Skip to content

Commit

Permalink
Realy be able to use clean without gopass
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Dec 14, 2020
1 parent 06a5ab5 commit 0917200
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 0917200

Please sign in to comment.