Skip to content

Commit

Permalink
Merge pull request #7 from Validus-Risk-Management/optional-pip-config
Browse files Browse the repository at this point in the history
0.3: Optional pip configuration
  • Loading branch information
davidsteiner authored Sep 9, 2023
2 parents bbfaa31 + 88b621d commit dbe5253
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 299 deletions.
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

0 comments on commit dbe5253

Please sign in to comment.