Class: Gitlab::Kubernetes::Helm::V2::BaseCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/kubernetes/helm/v2/base_command.rb

Constant Summary collapse

HELM_VERSION =
'2.17.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rbac:, name:, files:) ⇒ BaseCommand

Returns a new instance of BaseCommand.


12
13
14
15
16
# File 'lib/gitlab/kubernetes/helm/v2/base_command.rb', line 12

def initialize(rbac:, name:, files:)
  @rbac = rbac
  @name = name
  @files = files
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.


8
9
10
# File 'lib/gitlab/kubernetes/helm/v2/base_command.rb', line 8

def files
  @files
end

#nameObject (readonly)

Returns the value of attribute name.


8
9
10
# File 'lib/gitlab/kubernetes/helm/v2/base_command.rb', line 8

def name
  @name
end

Instance Method Details

#cluster_role_binding_resourceObject


52
53
54
55
56
57
58
59
60
61
62
# File 'lib/gitlab/kubernetes/helm/v2/base_command.rb', line 52

def cluster_role_binding_resource
  return unless rbac?

  subjects = [{ kind: 'ServiceAccount', name: , namespace: namespace }]

  Gitlab::Kubernetes::ClusterRoleBinding.new(
    cluster_role_binding_name,
    cluster_role_name,
    subjects
  ).generate
end

#config_map_resourceObject


42
43
44
# File 'lib/gitlab/kubernetes/helm/v2/base_command.rb', line 42

def config_map_resource
  Gitlab::Kubernetes::ConfigMap.new(name, files).generate
end

#envObject


18
19
20
# File 'lib/gitlab/kubernetes/helm/v2/base_command.rb', line 18

def env
  { TILLER_NAMESPACE: namespace }
end

#file_namesObject


64
65
66
# File 'lib/gitlab/kubernetes/helm/v2/base_command.rb', line 64

def file_names
  files.keys
end

#generate_scriptObject


32
33
34
35
36
# File 'lib/gitlab/kubernetes/helm/v2/base_command.rb', line 32

def generate_script
  <<~HEREDOC
    set -xeo pipefail
  HEREDOC
end

#pod_nameObject


38
39
40
# File 'lib/gitlab/kubernetes/helm/v2/base_command.rb', line 38

def pod_name
  "install-#{name}"
end

#pod_resourceObject


26
27
28
29
30
# File 'lib/gitlab/kubernetes/helm/v2/base_command.rb', line 26

def pod_resource
   = rbac? ?  : nil

  Gitlab::Kubernetes::Helm::Pod.new(self, namespace, service_account_name: ).generate
end

#rbac?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'lib/gitlab/kubernetes/helm/v2/base_command.rb', line 22

def rbac?
  @rbac
end

#service_account_resourceObject


46
47
48
49
50
# File 'lib/gitlab/kubernetes/helm/v2/base_command.rb', line 46

def 
  return unless rbac?

  Gitlab::Kubernetes::ServiceAccount.new(, namespace).generate
end