summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-04-16 07:51:05 +0000
committerSean McGivern <sean@gitlab.com>2019-04-16 07:51:05 +0000
commita2ceace1bdf0b55afb3706c46ee13c962d417303 (patch)
treec238f96c6d0ce3835fb9c6f6895903755b2068bc /lib
parentb754fb888891abcf24d8547d7f7b4d3f02c55d76 (diff)
parentf8326af565f31b781b79dc1431af2a4737722775 (diff)
downloadgitlab-ce-a2ceace1bdf0b55afb3706c46ee13c962d417303.tar.gz
Merge branch 'helm_uninstall_command' into 'master'
Helm DeleteCommand See merge request gitlab-org/gitlab-ce!27348
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/kubernetes/helm/delete_command.rb55
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