Class: Eien::CLI::Secrets

Inherits:
CLI
  • Object
show all
Defined in:
lib/eien/cli/secrets.rb

Instance Method Summary collapse

Methods inherited from CLI

exit_on_failure?

Instance Method Details

#exportObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/eien/cli/secrets.rb', line 31

def export
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    ::Eien::Secrets::ExportTask.new(
      context,
      app,
      options[:name] || "default",
    ).run!
  end
end

#listObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/eien/cli/secrets.rb', line 13

def list
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    ::Eien::Secrets::ListTask.new(
      context,
      app,
      options[:name] || "default",
    ).run!
  end
end

#set(*raw_key_pairs) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/eien/cli/secrets.rb', line 49

def set(*raw_key_pairs)
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    key_pairs = raw_key_pairs.each_with_object({}) do |raw_key_pair, key_pairs|
      key, value = raw_key_pair.split("=")
      key_pairs[key] = value
    end

    ::Eien::Secrets::UpdateTask.new(
      context,
      app,
      options[:name] || "default",
      **key_pairs,
    ).run!
  end
end

#unset(*keys) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/eien/cli/secrets.rb', line 73

def unset(*keys)
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    key_pairs = keys.each_with_object({}) do |key, key_pairs|
      key_pairs[key] = nil
    end

    ::Eien::Secrets::UpdateTask.new(
      context,
      app,
      options[:name] || "default",
      **key_pairs,
    ).run!
  end
end