Class: VagrantK8s::Config
- Inherits:
-
Object
- Object
- VagrantK8s::Config
- Defined in:
- lib/vagrant-k8s/config.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#kubeconfig ⇒ Object
Returns the value of attribute kubeconfig.
-
#kubectl ⇒ Object
Returns the value of attribute kubectl.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
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.
7 8 9 10 11 12 |
# File 'lib/vagrant-k8s/config.rb', line 7 def initialize @kubeconfig = UNSET_VALUE @context = UNSET_VALUE @namespace = UNSET_VALUE @kubectl = UNSET_VALUE end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
5 6 7 |
# File 'lib/vagrant-k8s/config.rb', line 5 def context @context end |
#kubeconfig ⇒ Object
Returns the value of attribute kubeconfig.
5 6 7 |
# File 'lib/vagrant-k8s/config.rb', line 5 def kubeconfig @kubeconfig end |
#kubectl ⇒ Object
Returns the value of attribute kubectl.
5 6 7 |
# File 'lib/vagrant-k8s/config.rb', line 5 def kubectl @kubectl end |
#namespace ⇒ Object
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/vagrant-k8s/config.rb', line 5 def namespace @namespace end |
Instance Method Details
#finalize! ⇒ Object
14 15 16 17 18 19 |
# File 'lib/vagrant-k8s/config.rb', line 14 def finalize! @kubeconfig = nil if @kubeconfig == UNSET_VALUE @context = nil if @context == UNSET_VALUE @namespace = nil if @namespace == UNSET_VALUE @kubectl = 'kubectl' if @kubectl == UNSET_VALUE end |
#validate(_machine) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/vagrant-k8s/config.rb', line 21 def validate(_machine) errors = [] errors << 'k8s.kubeconfig must be a path string or nil' unless @kubeconfig.nil? || @kubeconfig.is_a?(String) errors << 'k8s.context must be a string or nil' unless @context.nil? || @context.is_a?(String) errors << 'k8s.namespace must be a string or nil' unless @namespace.nil? || @namespace.is_a?(String) errors << 'k8s.kubectl must be a command string' unless @kubectl.is_a?(String) && !@kubectl.empty? { 'vagrant-k8s' => errors } end |