Module: Conjur::IdentifierManipulation
- Included in:
- Command
- Defined in:
- lib/conjur/identifier_manipulation.rb
Instance Method Summary collapse
-
#full_resource_id(id) ⇒ Object
(also: #full_role_id)
injects account into 2-tokens id.
-
#get_kind_and_id_from_args(args, argname = 'id') ⇒ Object
removes accounts from 3+-tokens id, extracts kind.
Instance Method Details
#full_resource_id(id) ⇒ Object Also known as: full_role_id
injects account into 2-tokens id
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/conjur/identifier_manipulation.rb', line 4 def full_resource_id id parts = id.split(':') unless id.nil? if id.blank? or parts.size < 2 raise "Expecting at least two tokens in #{id}" end if parts.size == 2 id = [Conjur.configuration.account, parts].flatten.join(":") end id end |
#get_kind_and_id_from_args(args, argname = 'id') ⇒ Object
removes accounts from 3+-tokens id, extracts kind
18 19 20 21 22 23 24 25 |
# File 'lib/conjur/identifier_manipulation.rb', line 18 def get_kind_and_id_from_args args, argname='id' flat_id = require_arg(args, argname) tokens=flat_id.split(':') raise "At least 2 tokens expected in #{flat_id}" if tokens.size<2 tokens.shift if tokens.size>=3 # get rid of account kind=tokens.shift.gsub('-','_') [kind, tokens.join(':')] end |