Class: VagrantPlugins::Rancher::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Rancher::Config
- Defined in:
- lib/vagrant-rancher/config.rb
Instance Attribute Summary collapse
-
#deactivate ⇒ Object
Returns the value of attribute deactivate.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#port ⇒ Object
Returns the value of attribute port.
-
#project ⇒ Object
Returns the value of attribute project.
-
#project_type ⇒ Object
Returns the value of attribute project_type.
-
#rancher_server_image ⇒ Object
Returns the value of attribute rancher_server_image.
-
#role ⇒ Object
Returns the value of attribute role.
-
#server_args ⇒ Object
Returns the value of attribute server_args.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(_machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vagrant-rancher/config.rb', line 15 def initialize @role = UNSET_VALUE @version = UNSET_VALUE @hostname = UNSET_VALUE @port = UNSET_VALUE @rancher_server_image = UNSET_VALUE @server_args = UNSET_VALUE @labels = UNSET_VALUE @deactivate = UNSET_VALUE @project = UNSET_VALUE @project_type = UNSET_VALUE end |
Instance Attribute Details
#deactivate ⇒ Object
Returns the value of attribute deactivate.
8 9 10 |
# File 'lib/vagrant-rancher/config.rb', line 8 def deactivate @deactivate end |
#hostname ⇒ Object
Returns the value of attribute hostname.
6 7 8 |
# File 'lib/vagrant-rancher/config.rb', line 6 def hostname @hostname end |
#labels ⇒ Object
Returns the value of attribute labels.
11 12 13 |
# File 'lib/vagrant-rancher/config.rb', line 11 def labels @labels end |
#port ⇒ Object
Returns the value of attribute port.
7 8 9 |
# File 'lib/vagrant-rancher/config.rb', line 7 def port @port end |
#project ⇒ Object
Returns the value of attribute project.
12 13 14 |
# File 'lib/vagrant-rancher/config.rb', line 12 def project @project end |
#project_type ⇒ Object
Returns the value of attribute project_type.
13 14 15 |
# File 'lib/vagrant-rancher/config.rb', line 13 def project_type @project_type end |
#rancher_server_image ⇒ Object
Returns the value of attribute rancher_server_image.
9 10 11 |
# File 'lib/vagrant-rancher/config.rb', line 9 def rancher_server_image @rancher_server_image end |
#role ⇒ Object
Returns the value of attribute role.
4 5 6 |
# File 'lib/vagrant-rancher/config.rb', line 4 def role @role end |
#server_args ⇒ Object
Returns the value of attribute server_args.
10 11 12 |
# File 'lib/vagrant-rancher/config.rb', line 10 def server_args @server_args end |
#version ⇒ Object
Returns the value of attribute version.
5 6 7 |
# File 'lib/vagrant-rancher/config.rb', line 5 def version @version end |
Instance Method Details
#finalize! ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-rancher/config.rb', line 28 def finalize! @role = 'server' if @role == UNSET_VALUE @version = 'latest' if @version == UNSET_VALUE @hostname = nil if @hostname == UNSET_VALUE @port = 8080 if @port == UNSET_VALUE @rancher_server_image = 'rancher/server' if @rancher_server_image == UNSET_VALUE @server_args = nil if @server_args == UNSET_VALUE @labels = nil if @labels == UNSET_VALUE @deactivate = false if @deactivate == UNSET_VALUE @project = 'Default' if @project == UNSET_VALUE @project_type = 'cattle' if @project_type == UNSET_VALUE end |
#validate(_machine) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/vagrant-rancher/config.rb', line 41 def validate(_machine) errors = _detected_errors unless role == 'server' || role == 'agent' errors << ':rancher provisioner requires role to either be "server" or "agent"' end unless version.is_a?(String) || version.nil? errors << ':rancher provisioner requires version to be a string' end unless hostname.is_a?(String) errors << ':rancher provisioner requires hostname to be set to a string' end unless port.is_a?(Fixnum) || port.is_a?(Fixnum) errors << ':rancher provisioner requires port to be a number' end unless rancher_server_image.is_a?(String) || rancher_server_image.nil? errors << ':rancher provisioner requires rancher_server_image to be a string' end unless server_args.is_a?(String) || server_args.nil? errors << ':rancher provisioner requires server_args to be a string' end unless labels.is_a?(Array) || labels.nil? errors << ':rancher provisioner requires labels to be an array' end unless deactivate.is_a?(TrueClass) || deactivate.is_a?(FalseClass) errors << ':rancher provisioner requires deactivate to be a bool' end unless project.is_a?(String) || project.nil? errors << ':rancher provisioner requires project to be a string' end unless ['cattle', 'kubernetes', 'swarm'].include? project_type || project_type.nil? errors << ':rancher provisioner requires project_type to be one of cattle, kubernetes or swarm' end { 'rancher provisioner' => errors } end |