Sha256: 195fe7c9c9e862990de2efc7deedee4808db16989225c022b9aa9355c339177d

Contents?: true

Size: 838 Bytes

Versions: 56

Compression:

Stored size: 838 Bytes

Contents

module Conjur
  module IdentifierManipulation
    # injects account into 2-tokens id
    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_account, parts].flatten.join(":")
      end
      id
    end

    # removes accounts from 3+-tokens id, extracts kind
    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

    def conjur_account
      Conjur::Core::API.conjur_account
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
conjur-cli-4.28.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.27.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.26.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.25.2 lib/conjur/identifier_manipulation.rb
conjur-cli-4.25.1 lib/conjur/identifier_manipulation.rb
conjur-cli-4.25.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.24.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.23.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.22.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.21.1 lib/conjur/identifier_manipulation.rb
conjur-cli-4.21.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.20.1 lib/conjur/identifier_manipulation.rb
conjur-cli-4.19.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.18.6 lib/conjur/identifier_manipulation.rb
conjur-cli-4.18.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.17.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.16.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.15.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.14.0 lib/conjur/identifier_manipulation.rb
conjur-cli-4.13.1 lib/conjur/identifier_manipulation.rb