Skip to content

Commit 54d6e39

Browse files
Merge branch 'main' into main
2 parents 36e5600 + 8551576 commit 54d6e39

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ jobs:
120120
path: "dist"
121121

122122
- name: Publish to PyPI
123-
uses: pypa/gh-action-pypi-publish@v1.10.3
123+
uses: pypa/gh-action-pypi-publish@v1.12.3
124124
with:
125125
# Note that this is currently being pushed to the 'crossplane' PyPI
126126
# user (not org). See @negz if you need access - PyPI requires 2FA to

crossplane/function/resource.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ def update(r: fnv1.Resource, source: dict | structpb.Struct | pydantic.BaseModel
3939
"""
4040
match source:
4141
case pydantic.BaseModel():
42-
r.resource.update(source.model_dump(exclude_defaults=True, warnings=False))
42+
data = source.model_dump(exclude_defaults=True, warnings=False)
43+
# In Pydantic, exclude_defaults=True in model_dump excludes fields
44+
# that have their value equal to the default. If a field like
45+
# apiVersion is set to its default value 's3.aws.upbound.io/v1beta2'
46+
# (and not explicitly provided during initialization), it will be
47+
# excluded from the serialized output.
48+
data['apiVersion'] = source.apiVersion
49+
data['kind'] = source.kind
50+
r.resource.update(data)
4351
case structpb.Struct():
4452
# TODO(negz): Use struct_to_dict and update to match other semantics?
4553
r.resource.MergeFrom(source)
@@ -106,10 +114,10 @@ def get_condition(resource: structpb.Struct, typ: str) -> Condition:
106114
"""
107115
unknown = Condition(typ=typ, status="Unknown")
108116

109-
if "status" not in resource:
117+
if not resource or "status" not in resource:
110118
return unknown
111119

112-
if "conditions" not in resource["status"]:
120+
if not resource["status"] or "conditions" not in resource["status"]:
113121
return unknown
114122

115123
for c in resource["status"]["conditions"]:
@@ -145,9 +153,9 @@ class Credentials:
145153
def get_credentials(req: structpb.Struct, name: str) -> Credentials:
146154
"""Get the supplied credentials."""
147155
empty = Credentials(type="data", data={})
148-
if "credentials" not in req:
156+
if not req or "credentials" not in req:
149157
return empty
150-
if name not in req["credentials"]:
158+
if not req["credentials"] or name not in req["credentials"]:
151159
return empty
152160
return Credentials(
153161
type=req["credentials"][name]["type"],

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ classifiers = [
1919
dependencies = [
2020
"grpcio==1.67.0",
2121
"grpcio-reflection==1.*",
22-
"protobuf==5.27.2",
22+
"protobuf==5.29.3",
2323
"pydantic==2.*",
2424
"structlog==24.*",
2525
]
@@ -38,13 +38,13 @@ validate-bump = false # Allow going from 0.0.0.dev0+x to 0
3838
[tool.hatch.envs.default]
3939
type = "virtual"
4040
path = ".venv-default"
41-
dependencies = ["ipython==8.28.0"]
41+
dependencies = ["ipython==8.31.0"]
4242

4343
[tool.hatch.envs.generate]
4444
type = "virtual"
4545
detached = true
4646
path = ".venv-generate"
47-
dependencies = ["grpcio-tools==1.67.0"]
47+
dependencies = ["grpcio-tools==1.69.0"]
4848

4949
[tool.hatch.envs.generate.scripts]
5050
protoc = "python -m grpc_tools.protoc --proto_path=. --python_out=. --pyi_out=. --grpc_python_out=. crossplane/function/proto/v1beta1/run_function.proto crossplane/function/proto/v1/run_function.proto"
@@ -62,7 +62,7 @@ packages = ["crossplane"]
6262

6363
# This special environment is used by hatch fmt.
6464
[tool.hatch.envs.hatch-static-analysis]
65-
dependencies = ["ruff==0.6.9"]
65+
dependencies = ["ruff==0.9.1"]
6666
config-path = "none" # Disable Hatch's default Ruff config.
6767

6868
[tool.ruff]

tests/test_resource.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ class TestCase:
9090
),
9191
want=fnv1.Resource(
9292
resource=resource.dict_to_struct(
93-
{"spec": {"forProvider": {"region": "us-west-2"}}}
93+
{
94+
"apiVersion": "s3.aws.upbound.io/v1beta2",
95+
"kind": "Bucket",
96+
"spec": {"forProvider": {"region": "us-west-2"}},
97+
}
9498
),
9599
),
96100
),

tests/testdata/models/io/upbound/aws/s3/v1beta2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,11 +759,11 @@ class Status(BaseModel):
759759

760760

761761
class Bucket(BaseModel):
762-
apiVersion: Optional[str] = None
762+
apiVersion: Optional[str] = 's3.aws.upbound.io/v1beta2'
763763
"""
764764
APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
765765
"""
766-
kind: Optional[str] = None
766+
kind: Optional[str] = 'Bucket'
767767
"""
768768
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
769769
"""

0 commit comments

Comments
 (0)