Module: ForemanVault::Macros

Defined in:
app/lib/foreman_vault/macros.rb

Defined Under Namespace

Classes: VaultError

Instance Method Summary collapse

Instance Method Details

#vault_issue_certificate(vault_connection_name, secret_path, *options) ⇒ Object



14
15
16
17
18
19
20
# File 'app/lib/foreman_vault/macros.rb', line 14

def vault_issue_certificate(vault_connection_name, secret_path, *options)
  vault = VaultConnection.find_by!(name: vault_connection_name)
  raise VaultError.new(N_('Invalid token for %s'), vault.name) if vault.with_token? && !vault.token_valid?
  vault.issue_certificate(secret_path, *options)
rescue ActiveRecord::RecordNotFound => e
  raise VaultError, e.message
end

#vault_secret(vault_connection_name, secret_path) ⇒ Object



5
6
7
8
9
10
11
12
# File 'app/lib/foreman_vault/macros.rb', line 5

def vault_secret(vault_connection_name, secret_path)
  vault = VaultConnection.find_by!(name: vault_connection_name)
  raise VaultError.new(N_('Invalid token for %s'), vault.name) if vault.with_token? && !vault.token_valid?

  vault.fetch_secret(secret_path)
rescue ActiveRecord::RecordNotFound => e
  raise VaultError, e.message
end