Module: EasyCreds::Actions::Edit

Defined in:
lib/easy_creds/actions/edit.rb

Class Method Summary collapse

Class Method Details

.call(ctx, local: false) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/easy_creds/actions/edit.rb', line 10

def self.call(ctx, local: false)
  label = local ? "#{ctx.env}_local" : ctx.env
  Theme.section("Edit — credentials/#{label}.yml.enc")

  unless ctx.io.key_exists?(ctx.env, local: local)
    Theme.failure('No local key. Run `init` or `pull` first.')
    return
  end

  local_hash, remote_fields = load_data(ctx, local: local)
  local_flat  = Flatten.dot(local_hash)
  modified    = run_edit_loop(ctx, local_flat, remote_fields, local: local)

  persist(ctx, local_flat, label, local: local, modified: modified)
end