Class: Armrest::Services::KeyVault::Secret

Inherits:
Base
  • Object
show all
Defined in:
lib/armrest/services/key_vault/secret.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Api::Settings

#client_id, #client_secret, #endpoint, #group, #location, #resource, #subscription_id, #tenant_id

Methods included from Api::HandleResponse

#load_json, #ok?

Methods included from Logging

#default_logger, #logger, #logger=

Constructor Details

This class inherits a constructor from Armrest::Services::Base

Instance Method Details

#show(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/armrest/services/key_vault/secret.rb', line 10

def show(options={})
  name = options[:name]
  @vault = options[:vault] || @options[:vault] || ENV['ARMREST_VAULT'] || self.class.vault
  version = "/#{version}" if @options[:version]
  begin
    resp = api.get("/secrets/#{name}#{version}")
  rescue SocketError => e
    if e.message.include?("vault.azure.net")
      message = "WARN: Vault not found. Vault: #{@vault}"
      logger.info message.color(:yellow)
      return message
    else
      raise
    end
  end

  case resp.code.to_s
  when /^2/
    data = JSON.load(resp.body)
    data['value']
  else
    message = standard_error_message(resp)
    logger.info "WARN: #{message}".color(:yellow)
    return message
  end
end