Skip to content

Commit

Permalink
Apply pre-commit fix
Browse files Browse the repository at this point in the history
From the artifact of the previous workflow run
  • Loading branch information
geo-ghci-int[bot] committed Feb 14, 2025
1 parent f250733 commit 47e0490
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions docker/operator_.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
def _hash(spec: kopf.Spec) -> str:
secret = spec.get("secret", os.environ.get("GITHUB_WEBHOOK_SECRET"))
return hashlib.sha256(
f"{spec['repository']}:{spec['url']}:{spec['contentType']}:{secret}".encode()
f"{spec['repository']}:{spec['url']}:{spec['contentType']}:{secret}".encode(),
).hexdigest()


Expand Down Expand Up @@ -74,7 +74,7 @@ def create_webhook(spec: kopf.Spec, logger: kopf.Logger) -> dict[str, Any]:
"content_type": spec.get("contentType", "json"),
"url": spec["url"],
"secret": spec.get("secret", os.environ.get("GITHUB_WEBHOOK_SECRET")),
}
},
},
timeout=TIMEOUT,
)
Expand Down Expand Up @@ -132,7 +132,7 @@ def get_status(status: kopf.Status) -> dict[str, Any]:
@kopf.on.resume("camptocamp.com", "v4", f"githubwebhooks{ENVIRONMENT}")
@kopf.on.update("camptocamp.com", "v4", f"githubwebhooks{ENVIRONMENT}")
async def update(
meta: kopf.Meta, spec: kopf.Spec, status: kopf.Status, logger: kopf.Logger, **_: Any
meta: kopf.Meta, spec: kopf.Spec, status: kopf.Status, logger: kopf.Logger, **_: Any,
) -> Optional[dict[str, Any]]:
"""Manage the update or resume of the webhook."""
logger.info(
Expand All @@ -151,7 +151,7 @@ async def update(

@kopf.on.delete("camptocamp.com", "v4", f"githubwebhooks{ENVIRONMENT}")
async def delete(
meta: kopf.Meta, spec: kopf.Spec, status: kopf.Status, logger: kopf.Logger, **_: Any
meta: kopf.Meta, spec: kopf.Spec, status: kopf.Status, logger: kopf.Logger, **_: Any,
) -> None:
"""Manage the deletion of the webhook."""
logger.info(
Expand Down
12 changes: 6 additions & 6 deletions tests/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def install_operator(scope="session"):
{"name": "GITHUB_TOKEN", "value": os.environ["GITHUB_TOKEN"]},
{"name": "LOG_LEVEL", "value": "DEBUG"},
{"name": "ENVIRONMENT", "value": "test"},
]
],
),
"--set=image.tag=latest,crd.suffix=test,crd.shortSuffix=t",
],
Expand All @@ -48,13 +48,13 @@ def install_operator(scope="session"):
for _ in range(100):
pods = json.loads(
subprocess.run(
["kubectl", "get", "pods", "--output=json"], check=True, stdout=subprocess.PIPE
).stdout
["kubectl", "get", "pods", "--output=json"], check=True, stdout=subprocess.PIPE,
).stdout,
)
if (
len(pods["items"]) == 1
and len(
[c for c in pods["items"][0].get("status", {}).get("conditions", {}) if c["status"] != "True"]
[c for c in pods["items"][0].get("status", {}).get("conditions", {}) if c["status"] != "True"],
)
== 0
):
Expand All @@ -73,7 +73,7 @@ def install_operator(scope="session"):
AUTH_HEADER = "Bearer {}".format(
os.environ["GITHUB_TOKEN"]
if "GITHUB_TOKEN" in os.environ
else subprocess.check_output(["gopass", "gs/ci/github/token/gopass"]).strip().decode()
else subprocess.check_output(["gopass", "gs/ci/github/token/gopass"]).strip().decode(),
)


Expand Down Expand Up @@ -106,7 +106,7 @@ def test_operator(install_operator):
del install_operator

# Initialize the source and the config
subprocess.run(["kubectl", "delete", "--filename=tests/webhook.yaml"])
subprocess.run(["kubectl", "delete", "--filename=tests/webhook.yaml"], check=False)

# Clean the old webhook
webhooks = requests.get(
Expand Down

0 comments on commit 47e0490

Please sign in to comment.