Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New release #202

Closed
gbolmier opened this issue Jan 28, 2022 · 9 comments
Closed

New release #202

gbolmier opened this issue Jan 28, 2022 · 9 comments

Comments

@gbolmier
Copy link
Contributor

The last release (0.0.11) was done a year ago now. New commits have been made since, I think it would be nice to have a new release of both ORMB and the python sdk. Does someone have to bandwith for it?

@gaocegege
Copy link
Member

SGTM

@gbolmier
Copy link
Contributor Author

Seems like the ormb-publish run failed, no binaries assets where published.

@gaocegege
Copy link
Member

Yeah it is caused by the wrong go version I think. I will try to fix it.

@gbolmier
Copy link
Contributor Author

gbolmier commented Feb 1, 2022

Tested the new release, works like a charm! Thank you @gaocegege, would it be possible to also make a new release of the python sdk to pypi too?

@gaocegege
Copy link
Member

SGTM. Will do it soon.

@gbolmier
Copy link
Contributor Author

gbolmier commented Feb 4, 2022

On my side, I re-implemented the ormb.api.py module to use subprocess.run instead of subprocess.Popen so that we can propagate shell's stderr to python. I also added exceptions handling with custom exceptions. This is what it looks like for the login command:

class ORMBLoginError(Exception):
    def __init__(self, registry_name: str, username: str, stderr: str) -> None:
        msg = f"Login to {registry_name} as '{username}' failed with stderr:\n{stderr}"
        super().__init__(msg)


def login(
    hostname: str,
    username: str,
    password: str,
    registry_name: str,
) -> subprocess.CompletedProcess:
    """
    Logs in an image registry by running ORMB CLI `login` command in a subprocess.

    Args:
        hostname: Remote registry to authenticate to.
        username: Username to authenticate with.
        password: Password to authenticate with.
        registry_name: Name of the registry for error logs.

    Returns:
        The completed process.

    Raises:
        ORMBLoginError: ORMB login command process exited with a non-zero exit code.
    """
    args = [
        BIN_PATHNAME,
        "login",
        hostname,
        "--username",
        username,
        "--password-stdin",
        "--insecure",
        "False",
    ]

    try:
        return subprocess.run(
            args=args,
            capture_output=True,
            check=True,
            input=password,
            text=True,
        )
    except subprocess.CalledProcessError as e:
        raise _cli_api_exceptions.ORMBLoginError(
            registry_name=registry_name,
            username=username,
            stderr=e.stderr,
        )

If you want I could create a PR this weekend to enhance the api.py module before you make the release.

@gaocegege
Copy link
Member

If you want I could create a PR this weekend to enhance the api.py module before you make the release.

I think it works for me! Thanks for the PR!

@gaocegege
Copy link
Member

@gbolmier
Copy link
Contributor Author

gbolmier commented Feb 7, 2022

Thx @gaocegege! Tested locally 🚀

@gbolmier gbolmier closed this as completed Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants