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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of BaseCommand.


9
10
11
12
13
# File 'lib/gitlab/kubernetes/helm/base_command.rb', line 9

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

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files


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

def files
  @files
end

#nameObject (readonly)

Returns the value of attribute name


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

def name
  @name
end

Instance Method Details

#cluster_role_binding_resourceObject


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/gitlab/kubernetes/helm/base_command.rb', line 45

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


35
36
37
# File 'lib/gitlab/kubernetes/helm/base_command.rb', line 35

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

#file_namesObject


57
58
59
# File 'lib/gitlab/kubernetes/helm/base_command.rb', line 57

def file_names
  files.keys
end

#generate_scriptObject


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

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

#pod_nameObject


31
32
33
# File 'lib/gitlab/kubernetes/helm/base_command.rb', line 31

def pod_name
  "install-#{name}"
end

#pod_resourceObject


19
20
21
22
23
# File 'lib/gitlab/kubernetes/helm/base_command.rb', line 19

def pod_resource
   = rbac? ?  : nil

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

#rbac?Boolean

Returns:

  • (Boolean)

15
16
17
# File 'lib/gitlab/kubernetes/helm/base_command.rb', line 15

def rbac?
  @rbac
end

#service_account_resourceObject


39
40
41
42
43
# File 'lib/gitlab/kubernetes/helm/base_command.rb', line 39

def 
  return unless rbac?

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