Class: VagrantK8s::Config
- Inherits:
-
Object
- Object
- VagrantK8s::Config
- Defined in:
- lib/vagrant-k8s/config.rb
Overview
Vagrant configuration for connecting to a Kubernetes cluster.
Instance Attribute Summary collapse
-
#context ⇒ String?
Kubeconfig context used for kubectl and Helm commands.
-
#kubeconfig ⇒ String?
Path to the kubeconfig file, relative to the Vagrantfile.
-
#kubectl ⇒ String
Path to the kubectl executable.
-
#namespace ⇒ String?
Default namespace for kubectl and Helm commands.
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.
17 18 19 20 21 22 |
# File 'lib/vagrant-k8s/config.rb', line 17 def initialize @kubeconfig = UNSET_VALUE @context = UNSET_VALUE @namespace = UNSET_VALUE @kubectl = UNSET_VALUE end |
Instance Attribute Details
#context ⇒ String?
Returns Kubeconfig context used for kubectl and Helm commands.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-k8s/config.rb', line 14 class Config < Vagrant.plugin('2', :config) attr_accessor :kubeconfig, :context, :namespace, :kubectl def initialize @kubeconfig = UNSET_VALUE @context = UNSET_VALUE @namespace = UNSET_VALUE @kubectl = UNSET_VALUE end 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 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 end |
#kubeconfig ⇒ String?
Returns Path to the kubeconfig file, relative to the Vagrantfile.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-k8s/config.rb', line 14 class Config < Vagrant.plugin('2', :config) attr_accessor :kubeconfig, :context, :namespace, :kubectl def initialize @kubeconfig = UNSET_VALUE @context = UNSET_VALUE @namespace = UNSET_VALUE @kubectl = UNSET_VALUE end 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 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 end |
#kubectl ⇒ String
Returns Path to the kubectl executable.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-k8s/config.rb', line 14 class Config < Vagrant.plugin('2', :config) attr_accessor :kubeconfig, :context, :namespace, :kubectl def initialize @kubeconfig = UNSET_VALUE @context = UNSET_VALUE @namespace = UNSET_VALUE @kubectl = UNSET_VALUE end 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 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 end |
#namespace ⇒ String?
Returns Default namespace for kubectl and Helm commands.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-k8s/config.rb', line 14 class Config < Vagrant.plugin('2', :config) attr_accessor :kubeconfig, :context, :namespace, :kubectl def initialize @kubeconfig = UNSET_VALUE @context = UNSET_VALUE @namespace = UNSET_VALUE @kubectl = UNSET_VALUE end 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 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 end |
Instance Method Details
#finalize! ⇒ Object
24 25 26 27 28 29 |
# File 'lib/vagrant-k8s/config.rb', line 24 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
31 32 33 34 35 36 37 38 |
# File 'lib/vagrant-k8s/config.rb', line 31 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 |