Skip to content

Commit

Permalink
Changes log messages on execution of agent (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
shariff-6 authored Nov 20, 2024
1 parent c2fa6f3 commit e81cc01
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/consumers/kafka_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(
brokers, username, password = get_kafka_credentials()
conf["sasl.username"] = username
conf["sasl.password"] = password
conf["bootstrap.servers"] = ','.join(brokers)
conf["bootstrap.servers"] = ",".join(brokers)

self.consumer = Consumer(conf)

Expand Down
15 changes: 8 additions & 7 deletions app/invokers/webhook_invoker.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def _request(
res.text,
)
run_logger(
f"The request was successful with status code: {res.status_code}"
f"Action invocation has completed successfully with "
f"status code: {res.status_code}"
)
else:
logger.warning(
Expand All @@ -176,7 +177,7 @@ def _request(
res.text,
)
run_logger(
f"The request failed with status code: {res.status_code} "
f"Action invocation failed with status code: {res.status_code} "
f"and response: {res.text}"
)

Expand Down Expand Up @@ -280,9 +281,9 @@ def _invoke_run(
res.raise_for_status()
run_logger("Port agent finished processing the action run")

def validate_incoming_signature(self,
msg: dict,
invocation_method_name: str) -> bool:
def validate_incoming_signature(
self, msg: dict, invocation_method_name: str
) -> bool:
if "changelogDestination" in msg:
return True

Expand All @@ -298,7 +299,7 @@ def validate_incoming_signature(self,

# Remove Port's generated headers to avoid them being
# used in the signature verification
if invocation_method_name == 'GITLAB':
if invocation_method_name == "GITLAB":
del msg["headers"]
else:
del msg["headers"]["X-Port-Signature"]
Expand All @@ -320,7 +321,7 @@ def invoke(self, msg: dict, invocation_method: dict) -> None:
logger.info("WebhookInvoker - start - destination: %s", invocation_method)
run_id = msg["context"].get("runId")

invocation_method_name = invocation_method.get('type', 'WEBHOOK')
invocation_method_name = invocation_method.get("type", "WEBHOOK")
if not self.validate_incoming_signature(msg, invocation_method_name):
return

Expand Down
2 changes: 1 addition & 1 deletion app/port_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ def get_kafka_credentials() -> tuple[list[str], str, str]:
)
res.raise_for_status()
data = res.json()["credentials"]
return data['brokers'], data["username"], data["password"]
return data["brokers"], data["username"], data["password"]
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def test_invocation_method_method_override(

expected_headers["X-Port-Timestamp"] = str(time.time())
expected_headers["X-Port-Signature"] = sign_sha_256(
json.dumps(expected_body, separators=(",", ":")), "test", time.time()
json.dumps(expected_body, separators=(",", ":")), "test", str(time.time())
)

expected_query: dict[str, ANY] = {}
Expand Down

0 comments on commit e81cc01

Please sign in to comment.