Module: Dapp::Kube::Dapp::Command::Dismiss

Included in:
Dapp
Defined in:
lib/dapp/kube/dapp/command/dismiss.rb

Instance Method Summary collapse

Instance Method Details

#kube_check_helm_release!Object



38
39
40
41
42
43
44
45
# File 'lib/dapp/kube/dapp/command/dismiss.rb', line 38

def kube_check_helm_release!
  pr = shellout([
    "helm",
    ("--kube-context #{custom_kube_context}" if custom_kube_context),
    "list | grep #{kube_release_name}"
  ].compact.join(" "))
  raise ::Dapp::Error::Command, code: :helm_release_not_exist, data: { name: kube_release_name } if pr.status == 1 || pr.stdout.empty?
end

#kube_dismissObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dapp/kube/dapp/command/dismiss.rb', line 6

def kube_dismiss
  command = "dismiss"

  # TODO: move release name logic to golang
  release_name = kube_release_name

  res = ruby2go_deploy(
    "command" => command,
    "releaseName" => release_name,
    "rubyCliOptions" => JSON.dump(self.options),
  )

  raise ::Dapp::Error::Command, code: :ruby2go_deploy_command_failed, data: { command: command, message: res["error"] } unless res["error"].nil?
end

#kube_dismiss_oldObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dapp/kube/dapp/command/dismiss.rb', line 21

def kube_dismiss_old
  lock_helm_release do
    kube_check_helm!
    kube_check_helm_release!
    log_process("Delete release #{kube_release_name}") do
      shellout!([
        "helm",
        ("--kube-context #{custom_kube_context}" if custom_kube_context),
        "delete",
        kube_release_name,
        "--purge",
      ].compact.join(" "))
      kubernetes.delete_namespace!(kube_namespace) if options[:with_namespace]
    end
  end
end