Welcome to mirror list, hosted at ThFree Co, Russian Federation.

reset_command.rb « v2 « helm « kubernetes « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 172a0884c496c75cbedd2b39db9a6a3e5496d61f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

module Gitlab
  module Kubernetes
    module Helm
      module V2
        class ResetCommand < BaseCommand
          include ClientCommand

          def generate_script
            super + [
              reset_helm_command,
              delete_tiller_replicaset,
              delete_tiller_clusterrolebinding
            ].join("\n")
          end

          def pod_name
            "uninstall-#{name}"
          end

          private

          # This method can be delete once we upgrade Helm to > 12.13.0
          # https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/27096#note_159695900
          #
          # Tracking this method to be removed here:
          # https://gitlab.com/gitlab-org/gitlab-foss/issues/52791#note_199374155
          def delete_tiller_replicaset
            delete_args = %w[replicaset -n gitlab-managed-apps -l name=tiller]

            Gitlab::Kubernetes::KubectlCmd.delete(*delete_args)
          end

          def delete_tiller_clusterrolebinding
            delete_args = %w[clusterrolebinding tiller-admin]

            Gitlab::Kubernetes::KubectlCmd.delete(*delete_args)
          end

          def reset_helm_command
            command = %w[helm reset] + optional_tls_flags

            command.shelljoin
          end
        end
      end
    end
  end
end