debian-mirror-gitlab/lib/gitlab/kubernetes/helm/install_command.rb

49 lines
1.1 KiB
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
module Gitlab
module Kubernetes
module Helm
2018-03-27 19:54:05 +05:30
class InstallCommand < BaseCommand
attr_reader :name, :chart, :repository, :values
2018-03-17 18:26:18 +05:30
2018-03-27 19:54:05 +05:30
def initialize(name, chart:, values:, repository: nil)
2018-03-17 18:26:18 +05:30
@name = name
@chart = chart
2018-03-27 19:54:05 +05:30
@values = values
@repository = repository
2018-03-17 18:26:18 +05:30
end
2018-03-27 19:54:05 +05:30
def generate_script
super + [
init_command,
repository_command,
script_command
].compact.join("\n")
2018-03-17 18:26:18 +05:30
end
2018-03-27 19:54:05 +05:30
def config_map?
true
end
def config_map_resource
Gitlab::Kubernetes::ConfigMap.new(name, values).generate
2018-03-17 18:26:18 +05:30
end
private
def init_command
2018-03-27 19:54:05 +05:30
'helm init --client-only >/dev/null'
2018-03-17 18:26:18 +05:30
end
2018-03-27 19:54:05 +05:30
def repository_command
"helm repo add #{name} #{repository}" if repository
2018-03-17 18:26:18 +05:30
end
2018-03-27 19:54:05 +05:30
def script_command
2018-03-17 18:26:18 +05:30
<<~HEREDOC
2018-03-27 19:54:05 +05:30
helm install #{chart} --name #{name} --namespace #{Gitlab::Kubernetes::Helm::NAMESPACE} -f /data/helm/#{name}/config/values.yaml >/dev/null
2018-03-17 18:26:18 +05:30
HEREDOC
end
end
end
end
end