lib/liberty_buildpack/services/vcap_services.rb
def one_service?(filter, *required_credentials)
      candidates = select(&matcher(filter))
      match = false

      if candidates.empty?
        @logger.debug("No service matching #{filter} was found")
      elsif candidates.one?
        if credentials?(candidates.first['credentials'], required_credentials)
          match = true
        else
          @logger.debug("A service with a name label or tag matching #{filter} was found, but was missing one of the required credentials #{required_credentials}")
        end
      else
        @logger.warn("Unable to resolve a single service matching #{filter}. Found multiple matches of #{candidates}.")
        raise "Unable to resolve a single service matching #{filter}. Multiple inexact matches exist."
      end

      match
    end
# Compares the name, label, and tags of each service to the given +filter+.  The method returns +true+ if the
# +filter+ matches exactly one service, +false+ otherwise.
#
# @param [Regexp, String] filter a +RegExp+ or +String+ to match against the name, label, and tags of the services
# @param [String] required_credentials an optional list of keys or groups of keys, where at one key from the
#                                      group, must exist in the credentials payload of the candidate service
# @return [Boolean] +true+ if the +filter+ matches exactly one service with the required credentials, +false+
#                   otherwise.
Compares the name, label, and tags of each service to the given +filter+.
Compares the name label and tags of each service to the given + filter + .
def one_service?(filter, *required_credentials)
      candidates = select(&matcher(filter))
      match = false
      if candidates.empty?
        @logger.debug("No service matching #{filter} was found")
      elsif candidates.one?
        if credentials?(candidates.first['credentials'], required_credentials)
          match = true
        else
          @logger.debug("A service with a name label or tag matching #{filter} was found, but was missing one of the required credentials #{required_credentials}")
        end
      else
        @logger.warn("Unable to resolve a single service matching #{filter}. Found multiple matches of #{candidates}.")
        raise "Unable to resolve a single service matching #{filter}. Multiple inexact matches exist."
      end
      match
    end
def one_service? ( filter , * required_credentials ) candidates = select ( & matcher ( filter ) ) match = false if candidates . empty? @logger . debug ( "No service matching #{filter} was found" ) elsif candidates . one? if credentials? ( candidates . first [ 'credentials' ] , required_credentials ) match = true else @logger . debug ( "A service with a name label or tag matching #{filter} was found, but was missing one of the required credentials #{required_credentials}" ) end else @logger . warn ( "Unable to resolve a single service matching #{filter}. Found multiple matches of #{candidates}." ) raise "Unable to resolve a single service matching #{filter}. Multiple inexact matches exist." end match end
Compares the name, label, and tags of each service to the given +filter+.
Compares the name label and tags of each service to the given + filter + .
+true+ if the +filter+ matches exactly one service with the required credentials, +false+ otherwise.
+ true + if the + filter + matches exactly one service with the required credentials + false + otherwise .
Boolean
filter
required_credentials
required_credentials an optional list of keys or groups of keys, where at one key from the group, must exist in the credentials payload of the candidate service
required_credentials an optional list of keys or groups of keys where at one key from the group must exist in the credentials payload of the candidate service