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

0.3: Optional pip configuration #7

Merged
merged 1 commit into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ partifact login myrepo --profile myprofile
partifact login myrepo --role myrole
```

If you would also like to configure `global.index-url` in the `pip` config,
you can do so through the `--configure-pip` flag.

```shell
partifact login myrepo --profile myprofile --configure-pip
```

# Known issues

1. The `CodeArtifact` token seems to exceed the maximum length allowed in Windows Credential Manager, resulting
Expand Down
21 changes: 16 additions & 5 deletions partifact/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Optional

import typer
from typing_extensions import Annotated

from partifact.auth_token import get_token
from partifact.config import Configuration
Expand All @@ -9,19 +10,28 @@
app = typer.Typer()

profile_option = typer.Option(
None, help="The AWS profile to use when getting the CodeArtifact token."
"--profile",
"-p",
help="The AWS profile to use when getting the CodeArtifact token.",
)

role_option = typer.Option(
None, help="The AWS role to use when getting the CodeArtifact token."
"--role", "-r", help="The AWS role to use when getting the CodeArtifact token."
)

should_configure_pip_option = typer.Option(
"--configure-pip",
"-c",
help="Set global.index-url for pip in addition to configuring poetry.",
)


@app.command()
def login(
repository: str,
profile: Optional[str] = profile_option,
role: Optional[str] = role_option,
profile: Annotated[Optional[str], profile_option] = None,
role: Annotated[Optional[str], role_option] = None,
should_configure_pip: Annotated[bool, should_configure_pip_option] = False,
) -> None:
"""Log into CodeArtifact.

Expand All @@ -30,7 +40,8 @@ def login(
config = Configuration.load(repository, profile, role)
token = get_token(config)

configure_pip(config, token)
if should_configure_pip:
configure_pip(config, token)
configure_poetry(repository, token)


Expand Down
Loading
Loading