diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-11-15 14:13:32 +0000 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-11-16 10:57:20 +0000 |
commit | a71b3f6a7c13fdc0978a1e9d0151fe15399b8b59 (patch) | |
tree | 87f00f405d5daea672b11efe06c2ab119ccddea6 /lib | |
parent | fe1469e12f7a1895cbf534f9ab17fd32af0e954c (diff) | |
download | gitlab-ce-a71b3f6a7c13fdc0978a1e9d0151fe15399b8b59.tar.gz |
Extract Helm::ClientCommand for shared commands
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/kubernetes/helm/client_command.rb | 26 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm/install_command.rb | 18 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm/upgrade_command.rb | 18 |
3 files changed, 30 insertions, 32 deletions
diff --git a/lib/gitlab/kubernetes/helm/client_command.rb b/lib/gitlab/kubernetes/helm/client_command.rb new file mode 100644 index 00000000000..0ff0169b61d --- /dev/null +++ b/lib/gitlab/kubernetes/helm/client_command.rb @@ -0,0 +1,26 @@ +module Gitlab + module Kubernetes + module Helm + module ClientCommand + def init_command + # Here we are always upgrading to the latest version of Tiller when + # installing an app. We ensure the helm version stored in the + # database is correct by also updating this after transition to + # :installed,:updated in Clusters::Concerns::ApplicationStatus + 'helm init --upgrade --tiller-namespace gitlab-managed-apps' + end + + def wait_for_tiller_command + # This is necessary to give Tiller time to restart after upgrade. + # Ideally we'd be able to use --wait but cannot because of + # https://github.com/helm/helm/issues/4855 + 'sleep 30' + end + + def repository_command + ['helm', 'repo', 'add', name, repository].shelljoin if repository + end + end + end + end +end diff --git a/lib/gitlab/kubernetes/helm/install_command.rb b/lib/gitlab/kubernetes/helm/install_command.rb index 5c7b6d6cb75..52700b5dc09 100644 --- a/lib/gitlab/kubernetes/helm/install_command.rb +++ b/lib/gitlab/kubernetes/helm/install_command.rb @@ -3,6 +3,7 @@ module Gitlab module Helm class InstallCommand include BaseCommand + include ClientCommand attr_reader :name, :files, :chart, :version, :repository, :preinstall, :postinstall @@ -20,10 +21,7 @@ module Gitlab def generate_script super + [ init_command, - # Sleep is necessary to give Tiller time to restart after upgrade. - # Ideally we'd be able to use --wait but cannot because of - # https://github.com/helm/helm/issues/4855 - sleep_command, + wait_for_tiller_command, repository_command, repository_update_command, preinstall_command, @@ -38,18 +36,6 @@ module Gitlab private - def init_command - 'helm init --upgrade --tiller-namespace gitlab-managed-apps' - end - - def sleep_command - 'sleep 30' - end - - def repository_command - ['helm', 'repo', 'add', name, repository].shelljoin if repository - end - def repository_update_command 'helm repo update' if repository end diff --git a/lib/gitlab/kubernetes/helm/upgrade_command.rb b/lib/gitlab/kubernetes/helm/upgrade_command.rb index 5b47944e5e6..9daffc138b5 100644 --- a/lib/gitlab/kubernetes/helm/upgrade_command.rb +++ b/lib/gitlab/kubernetes/helm/upgrade_command.rb @@ -5,6 +5,7 @@ module Gitlab module Helm class UpgradeCommand include BaseCommand + include ClientCommand attr_reader :name, :chart, :version, :repository, :files @@ -20,10 +21,7 @@ module Gitlab def generate_script super + [ init_command, - # Sleep is necessary to give Tiller time to restart after upgrade. - # Ideally we'd be able to use --wait but cannot because of - # https://github.com/helm/helm/issues/4855 - sleep_command, + wait_for_tiller_command, repository_command, script_command ].compact.join("\n") @@ -39,18 +37,6 @@ module Gitlab private - def init_command - 'helm init --upgrade --tiller-namespace gitlab-managed-apps' - end - - def sleep_command - 'sleep 30' - end - - def repository_command - "helm repo add #{name} #{repository}" if repository - end - def script_command upgrade_flags = "#{optional_version_flag}#{optional_tls_flags}" \ " --reset-values" \ |