Class: VagrantK8s::KustomizeConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-k8s/kustomize_provisioner.rb

Overview

Vagrant provisioner configuration for kubectl apply -k.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeKustomizeConfig

Returns a new instance of KustomizeConfig.



25
26
27
28
# File 'lib/vagrant-k8s/kustomize_provisioner.rb', line 25

def initialize
  @path = @namespace = @prune_selector = UNSET_VALUE
  @prune = @server_side = @force_conflicts = @wait = UNSET_VALUE
end

Instance Attribute Details

#force_conflictsBoolean

Returns Whether to pass --force-conflicts.

Returns:

  • (Boolean)

    Whether to pass --force-conflicts.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/vagrant-k8s/kustomize_provisioner.rb', line 22

class KustomizeConfig < Vagrant.plugin('2', :config)
  attr_accessor :path, :namespace, :prune, :prune_selector, :server_side, :force_conflicts, :wait

  def initialize
    @path = @namespace = @prune_selector = UNSET_VALUE
    @prune = @server_side = @force_conflicts = @wait = UNSET_VALUE
  end

  def finalize!
    @namespace = nil if @namespace == UNSET_VALUE
    @prune_selector = nil if @prune_selector == UNSET_VALUE
    @prune = false if @prune == UNSET_VALUE
    @server_side = false if @server_side == UNSET_VALUE
    @force_conflicts = false if @force_conflicts == UNSET_VALUE
    @wait = false if @wait == UNSET_VALUE
  end

  def validate(_machine)
    errors = []
    errors << 'kustomize.path is required' unless @path.is_a?(String) && !@path.empty?
    if @prune && !Kubeconfig.present?(@prune_selector)
      errors << 'kustomize.prune_selector is required when prune is true'
    end
    { 'vagrant-k8s' => errors }
  end
end

#namespaceString?

Returns Target namespace; falls back to k8s.namespace.

Returns:

  • (String, nil)

    Target namespace; falls back to k8s.namespace.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/vagrant-k8s/kustomize_provisioner.rb', line 22

class KustomizeConfig < Vagrant.plugin('2', :config)
  attr_accessor :path, :namespace, :prune, :prune_selector, :server_side, :force_conflicts, :wait

  def initialize
    @path = @namespace = @prune_selector = UNSET_VALUE
    @prune = @server_side = @force_conflicts = @wait = UNSET_VALUE
  end

  def finalize!
    @namespace = nil if @namespace == UNSET_VALUE
    @prune_selector = nil if @prune_selector == UNSET_VALUE
    @prune = false if @prune == UNSET_VALUE
    @server_side = false if @server_side == UNSET_VALUE
    @force_conflicts = false if @force_conflicts == UNSET_VALUE
    @wait = false if @wait == UNSET_VALUE
  end

  def validate(_machine)
    errors = []
    errors << 'kustomize.path is required' unless @path.is_a?(String) && !@path.empty?
    if @prune && !Kubeconfig.present?(@prune_selector)
      errors << 'kustomize.prune_selector is required when prune is true'
    end
    { 'vagrant-k8s' => errors }
  end
end

#pathString

Returns Kustomization directory, relative to the Vagrantfile.

Returns:

  • (String)

    Kustomization directory, relative to the Vagrantfile.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/vagrant-k8s/kustomize_provisioner.rb', line 22

class KustomizeConfig < Vagrant.plugin('2', :config)
  attr_accessor :path, :namespace, :prune, :prune_selector, :server_side, :force_conflicts, :wait

  def initialize
    @path = @namespace = @prune_selector = UNSET_VALUE
    @prune = @server_side = @force_conflicts = @wait = UNSET_VALUE
  end

  def finalize!
    @namespace = nil if @namespace == UNSET_VALUE
    @prune_selector = nil if @prune_selector == UNSET_VALUE
    @prune = false if @prune == UNSET_VALUE
    @server_side = false if @server_side == UNSET_VALUE
    @force_conflicts = false if @force_conflicts == UNSET_VALUE
    @wait = false if @wait == UNSET_VALUE
  end

  def validate(_machine)
    errors = []
    errors << 'kustomize.path is required' unless @path.is_a?(String) && !@path.empty?
    if @prune && !Kubeconfig.present?(@prune_selector)
      errors << 'kustomize.prune_selector is required when prune is true'
    end
    { 'vagrant-k8s' => errors }
  end
end

#pruneBoolean

Returns Whether to pass --prune (requires prune_selector).

Returns:

  • (Boolean)

    Whether to pass --prune (requires prune_selector).



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/vagrant-k8s/kustomize_provisioner.rb', line 22

class KustomizeConfig < Vagrant.plugin('2', :config)
  attr_accessor :path, :namespace, :prune, :prune_selector, :server_side, :force_conflicts, :wait

  def initialize
    @path = @namespace = @prune_selector = UNSET_VALUE
    @prune = @server_side = @force_conflicts = @wait = UNSET_VALUE
  end

  def finalize!
    @namespace = nil if @namespace == UNSET_VALUE
    @prune_selector = nil if @prune_selector == UNSET_VALUE
    @prune = false if @prune == UNSET_VALUE
    @server_side = false if @server_side == UNSET_VALUE
    @force_conflicts = false if @force_conflicts == UNSET_VALUE
    @wait = false if @wait == UNSET_VALUE
  end

  def validate(_machine)
    errors = []
    errors << 'kustomize.path is required' unless @path.is_a?(String) && !@path.empty?
    if @prune && !Kubeconfig.present?(@prune_selector)
      errors << 'kustomize.prune_selector is required when prune is true'
    end
    { 'vagrant-k8s' => errors }
  end
end

#prune_selectorString?

Returns Label selector passed to --selector when pruning.

Returns:

  • (String, nil)

    Label selector passed to --selector when pruning.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/vagrant-k8s/kustomize_provisioner.rb', line 22

class KustomizeConfig < Vagrant.plugin('2', :config)
  attr_accessor :path, :namespace, :prune, :prune_selector, :server_side, :force_conflicts, :wait

  def initialize
    @path = @namespace = @prune_selector = UNSET_VALUE
    @prune = @server_side = @force_conflicts = @wait = UNSET_VALUE
  end

  def finalize!
    @namespace = nil if @namespace == UNSET_VALUE
    @prune_selector = nil if @prune_selector == UNSET_VALUE
    @prune = false if @prune == UNSET_VALUE
    @server_side = false if @server_side == UNSET_VALUE
    @force_conflicts = false if @force_conflicts == UNSET_VALUE
    @wait = false if @wait == UNSET_VALUE
  end

  def validate(_machine)
    errors = []
    errors << 'kustomize.path is required' unless @path.is_a?(String) && !@path.empty?
    if @prune && !Kubeconfig.present?(@prune_selector)
      errors << 'kustomize.prune_selector is required when prune is true'
    end
    { 'vagrant-k8s' => errors }
  end
end

#server_sideBoolean

Returns Whether to pass --server-side.

Returns:

  • (Boolean)

    Whether to pass --server-side.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/vagrant-k8s/kustomize_provisioner.rb', line 22

class KustomizeConfig < Vagrant.plugin('2', :config)
  attr_accessor :path, :namespace, :prune, :prune_selector, :server_side, :force_conflicts, :wait

  def initialize
    @path = @namespace = @prune_selector = UNSET_VALUE
    @prune = @server_side = @force_conflicts = @wait = UNSET_VALUE
  end

  def finalize!
    @namespace = nil if @namespace == UNSET_VALUE
    @prune_selector = nil if @prune_selector == UNSET_VALUE
    @prune = false if @prune == UNSET_VALUE
    @server_side = false if @server_side == UNSET_VALUE
    @force_conflicts = false if @force_conflicts == UNSET_VALUE
    @wait = false if @wait == UNSET_VALUE
  end

  def validate(_machine)
    errors = []
    errors << 'kustomize.path is required' unless @path.is_a?(String) && !@path.empty?
    if @prune && !Kubeconfig.present?(@prune_selector)
      errors << 'kustomize.prune_selector is required when prune is true'
    end
    { 'vagrant-k8s' => errors }
  end
end

#waitBoolean

Returns Whether to wait for pods to become ready after applying.

Returns:

  • (Boolean)

    Whether to wait for pods to become ready after applying.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/vagrant-k8s/kustomize_provisioner.rb', line 22

class KustomizeConfig < Vagrant.plugin('2', :config)
  attr_accessor :path, :namespace, :prune, :prune_selector, :server_side, :force_conflicts, :wait

  def initialize
    @path = @namespace = @prune_selector = UNSET_VALUE
    @prune = @server_side = @force_conflicts = @wait = UNSET_VALUE
  end

  def finalize!
    @namespace = nil if @namespace == UNSET_VALUE
    @prune_selector = nil if @prune_selector == UNSET_VALUE
    @prune = false if @prune == UNSET_VALUE
    @server_side = false if @server_side == UNSET_VALUE
    @force_conflicts = false if @force_conflicts == UNSET_VALUE
    @wait = false if @wait == UNSET_VALUE
  end

  def validate(_machine)
    errors = []
    errors << 'kustomize.path is required' unless @path.is_a?(String) && !@path.empty?
    if @prune && !Kubeconfig.present?(@prune_selector)
      errors << 'kustomize.prune_selector is required when prune is true'
    end
    { 'vagrant-k8s' => errors }
  end
end

Instance Method Details

#finalize!Object



30
31
32
33
34
35
36
37
# File 'lib/vagrant-k8s/kustomize_provisioner.rb', line 30

def finalize!
  @namespace = nil if @namespace == UNSET_VALUE
  @prune_selector = nil if @prune_selector == UNSET_VALUE
  @prune = false if @prune == UNSET_VALUE
  @server_side = false if @server_side == UNSET_VALUE
  @force_conflicts = false if @force_conflicts == UNSET_VALUE
  @wait = false if @wait == UNSET_VALUE
end

#validate(_machine) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/vagrant-k8s/kustomize_provisioner.rb', line 39

def validate(_machine)
  errors = []
  errors << 'kustomize.path is required' unless @path.is_a?(String) && !@path.empty?
  if @prune && !Kubeconfig.present?(@prune_selector)
    errors << 'kustomize.prune_selector is required when prune is true'
  end
  { 'vagrant-k8s' => errors }
end