Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions apis/cluster/identity/v1alpha1/projectv3_extractor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright 2022 Upbound Inc.
Copyright 2023 Jakob Schlagenhaufer
Copyright 2025 Yannick Schlosser
*/

package v1alpha1

import (
"github.com/crossplane/crossplane-runtime/v2/pkg/reference"
"github.com/crossplane/crossplane-runtime/v2/pkg/resource"
)

// ExtractDomainID returns the external name of a ProjectV3 only when it
// represents a domain (isDomain: true). Referencing a regular project
// yields an empty value, causing reference resolution to fail.
func ExtractDomainID() reference.ExtractValueFn {
return func(mg resource.Managed) string {
p, ok := any(mg).(*ProjectV3)
if !ok {
return ""
}
isDomain := (p.Spec.ForProvider.IsDomain != nil && *p.Spec.ForProvider.IsDomain) ||
(p.Status.AtProvider.IsDomain != nil && *p.Status.AtProvider.IsDomain)
if !isDomain {
return ""
}
return reference.ExternalName()(mg)
}
}
120 changes: 120 additions & 0 deletions apis/cluster/identity/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading