Module: Vault::HID

Defined in:
lib/vault-tools/hid.rb

Constant Summary collapse

USER_HID_REGEX =
/\Auser(\d+)@heroku.com/
APP_HID_REGEX =
/\Aapp(\d+)@heroku.com/

Class Method Summary collapse

Class Method Details

.hid?(string) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
# File 'lib/vault-tools/hid.rb', line 25

def self.hid?(string)
  case string
  when APP_HID_REGEX; :app;
  when USER_HID_REGEX; :user;
  end
end

.hid_to_uuid(heroku_id) ⇒ String

Convert a Heroku app ID or user ID into a v5 UUID.

Parameters:

  • heroku_id (String)

    A Heroku app ID or user ID.

Returns:

  • (String)

    A v5 UUID that uniquely represents the app.

Raises:

  • (ArgumentError)

    Raised if a malformed Heroku ID is provided.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/vault-tools/hid.rb', line 13

def self.hid_to_uuid(heroku_id)
  case heroku_id
  when /^user/
    User.hid_to_uuid(heroku_id)
  when /^app/
    App.hid_to_uuid(heroku_id)
  else
    raise ArgumentError, "#{heroku_id} is not a valid Heroku app or " +
                         "user ID."
  end
end