Module: Hyperkit::Default

Defined in:
lib/hyperkit/default.rb

Overview

Default configuration options for Client

Constant Summary collapse

API_ENDPOINT =

Default API endpoint

"https://localhost:8443".freeze
AUTO_SYNC =

Default auto-sync value

true
CLIENT_CERT =

Default client certificate file for authentication

File.join(ENV['HOME'], '.config', 'lxc', 'client.crt').freeze
CLIENT_KEY =

Default client key file for authentication

File.join(ENV['HOME'], '.config', 'lxc', 'client.key').freeze
MEDIA_TYPE =

Default media type

'application/json'
RACK_BUILDER_CLASS =

In Faraday 0.9, Faraday::Builder was renamed to Faraday::RackBuilder

defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder
MIDDLEWARE =

Default Faraday middleware stack

RACK_BUILDER_CLASS.new do |builder|
  builder.use Hyperkit::Middleware::FollowRedirects
  builder.use Hyperkit::Response::RaiseError
  builder.adapter Faraday.default_adapter
end
USER_AGENT =

Default User Agent header string

"Hyperkit Ruby Gem #{Hyperkit::VERSION}".freeze
VERIFY_SSL =

Default to verifying SSL certificates

true

Class Method Summary collapse

Class Method Details

.api_endpointString

Default API endpoint from ENV or API_ENDPOINT


90
91
92
# File 'lib/hyperkit/default.rb', line 90

def api_endpoint
  ENV['HYPERKIT_API_ENDPOINT'] || API_ENDPOINT
end

.auto_syncObject

Default auto-sync value from ENV or AUTO_SYNC


95
96
97
# File 'lib/hyperkit/default.rb', line 95

def auto_sync
  ENV['HYPERKIT_AUTO_SYNC'] || AUTO_SYNC
end

.client_certString

Default client certificate file from ENV or CLIENT_CERT


101
102
103
# File 'lib/hyperkit/default.rb', line 101

def client_cert
  ENV['HYPERKIT_CLIENT_CERT'] || CLIENT_CERT
end

.client_keyString

Default client key file from ENV or CLIENT_KEY


107
108
109
# File 'lib/hyperkit/default.rb', line 107

def client_key
  ENV['HYPERKIT_KEY'] || CLIENT_KEY
end

.connection_optionsHash

Default options for Faraday::Connection


66
67
68
69
70
71
72
73
74
# File 'lib/hyperkit/default.rb', line 66

def connection_options
  {
    :headers => {
      :accept => default_media_type,
      :user_agent => user_agent,
    },
    :ssl => {}
  }
end

.default_media_typeString

Default media type from ENV or MEDIA_TYPE


78
79
80
# File 'lib/hyperkit/default.rb', line 78

def default_media_type
  ENV['HYPERKIT_DEFAULT_MEDIA_TYPE'] || MEDIA_TYPE
end

.middlewareString

Default middleware stack for Faraday::Connection from MIDDLEWARE


114
115
116
# File 'lib/hyperkit/default.rb', line 114

def middleware
  MIDDLEWARE
end

.optionsHash

Configuration options


84
85
86
# File 'lib/hyperkit/default.rb', line 84

def options
  Hash[Hyperkit::Configurable.keys.map{|key| [key, send(key)]}]
end

.proxyString

Default proxy server URI for Faraday connection from ENV


120
121
122
# File 'lib/hyperkit/default.rb', line 120

def proxy
  ENV['HYPERKIT_PROXY']
end

.user_agentString

Default User-Agent header string from ENV or USER_AGENT


126
127
128
# File 'lib/hyperkit/default.rb', line 126

def user_agent
  ENV['HYPERKIT_USER_AGENT'] || USER_AGENT
end

.verify_sslBoolean

Default to verifying peer SSL certificate


132
133
134
# File 'lib/hyperkit/default.rb', line 132

def verify_ssl
  true
end