class Veil::CredentialCollection::ChefSecretsFd

Public Class Methods

new(opts = {}) click to toggle source

Create a new ChefSecretsFd

@param [Hash] opts

ignored
# File lib/veil/credential_collection/chef_secrets_fd.rb, line 13
def initialize(opts = {})
  @credentials = {}
  import_credentials_hash(inflate_secrets_from_fd)
end

Public Instance Methods

inflate_secrets_from_fd() click to toggle source
# File lib/veil/credential_collection/chef_secrets_fd.rb, line 25
def inflate_secrets_from_fd
  if ENV['CHEF_SECRETS_FD'].nil?
    raise InvalidCredentialCollectionFd.new("CHEF_SECRETS_FD not found in environment")
  end

  fd = ENV['CHEF_SECRETS_FD'].to_i
  value = nil

  begin
    file = IO.new(fd, "r")
    value = file.gets
  rescue StandardError => e
    msg = "A problem occured trying to read passed file descriptor: #{e}"
    raise InvalidCredentialCollectionFd.new(msg)
  ensure
    file.close if file
  end

  if !value
    msg = "File at CHEF_SECRETS_FD (#{fd}) did not contain any data!"
    raise InvalidCredentialCollectionFd.new(msg)
  end

  begin
    JSON.parse(value)
  rescue JSON::ParserError => e
    msg = "Chef secrets data could not be parsed: #{e.message}"
    raise InvalidCredentialCollectionFd.new(msg)
  end
end
rotate() click to toggle source

Unsupported methods

# File lib/veil/credential_collection/chef_secrets_fd.rb, line 19
def rotate
  raise NotImplementedError
end
Also aliased as: rotate_credentials, save
rotate_credentials()
Alias for: rotate
save()
Alias for: rotate