Skip to content

Commit 064ffe7

Browse files
authored
Merge pull request #112 from crossplane/fix_unit_tests
Bump protobuf and add defensive checks to get_* helpers
2 parents d4b3506 + 685918f commit 064ffe7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

crossplane/function/resource.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ def get_condition(resource: structpb.Struct, typ: str) -> Condition:
118118
"""
119119
unknown = Condition(typ=typ, status="Unknown")
120120

121-
if "status" not in resource:
121+
if not resource or "status" not in resource:
122122
return unknown
123123

124-
if "conditions" not in resource["status"]:
124+
if not resource["status"] or "conditions" not in resource["status"]:
125125
return unknown
126126

127127
for c in resource["status"]["conditions"]:
@@ -157,9 +157,9 @@ class Credentials:
157157
def get_credentials(req: structpb.Struct, name: str) -> Credentials:
158158
"""Get the supplied credentials."""
159159
empty = Credentials(type="data", data={})
160-
if "credentials" not in req:
160+
if not req or "credentials" not in req:
161161
return empty
162-
if name not in req["credentials"]:
162+
if not req["credentials"] or name not in req["credentials"]:
163163
return empty
164164
return Credentials(
165165
type=req["credentials"][name]["type"],

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ classifiers = [
1919
dependencies = [
2020
"grpcio==1.*",
2121
"grpcio-reflection==1.*",
22-
"protobuf==5.27.2",
22+
"protobuf==5.28.1",
2323
"pydantic==2.*",
2424
"structlog==24.*",
2525
]

0 commit comments

Comments
 (0)