8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/easy_creds/actions/pull.rb', line 8
def self.call(ctx)
env = ctx.env
Theme.section("Pull — op://#{ctx.config.vault}/#{env} → local")
spinner = TTY::Spinner.new('[:spinner] Fetching from 1Password...', format: :dots)
spinner.auto_spin
remote_fields = ctx.op.item(env)
stored_key = ctx.op.read_credentials_key(env, ctx.config.credentials_item)
spinner.stop('')
unless remote_fields
Theme.failure("No item found at op://#{ctx.config.vault}/#{env}. Run `push` or `init` first.")
return
end
remote_hash = Flatten.unflatten(remote_fields)
if ctx.io.enc_exists?(env)
pull_with_diff(ctx, env, remote_hash, remote_fields, stored_key)
else
fresh_pull(ctx, env, remote_hash, remote_fields, stored_key)
end
offer_key_restore(ctx, env, stored_key)
end
|