Sha256: 5ba438c1be6887d15ac1e01a7814cb81d53c75eb662fff2823979b2103a7c04c

Contents?: true

Size: 754 Bytes

Versions: 3

Compression:

Stored size: 754 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 SECRETS_VAULT_AUTH_TOKEN env' if missing_auth_token?
        error! 'Missing SECRETS_VAULT_AUTH_METHOD env' if missing_auth_method?
      end

      private

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
secrets_cli-0.2.0 lib/secrets_cli/check/vault.rb
secrets_cli-0.1.1 lib/secrets_cli/check/vault.rb
secrets_cli-0.1.0 lib/secrets_cli/check/vault.rb