def get_creds_by_registry(registry, repository, registry_creds=None):
    user = pw = registry_verify = None
    if registry_creds:
        try:
            registry_creds.sort(key=(lambda x: len(x['registry'])), reverse=True)
            for registry_record in registry_creds:
                if registry_record_matches(registry_record['registry'], registry, repository):
                    if (registry_record['record_state_key'] not in ['active']):
                        try:
                            last_try = int(registry_record['record_state_val'])
                        except:
                            last_try = 0
                        if ((int(time.time()) - last_try) < 60):
                            logger.debug(('SKIPPING REGISTRY ATTEMPT: ' + str(registry_record['record_state_key'])))
                            raise Exception(('registry not available - ' + str(registry_record['record_state_key'])))
                    (user, pw) = get_docker_registry_userpw(registry_record)
                    registry_verify = registry_record['registry_verify']
                    break
        except Exception as err:
            raise err
    return (user, pw, registry_verify)
def get_creds_by_registry(registry, repository, registry_creds=None):
    user = pw = registry_verify = None
    if registry_creds:
        try:
            registry_creds.sort(key=(lambda x: len(x['registry'])), reverse=True)
            for registry_record in registry_creds:
                if registry_record_matches(registry_record['registry'], registry, repository):
                    if (registry_record['record_state_key'] not in ['active']):
                        try:
                            last_try = int(registry_record['record_state_val'])
                        except:
                            last_try = 0
                        if ((int(time.time()) - last_try) < 60):
                            logger.debug(('SKIPPING REGISTRY ATTEMPT: ' + str(registry_record['record_state_key'])))
                            raise Exception(('registry not available - ' + str(registry_record['record_state_key'])))
                    (user, pw) = get_docker_registry_userpw(registry_record)
                    registry_verify = registry_record['registry_verify']
                    break
        except Exception as err:
            raise err
    return (user, pw, registry_verify)