diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-04-10 21:09:48 +1200 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2019-04-16 09:10:11 +1000 |
commit | f8326af565f31b781b79dc1431af2a4737722775 (patch) | |
tree | e0d93824d6e320888818a914ed62e5dcafce891c /lib/gitlab/kubernetes | |
parent | 026c92d5fa82fac87386d5691c3d5b1e02f2eb5e (diff) | |
download | gitlab-ce-f8326af565f31b781b79dc1431af2a4737722775.tar.gz |
Implement commands to uninstall cluster applicationshelm_uninstall_command
This is the backend part which just allows uninstalling Prometheus for
now.
Diffstat (limited to 'lib/gitlab/kubernetes')
-rw-r--r-- | lib/gitlab/kubernetes/helm/delete_command.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/gitlab/kubernetes/helm/delete_command.rb b/lib/gitlab/kubernetes/helm/delete_command.rb new file mode 100644 index 00000000000..876994d2678 --- /dev/null +++ b/lib/gitlab/kubernetes/helm/delete_command.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +module Gitlab + module Kubernetes + module Helm + class DeleteCommand + include BaseCommand + include ClientCommand + + attr_accessor :name, :files + + def initialize(name:, rbac:, files:) + @name = name + @files = files + @rbac = rbac + end + + def generate_script + super + [ + init_command, + wait_for_tiller_command, + delete_command + ].compact.join("\n") + end + + def pod_name + "uninstall-#{name}" + end + + def rbac? + @rbac + end + + private + + def delete_command + command = ['helm', 'delete', '--purge', name] + optional_tls_flags + + command.shelljoin + end + + def optional_tls_flags + return [] unless files.key?(:'ca.pem') + + [ + '--tls', + '--tls-ca-cert', "#{files_dir}/ca.pem", + '--tls-cert', "#{files_dir}/cert.pem", + '--tls-key', "#{files_dir}/key.pem" + ] + end + end + end + end +end |