diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-17 00:08:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-17 00:08:00 +0300 |
commit | 69d6d3ca2013e97cfd2d89449669ea7bf475f4e9 (patch) | |
tree | 2cc4227ebfc52b7603691f06b0b8e09e030e8428 /lib/gitlab/kubernetes | |
parent | 01fdcf49b1553c22ae116fe96cedd7b91d02225c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/kubernetes')
-rw-r--r-- | lib/gitlab/kubernetes/helm/client_command.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm/install_command.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm/patch_command.rb | 73 |
3 files changed, 77 insertions, 4 deletions
diff --git a/lib/gitlab/kubernetes/helm/client_command.rb b/lib/gitlab/kubernetes/helm/client_command.rb index df3f35d1075..b953ce24c4a 100644 --- a/lib/gitlab/kubernetes/helm/client_command.rb +++ b/lib/gitlab/kubernetes/helm/client_command.rb @@ -43,6 +43,10 @@ module Gitlab optional_tls_flags end + def repository_update_command + 'helm repo update' + end + def optional_tls_flags return [] unless files.key?(:'ca.pem') diff --git a/lib/gitlab/kubernetes/helm/install_command.rb b/lib/gitlab/kubernetes/helm/install_command.rb index 82f6f5d0024..8e24cb4c24f 100644 --- a/lib/gitlab/kubernetes/helm/install_command.rb +++ b/lib/gitlab/kubernetes/helm/install_command.rb @@ -39,10 +39,6 @@ module Gitlab private - def repository_update_command - 'helm repo update' - end - # Uses `helm upgrade --install` which means we can use this for both # installation and uprade of applications def install_command diff --git a/lib/gitlab/kubernetes/helm/patch_command.rb b/lib/gitlab/kubernetes/helm/patch_command.rb new file mode 100644 index 00000000000..ed7a5c2b2d6 --- /dev/null +++ b/lib/gitlab/kubernetes/helm/patch_command.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +# PatchCommand is for updating values in installed charts without overwriting +# existing values. +module Gitlab + module Kubernetes + module Helm + class PatchCommand + include BaseCommand + include ClientCommand + + attr_reader :name, :files, :chart, :repository + attr_accessor :version + + def initialize(name:, chart:, files:, rbac:, version:, repository: nil) + # version is mandatory to prevent chart mismatches + # we do not want our values interpreted in the context of the wrong version + raise ArgumentError, 'version is required' if version.blank? + + @name = name + @chart = chart + @version = version + @rbac = rbac + @files = files + @repository = repository + end + + def generate_script + super + [ + init_command, + wait_for_tiller_command, + repository_command, + repository_update_command, + upgrade_command + ].compact.join("\n") + end + + def rbac? + @rbac + end + + private + + def upgrade_command + command = ['helm', 'upgrade', name, chart] + + reuse_values_flag + + tls_flags_if_remote_tiller + + version_flag + + namespace_flag + + value_flag + + command.shelljoin + end + + def reuse_values_flag + ['--reuse-values'] + end + + def value_flag + ['-f', "/data/helm/#{name}/config/values.yaml"] + end + + def namespace_flag + ['--namespace', Gitlab::Kubernetes::Helm::NAMESPACE] + end + + def version_flag + ['--version', version] + end + end + end + end +end |