def _credentials(image_reference: str, privileges:Privileges=None): ci.util.check_type(image_reference, str) registry_cfg = model.container_registry.find_config(image_reference, privileges) if not registry_cfg: return None credentials = registry_cfg.credentials() return docker_creds.Basic(username=credentials.username(), password=credentials.passwd())
def _credentials(image_reference: str, privileges: Privileges = None): util.check_type(image_reference, str) cfg_factory = util.ctx().cfg_factory() matching_cfgs = [ cfg for cfg in cfg_factory._cfg_elements('container_registry') if cfg.image_ref_matches(image_reference, privileges=privileges) ] if not matching_cfgs: return None # use first match credentials = matching_cfgs[0].credentials() return docker_creds.Basic(username=credentials.username(), password=credentials.passwd())
def _credentials( image_reference: str, credentials_lookup: typing.Callable[[image_reference, oa.Privileges], oa.OciConfig], privileges: oa.Privileges = None, absent_ok: bool = False, ): if not isinstance(image_reference, str): raise ValueError(image_reference) oci_creds = credentials_lookup( image_reference=image_reference, privileges=privileges, absent_ok=absent_ok, ) if not oci_creds: return None # XXX currently, we only support basic-auth return docker_creds.Basic(username=oci_creds.username, password=oci_creds.password)
def _credentials(image_reference: str, privileges: Privileges = None): util.check_type(image_reference, str) credentials = _retrieve_matching_credentials(image_reference, privileges) return docker_creds.Basic(username=credentials.username(), password=credentials.passwd())