Skip to content

Commit 2d89153

Browse files
Record a dependency when a field refers to another resource
Providers resolve cross-resource references themselves, through fields like vpcIdSelector, so Crossplane never sees the relationship and can't order anything. Writing the reference as a field value instead makes it visible: the function says where the value comes from, and the SDK records the dependency. reference.named names a composed resource, and named_required a required one. Reading a field through it records a path, and ref turns that into a marker string; external_name references the external name, which is what a selector would have resolved to. reference.resolve then replaces each marker with the observed value and records the edge. A marker is a string because that's what a generated model's own validation accepts in a string field, so it survives model_validate and resource.update untouched. Given the model, the stand-in follows the model's fields: a typo fails where it's written, and a field whose JSON name is a Python keyword (from, class) is recorded under its JSON name. It has no value, so a truth test or str() raises rather than taking the wrong branch the way an always-truthy placeholder would. A reference whose source doesn't exist yet leaves the field out, and the edge means Crossplane doesn't create the resource until it does. A resource that already exists keeps the value it has, so an apply doesn't unset it. On a Crossplane without CAPABILITY_DEPENDENCIES the edge would be ignored and the resource created without the field, so there a resource with an unresolved reference is left out instead. The runtime fails a response that still contains a marker, so forgetting to call resolve can't send one to the cluster. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8e5a0b2 commit 2d89153

3 files changed

Lines changed: 1062 additions & 2 deletions

File tree

0 commit comments

Comments
 (0)