Sha256: 8c77d56ac273c6bd135f41c822d955a37b40fe5ce0406dc388d3fc5a88cb2eaf
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
module SecretsCli module Vault class Push < SecretsCli::Vault::Base attr_reader :secrets_storage_key, :secrets_field, :secrets, :secrets_file def initialize(options) super SecretsCli::Check::Secrets.new(options).call @secrets_storage_key = options.secrets_storage_key || config.secrets_storage_key @secrets_file = options.secrets_file || config.secrets_file @secrets = File.read(secrets_file) end def call return if !options.ci_mode && !are_you_sure? compare unless options.ci_mode super end private def command ::Vault.logical.write(secrets_full_storage_key, SECRETS_FIELD => secrets) secrets end def compare secrets = ::Vault.logical.read(secrets_full_storage_key) secrets = secrets.nil? ? ' ' : secrets.data[SECRETS_FIELD] diff = TTY::File.diff(secrets, secrets_file, verbose: false) return if diff == '' prompt.ok("There are some differences between #{secrets_file} and vault:") pretty_diff(diff) exit 0 unless prompt.yes?("Are you sure you want to override #{secrets_full_storage_key}?") end def are_you_sure? prompt.yes?("Are you sure you want to write #{secrets_file} to #{secrets_full_storage_key}") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
secrets_cli-1.7.0 | lib/secrets_cli/vault/push.rb |
secrets_cli-1.6.0 | lib/secrets_cli/vault/push.rb |
secrets_cli-1.5.0 | lib/secrets_cli/vault/push.rb |