unioslo / harborapi

Python async client for the Harbor REST API v2.0.
https://unioslo.github.io/harborapi/
MIT License
28 stars 5 forks source link

Rename `HarborAsyncClient.credentials` to `basicauth` #18

Closed pederhan closed 1 year ago

pederhan commented 1 year ago

credentials is too vague, and doesn't describe what kind of scheme is expected. Since the credentials are always base64 basic access credentials, we should change the name to reflect this. This is possibly a breaking change, and will require changes to HarborAsyncClient, utility functions such as utils.get_credentials, numerous tests, as well as many examples.

Despite the work required to change this name, it should be done, so that we have 3 distinct names for the different authentication methods.

To not break HarborAsyncClient, we can accept kwargs and issue a warning if credentials is used, and tell users to use the new basicauth instead:

class HarborAsyncClient:
    def __init__(
        self,
        # ...
        basicauth: Optional[str] = None,
        # ...
        **kwargs: Any,
    ) -> None:
        # ...
        elif basicauth or (credentials_kwarg := kwargs.get("credentials")):
            if credentials_kwarg:
                basicauth = credentials_kwarg
                warnings.warn(
                    "parameter 'credentials' is deprecated and will be removed, use 'basicauth'",
                    DeprecationWarning,
                )
            self.basicauth = basicauth
pederhan commented 1 year ago

Resolved by ddcf32837e221a3095ef0ace36cbbebdd1fca7bf.