Sha256: 06fb1b3bf6afaf232520ec125156fdf0ab3949ac376e8e62af39174fcf6cac8b

Contents?: true

Size: 722 Bytes

Versions: 3

Compression:

Stored size: 722 Bytes

Contents

module SecretsCli
  module Check
    class Vault
      include SecretsCli::Helpers

      attr_reader :options

      def initialize(options)
        @options = options
      end

      def call
        error! 'Missing vault' if TTY::Which.which('vault').nil?
        error! 'Missing VAULT_ADDR env' if ENV['VAULT_ADDR'].nil?
        error! 'Missing VAULT_AUTH_TOKEN env' if missing_auth_token?
        error! 'Missing VAULT_AUTH_METHOD env' if missing_auth_method?
      end

      private

      def missing_auth_token?
        options.auth_token.nil? && ENV['VAULT_AUTH_TOKEN'].nil?
      end

      def missing_auth_method?
        options.auth_method.nil? && ENV['VAULT_AUTH_METHOD'].nil?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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