Class: Mortar::YankCommand

Inherits:
Command
  • Object
show all
Includes:
ClientHelper, TTYHelper
Defined in:
lib/mortar/yank_command.rb

Constant Summary

Constants inherited from Command

Command::CHECKSUM_ANNOTATION, Command::LABEL

Instance Method Summary collapse

Methods included from TTYHelper

#pastel

Methods included from ClientHelper

#build_kubeconfig_from_env, #client, #create_client

Instance Method Details

#executeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/mortar/yank_command.rb', line 16

def execute
  unless force?
    if $stdin.tty?
      print "enter '#{pastel.cyan(name)}' to confirm yank: "
      begin
        signal_error("confirmation did not match #{pastel.cyan(name)}.") unless $stdin.gets.chomp == name
      rescue Interrupt
        puts
        abort 'Canceled'
      end
    else
      signal_usage_error '--force required when running in a non-interactive mode'
    end
  end

  K8s::Stack.new(
    name, [],
    debug: debug?,
    label: LABEL,
    checksum_annotation: CHECKSUM_ANNOTATION
  ).prune(client, keep_resources: false)

  puts "yanked #{pastel.cyan(name)} successfully!" if $stdout.tty?
end