Merge pull request #112 from crossplane/fix_unit_tests

Bump protobuf and add defensive checks to get_* helpers
This commit is contained in:
Nic Cope 2025-01-08 11:19:46 -08:00 committed by GitHub
commit 064ffe7458
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -118,10 +118,10 @@ def get_condition(resource: structpb.Struct, typ: str) -> Condition:
""" """
unknown = Condition(typ=typ, status="Unknown") unknown = Condition(typ=typ, status="Unknown")
if "status" not in resource: if not resource or "status" not in resource:
return unknown return unknown
if "conditions" not in resource["status"]: if not resource["status"] or "conditions" not in resource["status"]:
return unknown return unknown
for c in resource["status"]["conditions"]: for c in resource["status"]["conditions"]:
@ -157,9 +157,9 @@ class Credentials:
def get_credentials(req: structpb.Struct, name: str) -> Credentials: def get_credentials(req: structpb.Struct, name: str) -> Credentials:
"""Get the supplied credentials.""" """Get the supplied credentials."""
empty = Credentials(type="data", data={}) empty = Credentials(type="data", data={})
if "credentials" not in req: if not req or "credentials" not in req:
return empty return empty
if name not in req["credentials"]: if not req["credentials"] or name not in req["credentials"]:
return empty return empty
return Credentials( return Credentials(
type=req["credentials"][name]["type"], type=req["credentials"][name]["type"],

View File

@ -19,7 +19,7 @@ classifiers = [
dependencies = [ dependencies = [
"grpcio==1.*", "grpcio==1.*",
"grpcio-reflection==1.*", "grpcio-reflection==1.*",
"protobuf==5.27.2", "protobuf==5.28.1",
"pydantic==2.*", "pydantic==2.*",
"structlog==24.*", "structlog==24.*",
] ]