Exemple #1
0
 def __init__(self) -> None:
     super().__init__()
     if piggybacking.has_pykube():
         self._activities.append(
             handlers.ActivityHandler(
                 id=ids.HandlerId('login_via_pykube'),
                 fn=piggybacking.login_via_pykube,
                 activity=causes.Activity.AUTHENTICATION,
                 errors=execution.ErrorsMode.IGNORED,
                 param=None,
                 timeout=None,
                 retries=None,
                 backoff=None,
                 _fallback=True,
             ))
     if piggybacking.has_client():
         self._activities.append(
             handlers.ActivityHandler(
                 id=ids.HandlerId('login_via_client'),
                 fn=piggybacking.login_via_client,
                 activity=causes.Activity.AUTHENTICATION,
                 errors=execution.ErrorsMode.IGNORED,
                 param=None,
                 timeout=None,
                 retries=None,
                 backoff=None,
                 _fallback=True,
             ))
Exemple #2
0
    def __init__(self) -> None:
        super().__init__()

        if piggybacking.has_pykube():
            self._activities.append(
                handlers.ActivityHandler(
                    id=ids.HandlerId('login_via_pykube'),
                    fn=piggybacking.login_via_pykube,
                    activity=causes.Activity.AUTHENTICATION,
                    errors=execution.ErrorsMode.IGNORED,
                    param=None,
                    timeout=None,
                    retries=None,
                    backoff=None,
                    _fallback=True,
                ))
        if piggybacking.has_client():
            self._activities.append(
                handlers.ActivityHandler(
                    id=ids.HandlerId('login_via_client'),
                    fn=piggybacking.login_via_client,
                    activity=causes.Activity.AUTHENTICATION,
                    errors=execution.ErrorsMode.IGNORED,
                    param=None,
                    timeout=None,
                    retries=None,
                    backoff=None,
                    _fallback=True,
                ))

        # As a last resort, fall back to rudimentary logins if no advanced ones are available.
        thirdparties_present = piggybacking.has_pykube(
        ) or piggybacking.has_client()
        if not thirdparties_present and piggybacking.has_kubeconfig():
            self._activities.append(
                handlers.ActivityHandler(
                    id=ids.HandlerId('login_with_kubeconfig'),
                    fn=piggybacking.login_with_kubeconfig,
                    activity=causes.Activity.AUTHENTICATION,
                    errors=execution.ErrorsMode.IGNORED,
                    param=None,
                    timeout=None,
                    retries=None,
                    backoff=None,
                    _fallback=True,
                ))
        if not thirdparties_present and piggybacking.has_service_account():
            self._activities.append(
                handlers.ActivityHandler(
                    id=ids.HandlerId('login_with_service_account'),
                    fn=piggybacking.login_with_service_account,
                    activity=causes.Activity.AUTHENTICATION,
                    errors=execution.ErrorsMode.IGNORED,
                    param=None,
                    timeout=None,
                    retries=None,
                    backoff=None,
                    _fallback=True,
                ))
Exemple #3
0
 def decorator(  # lgtm[py/similar-function]
         fn: callbacks.ActivityFn,
 ) -> callbacks.ActivityFn:
     real_registry = registry if registry is not None else registries.get_default_registry()
     real_id = registries.generate_id(fn=fn, id=id)
     handler = handlers.ActivityHandler(
         fn=fn, id=real_id, param=param,
         errors=errors, timeout=timeout, retries=retries, backoff=backoff,
         activity=causes.Activity.AUTHENTICATION,
     )
     real_registry._activities.append(handler)
     return fn