Sha256: b1c6a31e1ae84bf1cd2fa57dab3854fdc81fc684ab8666bb2ac162f0d1db8a99

Contents?: true

Size: 803 Bytes

Versions: 3

Compression:

Stored size: 803 Bytes

Contents

module SecretsCli
  module Vault
    class Push < SecretsCli::Vault::Base
      attr_reader :secrets_storage_key, :secrets_field, :secrets, :secrets_file

      def initialize(options)
        super
        @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.without_prompt && !are_you_sure?
        super
      end

      private

      def command
        "vault write #{secrets_full_storage_key} #{SECRETS_FIELD}=\"#{secrets}\""
      end

      def are_you_sure?
        prompt.yes?("Are you sure you want to write #{secrets_file} to #{secrets_full_storage_key}", default: 'Y')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
secrets_cli-0.4.0 lib/secrets_cli/vault/push.rb
secrets_cli-0.3.1 lib/secrets_cli/vault/push.rb
secrets_cli-0.3.0 lib/secrets_cli/vault/push.rb