Skip to content

Commit

Permalink
Merge pull request #40 from camptocamp/fix-clean
Browse files Browse the repository at this point in the history
Realy be able to use clean without gopass
  • Loading branch information
sbrunner authored Dec 15, 2020
2 parents 7553b63 + 0917200 commit 61556e9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions c2cciutils/scripts/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,23 @@ def clean(image: str, tag: str, token: str) -> None:


def main() -> None:
username = (
os.environ["DOCKERHUB_USERNAME"]
if "DOCKERHUB_USERNAME" in os.environ
else subprocess.check_output(["gopass", "show", "gs/ci/dockerhub/username"]).decode()
)
password = (
os.environ["DOCKERHUB_PASSWORD"]
if "DOCKERHUB_PASSWORD" in os.environ
else subprocess.check_output(["gopass", "show", "gs/ci/dockerhub/password"]).decode()
)
token = requests.post(
"https://hub.docker.com/v2/users/login/",
headers={"Content-Type": "application/json"},
data=json.dumps(
{
"username": os.environ.get(
"DOCKERHUB_USERNAME",
subprocess.check_output(["gopass", "show", "gs/ci/dockerhub/username"]).decode(),
),
"password": os.environ.get(
"DOCKERHUB_PASSWORD",
subprocess.check_output(["gopass", "show", "gs/ci/dockerhub/password"]).decode(),
),
"username": username,
"password": password,
}
),
).json()["token"]
Expand Down

0 comments on commit 61556e9

Please sign in to comment.