Repository navigation
feat: add domainIdRef/domainIdSelector support to identity resources - #176
Conversation
|
Hello, @Avatos! Could you please review this PR when you will have time, thank you |
0febfc9 to
119a54a
Compare
|
Hello @Avatos just a reminder, please review this PR. Thanks |
|
Hey @JRaver, First of all, thanks for this contribution! I identified one potential issue with the Assuming we have these two resources: apiVersion: identity.openstack.m.crossplane.io/v1alpha1
kind: UserV3
metadata:
name: example-user
namespace: application
spec:
forProvider:
domainIdRef:
name: example-domain
namespace: infrastructureapiVersion: identity.openstack.m.crossplane.io/v1alpha1
kind: ProjectV3
metadata:
name: example-domain
namespace: application
spec:
forProvider:
isDomain: falseThe custom validator's It would be great if you were able to test this scenario on an OpenStack cluster. |
Signed-off-by: Yevhen Artemenko <eartemenko@playtika.com>
119a54a to
93d5709
Compare
|
Thank you for your comment @Avatos . I add this functionality and provide my tests on our Openstack. Please take a look one more time. Testing: cross-namespace
|
| User | Namespace | domainIdRef | Expected |
|---|---|---|---|
namespaced-user |
namespaced-object-infra |
name: namespaced-domain, namespace: namespaced-infra |
✅ Cross-NS ref to domain → resolves |
wrong-namespaced-user |
namespaced-object-infra |
name: namespaced-domain (no namespace) |
❌ Domain not found in own NS |
namespaced-user-on-project |
namespaced-object-infra |
name: namespaced-project, namespace: namespaced-infra |
❌ Target is a project, not a domain |
Results
$ kubectl get userv3.identity.openstack.m.crossplane.io -A
NAMESPACE NAME SYNCED READY EXTERNAL-NAME AGE
namespaced-object-infra namespaced-user True True bea9217d667a47d290a7a792aaae933c 2m47s
namespaced-object-infra namespaced-user-on-project False 2m46s
namespaced-object-infra wrong-namespaced-user False 2m46s
✅ namespaced-user — cross-namespace reference resolved successfully (user in namespaced-object-infra → domain in namespaced-infra).
❌ namespaced-user-on-project — initializer blocks with a clear error:
Warning CannotInitializeManagedResource 13s (x9 over 3m19s)
spec.forProvider.domainIdRef: referenced ProjectV3 "namespaced-project" is a project,
not a domain: reference a ProjectV3 created with isDomain: true
❌ wrong-namespaced-user — resolver correctly fails because namespaced-domain doesn't exist in the user's own namespace (namespaced-object-infra):
Warning CannotResolveResourceReferences 40s (x9 over 3m46s)
cannot resolve references: mg.Spec.ForProvider.DomainID: cannot get referenced resource:
ProjectV3.identity.openstack.m.crossplane.io "namespaced-domain" not found
Summary
- Cross-namespace
domainIdRef.namespaceworks correctly — validator now reads explicit namespace from the ref (mirroringAPINamespacedResolverbehavior) - Referencing a regular project (not a domain) gives a clear
CannotInitializeManagedResourceerror - Missing explicit namespace in cross-NS scenario correctly fails at resolver level (domain not found in own namespace)
|
@Avatos Please take a look one more time) and If everything is ok, please merge and create new release, thanks) |
|
@Avatos Sorry for bothering you, but any changes to this PR will be reviewed and merged, please |
Description of your changes
Add
domainIdRefanddomainIdSelectorsupport to all identity resources that have adomainIdfield:ProjectV3UserV3GroupV3RoleV3RoleAssignmentV3InheritRoleAssignmentV3In OpenStack, a domain is represented as a
ProjectV3withisDomain: true. A customExtractDomainID()extractor ensures that references resolve only when the targetProjectV3is actually a domain. Referencing a regular project returns an empty value and blocks resource creation.On top of that, an initializer-based validator provides a clear, actionable error message:
instead of the generic
referenced field was empty (referenced resource may not yet be ready).Both
domainIdRef(direct name reference) anddomainIdSelector(label-based selection) are validated.Usage example
I have:
make submodules; make reviewable testto ensure this PR is ready for review.How has this code been tested
go build ./...— compiles successfullygo test -v ./internal/initializer/domain/— 10 unit tests covering: ref to domain (pass), ref to project (error with clear message), ref to non-existent object (silent, left to resolver), already resolved value (skip), selector to domain (pass), selector to project (error), selector with no match (silent), initProvider ref validation, isDomain detected from status.atProvidermake generate— verified generated types (DomainIDRef/DomainIDSelectorfields), resolvers (ExtractDomainID()usage), deepcopy, controllers (InitializerFnswired), and CRDsdomainIdRefto domain (resolves), project withdomainIdRefto a regular project (clear error in status and events)[contribution process]: https://git.io/fj2m9