Skip to content

Commit 38b5b91

Browse files
Rename the reference module to dependency
crossplane.function.reference was easy to confuse with managed resource references - vpcIdRef, vpcIdSelector - which are what it's meant to replace. crossplane.function.dependency says what it records, and reads alongside response.add_dependency: vpc = dependency.named("vpc", VPC) with dependency.composing(req, rsp, "subnet") as c: ... Two error messages still told the reader to wrap a field in reference.ref(), which went with the marker style. They now point at c.ref() inside dependency.composing(), as does named()'s docstring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e0f7ac7 commit 38b5b91

2 files changed

Lines changed: 68 additions & 64 deletions

File tree

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
dependency, and Crossplane waits rather than letting the provider discover
2626
the problem:
2727
28-
from crossplane.function import reference
28+
from crossplane.function import dependency
2929
30-
vpc = reference.named("vpc", VPC)
30+
vpc = dependency.named("vpc", VPC)
3131
32-
with reference.composing(req, rsp, "subnet") as c:
32+
with dependency.composing(req, rsp, "subnet") as c:
3333
c.update(
3434
Subnet(
3535
spec={
@@ -131,8 +131,8 @@ def __setattr__(self, attr: str, value: typing.Any) -> None:
131131

132132
def __bool__(self) -> bool:
133133
msg = (
134-
f"{self._describe()} has no value yet. Wrap it in reference.ref() to "
135-
"assign it; read the observed resource instead to branch on it."
134+
f"{self._describe()} has no value yet. Read it with c.ref() inside "
135+
"dependency.composing(), and branch on what that returns."
136136
)
137137
raise TypeError(msg)
138138

@@ -141,7 +141,7 @@ def __iter__(self) -> typing.NoReturn:
141141
raise TypeError(msg)
142142

143143
def __str__(self) -> str:
144-
msg = f"{self._describe()} has no value yet. Wrap it in reference.ref()."
144+
msg = f"{self._describe()} has no value yet. Read it with c.ref()."
145145
raise TypeError(msg)
146146

147147
def __repr__(self) -> str:
@@ -220,8 +220,10 @@ def named(name: str, model: type[M] | None = None) -> typing.Any:
220220
Returns:
221221
A stand-in that reads like the resource itself:
222222
223-
vpc = reference.named("vpc", VPC)
224-
"vpcId": reference.ref(vpc.status.atProvider.id),
223+
vpc = dependency.named("vpc", VPC)
224+
225+
with dependency.composing(req, rsp, "subnet") as c:
226+
vpc_id = c.ref(vpc.status.atProvider.id)
225227
"""
226228
return _Field(_Source(_COMPOSED, name), (), model)
227229

@@ -559,9 +561,9 @@ def composing(
559561
A Scope whose ref and external_name return real values, and record
560562
that this resource depends on the resources they came from:
561563
562-
vpc = reference.named("vpc", VPC)
564+
vpc = dependency.named("vpc", VPC)
563565
564-
with reference.composing(req, rsp, "subnet") as c:
566+
with dependency.composing(req, rsp, "subnet") as c:
565567
c.update(Subnet(spec={"forProvider": {
566568
"region": "us-east-1",
567569
"vpcId": c.external_name(vpc),

0 commit comments

Comments
 (0)