diff --git a/apis/authenticationflow/v1alpha1/zz_generated.resolvers.go b/apis/authenticationflow/v1alpha1/zz_generated.resolvers.go index f7572f88..2ddcf040 100644 --- a/apis/authenticationflow/v1alpha1/zz_generated.resolvers.go +++ b/apis/authenticationflow/v1alpha1/zz_generated.resolvers.go @@ -2,243 +2,291 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" + common "github.com/crossplane-contrib/provider-keycloak/config/common" + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" + + // ResolveReferences of this Bindings. + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" ) -// ResolveReferences of this Bindings. func (mg *Bindings) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.BrowserFlow), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.ForProvider.BrowserFlowRef, - Selector: mg.Spec.ForProvider.BrowserFlowSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.BrowserFlow), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.ForProvider.BrowserFlowRef, + Selector: mg.Spec.ForProvider.BrowserFlowSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.BrowserFlow") } mg.Spec.ForProvider.BrowserFlow = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.BrowserFlowRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientAuthenticationFlow), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.ForProvider.ClientAuthenticationFlowRef, - Selector: mg.Spec.ForProvider.ClientAuthenticationFlowSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientAuthenticationFlow), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.ForProvider.ClientAuthenticationFlowRef, + Selector: mg.Spec.ForProvider.ClientAuthenticationFlowSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientAuthenticationFlow") } mg.Spec.ForProvider.ClientAuthenticationFlow = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientAuthenticationFlowRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.DirectGrantFlow), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.ForProvider.DirectGrantFlowRef, - Selector: mg.Spec.ForProvider.DirectGrantFlowSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.DirectGrantFlow), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.ForProvider.DirectGrantFlowRef, + Selector: mg.Spec.ForProvider.DirectGrantFlowSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.DirectGrantFlow") } mg.Spec.ForProvider.DirectGrantFlow = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.DirectGrantFlowRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.DockerAuthenticationFlow), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.ForProvider.DockerAuthenticationFlowRef, - Selector: mg.Spec.ForProvider.DockerAuthenticationFlowSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.DockerAuthenticationFlow), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.ForProvider.DockerAuthenticationFlowRef, + Selector: mg.Spec.ForProvider.DockerAuthenticationFlowSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.DockerAuthenticationFlow") } mg.Spec.ForProvider.DockerAuthenticationFlow = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.DockerAuthenticationFlowRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RegistrationFlow), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.ForProvider.RegistrationFlowRef, - Selector: mg.Spec.ForProvider.RegistrationFlowSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RegistrationFlow), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.ForProvider.RegistrationFlowRef, + Selector: mg.Spec.ForProvider.RegistrationFlowSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RegistrationFlow") } mg.Spec.ForProvider.RegistrationFlow = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RegistrationFlowRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ResetCredentialsFlow), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.ForProvider.ResetCredentialsFlowRef, - Selector: mg.Spec.ForProvider.ResetCredentialsFlowSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ResetCredentialsFlow), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.ForProvider.ResetCredentialsFlowRef, + Selector: mg.Spec.ForProvider.ResetCredentialsFlowSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ResetCredentialsFlow") } mg.Spec.ForProvider.ResetCredentialsFlow = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ResetCredentialsFlowRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.BrowserFlow), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.InitProvider.BrowserFlowRef, - Selector: mg.Spec.InitProvider.BrowserFlowSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.BrowserFlow), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.InitProvider.BrowserFlowRef, + Selector: mg.Spec.InitProvider.BrowserFlowSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.BrowserFlow") } mg.Spec.InitProvider.BrowserFlow = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.BrowserFlowRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientAuthenticationFlow), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.InitProvider.ClientAuthenticationFlowRef, - Selector: mg.Spec.InitProvider.ClientAuthenticationFlowSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientAuthenticationFlow), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.InitProvider.ClientAuthenticationFlowRef, + Selector: mg.Spec.InitProvider.ClientAuthenticationFlowSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientAuthenticationFlow") } mg.Spec.InitProvider.ClientAuthenticationFlow = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientAuthenticationFlowRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.DirectGrantFlow), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.InitProvider.DirectGrantFlowRef, - Selector: mg.Spec.InitProvider.DirectGrantFlowSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.DirectGrantFlow), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.InitProvider.DirectGrantFlowRef, + Selector: mg.Spec.InitProvider.DirectGrantFlowSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.DirectGrantFlow") } mg.Spec.InitProvider.DirectGrantFlow = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.DirectGrantFlowRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.DockerAuthenticationFlow), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.InitProvider.DockerAuthenticationFlowRef, - Selector: mg.Spec.InitProvider.DockerAuthenticationFlowSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.DockerAuthenticationFlow), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.InitProvider.DockerAuthenticationFlowRef, + Selector: mg.Spec.InitProvider.DockerAuthenticationFlowSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.DockerAuthenticationFlow") } mg.Spec.InitProvider.DockerAuthenticationFlow = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.DockerAuthenticationFlowRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } mg.Spec.InitProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RegistrationFlow), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.InitProvider.RegistrationFlowRef, - Selector: mg.Spec.InitProvider.RegistrationFlowSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RegistrationFlow), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.InitProvider.RegistrationFlowRef, + Selector: mg.Spec.InitProvider.RegistrationFlowSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RegistrationFlow") } mg.Spec.InitProvider.RegistrationFlow = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.RegistrationFlowRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ResetCredentialsFlow), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.InitProvider.ResetCredentialsFlowRef, - Selector: mg.Spec.InitProvider.ResetCredentialsFlowSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ResetCredentialsFlow), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.InitProvider.ResetCredentialsFlowRef, + Selector: mg.Spec.InitProvider.ResetCredentialsFlowSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ResetCredentialsFlow") } @@ -250,69 +298,83 @@ func (mg *Bindings) ResolveReferences(ctx context.Context, c client.Reader) erro // ResolveReferences of this Execution. func (mg *Execution) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ParentFlowAlias), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.ForProvider.ParentFlowAliasRef, - Selector: mg.Spec.ForProvider.ParentFlowAliasSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ParentFlowAlias), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.ForProvider.ParentFlowAliasRef, + Selector: mg.Spec.ForProvider.ParentFlowAliasSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ParentFlowAlias") } mg.Spec.ForProvider.ParentFlowAlias = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ParentFlowAliasRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ParentFlowAlias), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.InitProvider.ParentFlowAliasRef, - Selector: mg.Spec.InitProvider.ParentFlowAliasSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ParentFlowAlias), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.InitProvider.ParentFlowAliasRef, + Selector: mg.Spec.InitProvider.ParentFlowAliasSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ParentFlowAlias") } mg.Spec.InitProvider.ParentFlowAlias = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ParentFlowAliasRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -324,69 +386,83 @@ func (mg *Execution) ResolveReferences(ctx context.Context, c client.Reader) err // ResolveReferences of this ExecutionConfig. func (mg *ExecutionConfig) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ExecutionID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.ExecutionIDRef, - Selector: mg.Spec.ForProvider.ExecutionIDSelector, - To: reference.To{ - List: &ExecutionList{}, - Managed: &Execution{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Execution", "ExecutionList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ExecutionID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.ExecutionIDRef, + Selector: mg.Spec.ForProvider.ExecutionIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ExecutionID") } mg.Spec.ForProvider.ExecutionID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ExecutionIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ExecutionID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.ExecutionIDRef, - Selector: mg.Spec.InitProvider.ExecutionIDSelector, - To: reference.To{ - List: &ExecutionList{}, - Managed: &Execution{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Execution", "ExecutionList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ExecutionID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.ExecutionIDRef, + Selector: mg.Spec.InitProvider.ExecutionIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ExecutionID") } mg.Spec.InitProvider.ExecutionID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ExecutionIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -398,37 +474,45 @@ func (mg *ExecutionConfig) ResolveReferences(ctx context.Context, c client.Reade // ResolveReferences of this Flow. func (mg *Flow) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -440,69 +524,83 @@ func (mg *Flow) ResolveReferences(ctx context.Context, c client.Reader) error { // ResolveReferences of this Subflow. func (mg *Subflow) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ParentFlowAlias), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.ForProvider.ParentFlowAliasRef, - Selector: mg.Spec.ForProvider.ParentFlowAliasSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ParentFlowAlias), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.ForProvider.ParentFlowAliasRef, + Selector: mg.Spec.ForProvider.ParentFlowAliasSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ParentFlowAlias") } mg.Spec.ForProvider.ParentFlowAlias = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ParentFlowAliasRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ParentFlowAlias), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.InitProvider.ParentFlowAliasRef, - Selector: mg.Spec.InitProvider.ParentFlowAliasSelector, - To: reference.To{ - List: &FlowList{}, - Managed: &Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ParentFlowAlias), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.InitProvider.ParentFlowAliasRef, + Selector: mg.Spec.InitProvider.ParentFlowAliasSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ParentFlowAlias") } mg.Spec.InitProvider.ParentFlowAlias = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ParentFlowAliasRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } diff --git a/apis/client/v1alpha1/zz_generated.resolvers.go b/apis/client/v1alpha1/zz_generated.resolvers.go index 0d541073..1026ac10 100644 --- a/apis/client/v1alpha1/zz_generated.resolvers.go +++ b/apis/client/v1alpha1/zz_generated.resolvers.go @@ -2,117 +2,138 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/openidclient/v1alpha1" - v1alpha11 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" - v1alpha12 "github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1" + common "github.com/crossplane-contrib/provider-keycloak/config/common" + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" ) -// ResolveReferences of this ProtocolMapper. -func (mg *ProtocolMapper) ResolveReferences(ctx context.Context, c client.Reader) error { +func (mg *ProtocolMapper) ResolveReferences( // ResolveReferences of this ProtocolMapper. + ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.ForProvider.ClientIDRef, - Selector: mg.Spec.ForProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.ForProvider.ClientIDRef, + Selector: mg.Spec.ForProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientID") } mg.Spec.ForProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "ClientScope", "ClientScopeList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientScopeID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.ClientScopeIDRef, - Selector: mg.Spec.ForProvider.ClientScopeIDSelector, - To: reference.To{ - List: &v1alpha1.ClientScopeList{}, - Managed: &v1alpha1.ClientScope{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientScopeID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.ClientScopeIDRef, + Selector: mg.Spec.ForProvider.ClientScopeIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientScopeID") } mg.Spec.ForProvider.ClientScopeID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientScopeIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.InitProvider.ClientIDRef, - Selector: mg.Spec.InitProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.InitProvider.ClientIDRef, + Selector: mg.Spec.InitProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientID") } mg.Spec.InitProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "ClientScope", "ClientScopeList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientScopeID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.ClientScopeIDRef, - Selector: mg.Spec.InitProvider.ClientScopeIDSelector, - To: reference.To{ - List: &v1alpha1.ClientScopeList{}, - Managed: &v1alpha1.ClientScope{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientScopeID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.ClientScopeIDRef, + Selector: mg.Spec.InitProvider.ClientScopeIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientScopeID") } mg.Spec.InitProvider.ClientScopeID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientScopeIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -124,101 +145,121 @@ func (mg *ProtocolMapper) ResolveReferences(ctx context.Context, c client.Reader // ResolveReferences of this RoleMapper. func (mg *RoleMapper) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.ForProvider.ClientIDRef, - Selector: mg.Spec.ForProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.ForProvider.ClientIDRef, + Selector: mg.Spec.ForProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientID") } mg.Spec.ForProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RoleID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RoleIDRef, - Selector: mg.Spec.ForProvider.RoleIDSelector, - To: reference.To{ - List: &v1alpha12.RoleList{}, - Managed: &v1alpha12.Role{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RoleID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RoleIDRef, + Selector: mg.Spec.ForProvider.RoleIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RoleID") } mg.Spec.ForProvider.RoleID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RoleIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.InitProvider.ClientIDRef, - Selector: mg.Spec.InitProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.InitProvider.ClientIDRef, + Selector: mg.Spec.InitProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientID") } mg.Spec.InitProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } mg.Spec.InitProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RoleID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RoleIDRef, - Selector: mg.Spec.InitProvider.RoleIDSelector, - To: reference.To{ - List: &v1alpha12.RoleList{}, - Managed: &v1alpha12.Role{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RoleID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RoleIDRef, + Selector: mg.Spec.InitProvider.RoleIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RoleID") } diff --git a/apis/defaults/v1alpha1/zz_generated.resolvers.go b/apis/defaults/v1alpha1/zz_generated.resolvers.go index 6badcf93..5b05f968 100644 --- a/apis/defaults/v1alpha1/zz_generated.resolvers.go +++ b/apis/defaults/v1alpha1/zz_generated.resolvers.go @@ -2,86 +2,102 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1" - v1alpha11 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" - v1alpha12 "github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1" + + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" resource "github.com/crossplane/upjet/pkg/resource" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" + + // ResolveReferences of this DefaultGroups. + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" ) -// ResolveReferences of this DefaultGroups. func (mg *DefaultGroups) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var mrsp reference.MultiResolutionResponse var err error - - mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ - CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.GroupIds), - Extract: reference.ExternalName(), - References: mg.Spec.ForProvider.GroupIdsRefs, - Selector: mg.Spec.ForProvider.GroupIdsSelector, - To: reference.To{ - List: &v1alpha1.GroupList{}, - Managed: &v1alpha1.Group{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("group.keycloak.crossplane.io", "v1alpha1", "Group", "GroupList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.GroupIds), + Extract: reference.ExternalName(), + References: mg.Spec.ForProvider.GroupIdsRefs, + Selector: mg.Spec.ForProvider.GroupIdsSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.GroupIds") } mg.Spec.ForProvider.GroupIds = reference.ToPtrValues(mrsp.ResolvedValues) mg.Spec.ForProvider.GroupIdsRefs = mrsp.ResolvedReferences - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ - CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.GroupIds), - Extract: reference.ExternalName(), - References: mg.Spec.InitProvider.GroupIdsRefs, - Selector: mg.Spec.InitProvider.GroupIdsSelector, - To: reference.To{ - List: &v1alpha1.GroupList{}, - Managed: &v1alpha1.Group{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("group.keycloak.crossplane.io", "v1alpha1", "Group", "GroupList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.GroupIds), + Extract: reference.ExternalName(), + References: mg.Spec.InitProvider.GroupIdsRefs, + Selector: mg.Spec.InitProvider.GroupIdsSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.GroupIds") } mg.Spec.InitProvider.GroupIds = reference.ToPtrValues(mrsp.ResolvedValues) mg.Spec.InitProvider.GroupIdsRefs = mrsp.ResolvedReferences - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -93,70 +109,84 @@ func (mg *DefaultGroups) ResolveReferences(ctx context.Context, c client.Reader) // ResolveReferences of this Roles. func (mg *Roles) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var mrsp reference.MultiResolutionResponse var err error - - mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ - CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.DefaultRoles), - Extract: resource.ExtractParamPath("name", false), - References: mg.Spec.ForProvider.DefaultRolesRefs, - Selector: mg.Spec.ForProvider.DefaultRolesSelector, - To: reference.To{ - List: &v1alpha12.RoleList{}, - Managed: &v1alpha12.Role{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.DefaultRoles), + Extract: resource.ExtractParamPath("name", false), + References: mg.Spec.ForProvider.DefaultRolesRefs, + Selector: mg.Spec.ForProvider.DefaultRolesSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.DefaultRoles") } mg.Spec.ForProvider.DefaultRoles = reference.ToPtrValues(mrsp.ResolvedValues) mg.Spec.ForProvider.DefaultRolesRefs = mrsp.ResolvedReferences - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ - CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.DefaultRoles), - Extract: resource.ExtractParamPath("name", false), - References: mg.Spec.InitProvider.DefaultRolesRefs, - Selector: mg.Spec.InitProvider.DefaultRolesSelector, - To: reference.To{ - List: &v1alpha12.RoleList{}, - Managed: &v1alpha12.Role{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.DefaultRoles), + Extract: resource.ExtractParamPath("name", false), + References: mg.Spec.InitProvider.DefaultRolesRefs, + Selector: mg.Spec.InitProvider.DefaultRolesSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.DefaultRoles") } mg.Spec.InitProvider.DefaultRoles = reference.ToPtrValues(mrsp.ResolvedValues) mg.Spec.InitProvider.DefaultRolesRefs = mrsp.ResolvedReferences - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } diff --git a/apis/generate.go b/apis/generate.go index 67de6a78..7d65b64c 100644 --- a/apis/generate.go +++ b/apis/generate.go @@ -30,6 +30,10 @@ Copyright 2021 Upbound Inc. // Generate crossplane-runtime methodsets (resource.Claim, etc) //go:generate go run -tags generate github.com/crossplane/crossplane-tools/cmd/angryjet generate-methodsets --header-file=../hack/boilerplate.go.txt ./... +// Run upjet's transformer for the generated resolvers to get rid of the cross +// API-group imports and to prevent import cycles +//go:generate go run github.com/crossplane/upjet/cmd/resolver -g keycloak.crossplane.io -a github.com/crossplane-contrib/provider-keycloak/internal/apis -s + package apis import ( diff --git a/apis/group/v1alpha1/zz_generated.resolvers.go b/apis/group/v1alpha1/zz_generated.resolvers.go index 3d606c25..1972f52d 100644 --- a/apis/group/v1alpha1/zz_generated.resolvers.go +++ b/apis/group/v1alpha1/zz_generated.resolvers.go @@ -2,84 +2,101 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" - v1alpha11 "github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1" + common "github.com/crossplane-contrib/provider-keycloak/config/common" + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" + + // ResolveReferences of this Group. + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" ) -// ResolveReferences of this Group. func (mg *Group) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ParentID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.ParentIDRef, - Selector: mg.Spec.ForProvider.ParentIDSelector, - To: reference.To{ - List: &GroupList{}, - Managed: &Group{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("group.keycloak.crossplane.io", "v1alpha1", "Group", "GroupList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ParentID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.ParentIDRef, + Selector: mg.Spec.ForProvider.ParentIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ParentID") } mg.Spec.ForProvider.ParentID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ParentIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ParentID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.ParentIDRef, - Selector: mg.Spec.InitProvider.ParentIDSelector, - To: reference.To{ - List: &GroupList{}, - Managed: &Group{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("group.keycloak.crossplane.io", "v1alpha1", "Group", "GroupList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ParentID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.ParentIDRef, + Selector: mg.Spec.InitProvider.ParentIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ParentID") } mg.Spec.InitProvider.ParentID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ParentIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -91,69 +108,83 @@ func (mg *Group) ResolveReferences(ctx context.Context, c client.Reader) error { // ResolveReferences of this Memberships. func (mg *Memberships) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.GroupID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.GroupIDRef, - Selector: mg.Spec.ForProvider.GroupIDSelector, - To: reference.To{ - List: &GroupList{}, - Managed: &Group{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("group.keycloak.crossplane.io", "v1alpha1", "Group", "GroupList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.GroupID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.GroupIDRef, + Selector: mg.Spec.ForProvider.GroupIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.GroupID") } mg.Spec.ForProvider.GroupID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.GroupIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.GroupID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.GroupIDRef, - Selector: mg.Spec.InitProvider.GroupIDSelector, - To: reference.To{ - List: &GroupList{}, - Managed: &Group{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("group.keycloak.crossplane.io", "v1alpha1", "Group", "GroupList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.GroupID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.GroupIDRef, + Selector: mg.Spec.InitProvider.GroupIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.GroupID") } mg.Spec.InitProvider.GroupID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.GroupIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -165,69 +196,83 @@ func (mg *Memberships) ResolveReferences(ctx context.Context, c client.Reader) e // ResolveReferences of this Permissions. func (mg *Permissions) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.GroupID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.GroupIDRef, - Selector: mg.Spec.ForProvider.GroupIDSelector, - To: reference.To{ - List: &GroupList{}, - Managed: &Group{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("group.keycloak.crossplane.io", "v1alpha1", "Group", "GroupList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.GroupID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.GroupIDRef, + Selector: mg.Spec.ForProvider.GroupIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.GroupID") } mg.Spec.ForProvider.GroupID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.GroupIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.GroupID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.GroupIDRef, - Selector: mg.Spec.InitProvider.GroupIDSelector, - To: reference.To{ - List: &GroupList{}, - Managed: &Group{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("group.keycloak.crossplane.io", "v1alpha1", "Group", "GroupList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.GroupID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.GroupIDRef, + Selector: mg.Spec.InitProvider.GroupIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.GroupID") } mg.Spec.InitProvider.GroupID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.GroupIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -239,102 +284,122 @@ func (mg *Permissions) ResolveReferences(ctx context.Context, c client.Reader) e // ResolveReferences of this Roles. func (mg *Roles) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var mrsp reference.MultiResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.GroupID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.GroupIDRef, - Selector: mg.Spec.ForProvider.GroupIDSelector, - To: reference.To{ - List: &GroupList{}, - Managed: &Group{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("group.keycloak.crossplane.io", "v1alpha1", "Group", "GroupList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.GroupID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.GroupIDRef, + Selector: mg.Spec.ForProvider.GroupIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.GroupID") } mg.Spec.ForProvider.GroupID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.GroupIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ - CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.RoleIds), - Extract: common.UUIDExtractor(), - References: mg.Spec.ForProvider.RoleIdsRefs, - Selector: mg.Spec.ForProvider.RoleIdsSelector, - To: reference.To{ - List: &v1alpha11.RoleList{}, - Managed: &v1alpha11.Role{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.RoleIds), + Extract: common.UUIDExtractor(), + References: mg.Spec.ForProvider.RoleIdsRefs, + Selector: mg.Spec.ForProvider.RoleIdsSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RoleIds") } mg.Spec.ForProvider.RoleIds = reference.ToPtrValues(mrsp.ResolvedValues) mg.Spec.ForProvider.RoleIdsRefs = mrsp.ResolvedReferences - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.GroupID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.GroupIDRef, - Selector: mg.Spec.InitProvider.GroupIDSelector, - To: reference.To{ - List: &GroupList{}, - Managed: &Group{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("group.keycloak.crossplane.io", "v1alpha1", "Group", "GroupList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.GroupID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.GroupIDRef, + Selector: mg.Spec.InitProvider.GroupIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.GroupID") } mg.Spec.InitProvider.GroupID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.GroupIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } mg.Spec.InitProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.RealmIDRef = rsp.ResolvedReference - - mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ - CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.RoleIds), - Extract: common.UUIDExtractor(), - References: mg.Spec.InitProvider.RoleIdsRefs, - Selector: mg.Spec.InitProvider.RoleIdsSelector, - To: reference.To{ - List: &v1alpha11.RoleList{}, - Managed: &v1alpha11.Role{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.RoleIds), + Extract: common.UUIDExtractor(), + References: mg.Spec.InitProvider.RoleIdsRefs, + Selector: mg.Spec.InitProvider.RoleIdsSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RoleIds") } diff --git a/apis/group/v1alpha1/zz_group_types.go b/apis/group/v1alpha1/zz_group_types.go index 7f9ca340..9b80f76a 100755 --- a/apis/group/v1alpha1/zz_group_types.go +++ b/apis/group/v1alpha1/zz_group_types.go @@ -23,14 +23,14 @@ type GroupInitParameters struct { Name *string `json:"name,omitempty" tf:"name,omitempty"` // The ID of this group's parent. If omitted, this group will be defined at the root level. - // +crossplane:generate:reference:type=Group + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1.Group ParentID *string `json:"parentId,omitempty" tf:"parent_id,omitempty"` - // Reference to a Group to populate parentId. + // Reference to a Group in group to populate parentId. // +kubebuilder:validation:Optional ParentIDRef *v1.Reference `json:"parentIdRef,omitempty" tf:"-"` - // Selector for a Group to populate parentId. + // Selector for a Group in group to populate parentId. // +kubebuilder:validation:Optional ParentIDSelector *v1.Selector `json:"parentIdSelector,omitempty" tf:"-"` @@ -80,15 +80,15 @@ type GroupParameters struct { Name *string `json:"name,omitempty" tf:"name,omitempty"` // The ID of this group's parent. If omitted, this group will be defined at the root level. - // +crossplane:generate:reference:type=Group + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1.Group // +kubebuilder:validation:Optional ParentID *string `json:"parentId,omitempty" tf:"parent_id,omitempty"` - // Reference to a Group to populate parentId. + // Reference to a Group in group to populate parentId. // +kubebuilder:validation:Optional ParentIDRef *v1.Reference `json:"parentIdRef,omitempty" tf:"-"` - // Selector for a Group to populate parentId. + // Selector for a Group in group to populate parentId. // +kubebuilder:validation:Optional ParentIDSelector *v1.Selector `json:"parentIdSelector,omitempty" tf:"-"` diff --git a/apis/group/v1alpha1/zz_memberships_types.go b/apis/group/v1alpha1/zz_memberships_types.go index ba01f32b..8af21e40 100755 --- a/apis/group/v1alpha1/zz_memberships_types.go +++ b/apis/group/v1alpha1/zz_memberships_types.go @@ -16,14 +16,14 @@ import ( type MembershipsInitParameters struct { // The ID of the group this resource should manage memberships for. - // +crossplane:generate:reference:type=Group + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1.Group GroupID *string `json:"groupId,omitempty" tf:"group_id,omitempty"` - // Reference to a Group to populate groupId. + // Reference to a Group in group to populate groupId. // +kubebuilder:validation:Optional GroupIDRef *v1.Reference `json:"groupIdRef,omitempty" tf:"-"` - // Selector for a Group to populate groupId. + // Selector for a Group in group to populate groupId. // +kubebuilder:validation:Optional GroupIDSelector *v1.Selector `json:"groupIdSelector,omitempty" tf:"-"` @@ -62,15 +62,15 @@ type MembershipsObservation struct { type MembershipsParameters struct { // The ID of the group this resource should manage memberships for. - // +crossplane:generate:reference:type=Group + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1.Group // +kubebuilder:validation:Optional GroupID *string `json:"groupId,omitempty" tf:"group_id,omitempty"` - // Reference to a Group to populate groupId. + // Reference to a Group in group to populate groupId. // +kubebuilder:validation:Optional GroupIDRef *v1.Reference `json:"groupIdRef,omitempty" tf:"-"` - // Selector for a Group to populate groupId. + // Selector for a Group in group to populate groupId. // +kubebuilder:validation:Optional GroupIDSelector *v1.Selector `json:"groupIdSelector,omitempty" tf:"-"` diff --git a/apis/group/v1alpha1/zz_permissions_types.go b/apis/group/v1alpha1/zz_permissions_types.go index 907b6283..9aa635d2 100755 --- a/apis/group/v1alpha1/zz_permissions_types.go +++ b/apis/group/v1alpha1/zz_permissions_types.go @@ -142,14 +142,14 @@ type ManageScopeParameters struct { type PermissionsInitParameters struct { // The id of the group. - // +crossplane:generate:reference:type=Group + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1.Group GroupID *string `json:"groupId,omitempty" tf:"group_id,omitempty"` - // Reference to a Group to populate groupId. + // Reference to a Group in group to populate groupId. // +kubebuilder:validation:Optional GroupIDRef *v1.Reference `json:"groupIdRef,omitempty" tf:"-"` - // Selector for a Group to populate groupId. + // Selector for a Group in group to populate groupId. // +kubebuilder:validation:Optional GroupIDSelector *v1.Selector `json:"groupIdSelector,omitempty" tf:"-"` @@ -217,15 +217,15 @@ type PermissionsObservation struct { type PermissionsParameters struct { // The id of the group. - // +crossplane:generate:reference:type=Group + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1.Group // +kubebuilder:validation:Optional GroupID *string `json:"groupId,omitempty" tf:"group_id,omitempty"` - // Reference to a Group to populate groupId. + // Reference to a Group in group to populate groupId. // +kubebuilder:validation:Optional GroupIDRef *v1.Reference `json:"groupIdRef,omitempty" tf:"-"` - // Selector for a Group to populate groupId. + // Selector for a Group in group to populate groupId. // +kubebuilder:validation:Optional GroupIDSelector *v1.Selector `json:"groupIdSelector,omitempty" tf:"-"` diff --git a/apis/group/v1alpha1/zz_roles_types.go b/apis/group/v1alpha1/zz_roles_types.go index a448882a..7584e39c 100755 --- a/apis/group/v1alpha1/zz_roles_types.go +++ b/apis/group/v1alpha1/zz_roles_types.go @@ -19,14 +19,14 @@ type RolesInitParameters struct { Exhaustive *bool `json:"exhaustive,omitempty" tf:"exhaustive,omitempty"` // The ID of the group this resource should manage roles for. - // +crossplane:generate:reference:type=Group + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1.Group GroupID *string `json:"groupId,omitempty" tf:"group_id,omitempty"` - // Reference to a Group to populate groupId. + // Reference to a Group in group to populate groupId. // +kubebuilder:validation:Optional GroupIDRef *v1.Reference `json:"groupIdRef,omitempty" tf:"-"` - // Selector for a Group to populate groupId. + // Selector for a Group in group to populate groupId. // +kubebuilder:validation:Optional GroupIDSelector *v1.Selector `json:"groupIdSelector,omitempty" tf:"-"` @@ -82,15 +82,15 @@ type RolesParameters struct { Exhaustive *bool `json:"exhaustive,omitempty" tf:"exhaustive,omitempty"` // The ID of the group this resource should manage roles for. - // +crossplane:generate:reference:type=Group + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1.Group // +kubebuilder:validation:Optional GroupID *string `json:"groupId,omitempty" tf:"group_id,omitempty"` - // Reference to a Group to populate groupId. + // Reference to a Group in group to populate groupId. // +kubebuilder:validation:Optional GroupIDRef *v1.Reference `json:"groupIdRef,omitempty" tf:"-"` - // Selector for a Group to populate groupId. + // Selector for a Group in group to populate groupId. // +kubebuilder:validation:Optional GroupIDSelector *v1.Selector `json:"groupIdSelector,omitempty" tf:"-"` diff --git a/apis/identityprovider/v1alpha1/zz_generated.resolvers.go b/apis/identityprovider/v1alpha1/zz_generated.resolvers.go index 6d165f20..9c7fb07f 100644 --- a/apis/identityprovider/v1alpha1/zz_generated.resolvers.go +++ b/apis/identityprovider/v1alpha1/zz_generated.resolvers.go @@ -2,50 +2,61 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" + + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" ) -// ResolveReferences of this IdentityProviderMapper. -func (mg *IdentityProviderMapper) ResolveReferences(ctx context.Context, c client.Reader) error { +func (mg *IdentityProviderMapper) ResolveReferences( // ResolveReferences of this IdentityProviderMapper. + ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Realm), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmRef, - Selector: mg.Spec.ForProvider.RealmSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Realm), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmRef, + Selector: mg.Spec.ForProvider.RealmSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.Realm") } mg.Spec.ForProvider.Realm = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.Realm), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmRef, - Selector: mg.Spec.InitProvider.RealmSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.Realm), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmRef, + Selector: mg.Spec.InitProvider.RealmSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.Realm") } diff --git a/apis/ldap/v1alpha1/zz_generated.resolvers.go b/apis/ldap/v1alpha1/zz_generated.resolvers.go index ab4c613c..a1c3348c 100644 --- a/apis/ldap/v1alpha1/zz_generated.resolvers.go +++ b/apis/ldap/v1alpha1/zz_generated.resolvers.go @@ -2,87 +2,102 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha11 "github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1" - v1alpha13 "github.com/crossplane-contrib/provider-keycloak/apis/openidclient/v1alpha1" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" - v1alpha12 "github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1" + common "github.com/crossplane-contrib/provider-keycloak/config/common" + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" resource "github.com/crossplane/upjet/pkg/resource" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" + + // ResolveReferences of this CustomMapper. + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" ) -// ResolveReferences of this CustomMapper. func (mg *CustomMapper) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, - Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, + Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.LdapUserFederationID") } mg.Spec.ForProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, - Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, + Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.LdapUserFederationID") } mg.Spec.InitProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -94,69 +109,83 @@ func (mg *CustomMapper) ResolveReferences(ctx context.Context, c client.Reader) // ResolveReferences of this FullNameMapper. func (mg *FullNameMapper) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, - Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, + Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.LdapUserFederationID") } mg.Spec.ForProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, - Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, + Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.LdapUserFederationID") } mg.Spec.InitProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -168,69 +197,83 @@ func (mg *FullNameMapper) ResolveReferences(ctx context.Context, c client.Reader // ResolveReferences of this GroupMapper. func (mg *GroupMapper) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, - Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, + Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.LdapUserFederationID") } mg.Spec.ForProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, - Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, + Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.LdapUserFederationID") } mg.Spec.InitProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -242,69 +285,83 @@ func (mg *GroupMapper) ResolveReferences(ctx context.Context, c client.Reader) e // ResolveReferences of this HardcodedAttributeMapper. func (mg *HardcodedAttributeMapper) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, - Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, + Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.LdapUserFederationID") } mg.Spec.ForProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, - Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, + Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.LdapUserFederationID") } mg.Spec.InitProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -316,101 +373,121 @@ func (mg *HardcodedAttributeMapper) ResolveReferences(ctx context.Context, c cli // ResolveReferences of this HardcodedGroupMapper. func (mg *HardcodedGroupMapper) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Group), - Extract: resource.ExtractParamPath("name", false), - Reference: mg.Spec.ForProvider.GroupRef, - Selector: mg.Spec.ForProvider.GroupSelector, - To: reference.To{ - List: &v1alpha11.GroupList{}, - Managed: &v1alpha11.Group{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("group.keycloak.crossplane.io", "v1alpha1", "Group", "GroupList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Group), + Extract: resource.ExtractParamPath("name", false), + Reference: mg.Spec.ForProvider.GroupRef, + Selector: mg.Spec.ForProvider.GroupSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.Group") } mg.Spec.ForProvider.Group = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.GroupRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, - Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, + Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.LdapUserFederationID") } mg.Spec.ForProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.Group), - Extract: resource.ExtractParamPath("name", false), - Reference: mg.Spec.InitProvider.GroupRef, - Selector: mg.Spec.InitProvider.GroupSelector, - To: reference.To{ - List: &v1alpha11.GroupList{}, - Managed: &v1alpha11.Group{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("group.keycloak.crossplane.io", "v1alpha1", "Group", "GroupList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.Group), + Extract: resource.ExtractParamPath("name", false), + Reference: mg.Spec.InitProvider.GroupRef, + Selector: mg.Spec.InitProvider.GroupSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.Group") } mg.Spec.InitProvider.Group = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.GroupRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, - Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, + Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.LdapUserFederationID") } mg.Spec.InitProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -422,101 +499,121 @@ func (mg *HardcodedGroupMapper) ResolveReferences(ctx context.Context, c client. // ResolveReferences of this HardcodedRoleMapper. func (mg *HardcodedRoleMapper) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, - Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, + Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.LdapUserFederationID") } mg.Spec.ForProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Role), - Extract: resource.ExtractParamPath("name", false), - Reference: mg.Spec.ForProvider.RoleRef, - Selector: mg.Spec.ForProvider.RoleSelector, - To: reference.To{ - List: &v1alpha12.RoleList{}, - Managed: &v1alpha12.Role{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Role), + Extract: resource.ExtractParamPath("name", false), + Reference: mg.Spec.ForProvider.RoleRef, + Selector: mg.Spec.ForProvider.RoleSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.Role") } mg.Spec.ForProvider.Role = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RoleRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, - Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, + Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.LdapUserFederationID") } mg.Spec.InitProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } mg.Spec.InitProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.Role), - Extract: resource.ExtractParamPath("name", false), - Reference: mg.Spec.InitProvider.RoleRef, - Selector: mg.Spec.InitProvider.RoleSelector, - To: reference.To{ - List: &v1alpha12.RoleList{}, - Managed: &v1alpha12.Role{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.Role), + Extract: resource.ExtractParamPath("name", false), + Reference: mg.Spec.InitProvider.RoleRef, + Selector: mg.Spec.InitProvider.RoleSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.Role") } @@ -528,69 +625,83 @@ func (mg *HardcodedRoleMapper) ResolveReferences(ctx context.Context, c client.R // ResolveReferences of this MsadLdsUserAccountControlMapper. func (mg *MsadLdsUserAccountControlMapper) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, - Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, + Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.LdapUserFederationID") } mg.Spec.ForProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, - Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, + Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.LdapUserFederationID") } mg.Spec.InitProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -602,69 +713,83 @@ func (mg *MsadLdsUserAccountControlMapper) ResolveReferences(ctx context.Context // ResolveReferences of this MsadUserAccountControlMapper. func (mg *MsadUserAccountControlMapper) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, - Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, + Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.LdapUserFederationID") } mg.Spec.ForProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, - Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, + Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.LdapUserFederationID") } mg.Spec.InitProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -676,101 +801,121 @@ func (mg *MsadUserAccountControlMapper) ResolveReferences(ctx context.Context, c // ResolveReferences of this RoleMapper. func (mg *RoleMapper) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.ForProvider.ClientIDRef, - Selector: mg.Spec.ForProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha13.ClientList{}, - Managed: &v1alpha13.Client{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.ForProvider.ClientIDRef, + Selector: mg.Spec.ForProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientID") } mg.Spec.ForProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, - Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, + Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.LdapUserFederationID") } mg.Spec.ForProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.InitProvider.ClientIDRef, - Selector: mg.Spec.InitProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha13.ClientList{}, - Managed: &v1alpha13.Client{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.InitProvider.ClientIDRef, + Selector: mg.Spec.InitProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientID") } mg.Spec.InitProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, - Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, + Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.LdapUserFederationID") } mg.Spec.InitProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -782,69 +927,83 @@ func (mg *RoleMapper) ResolveReferences(ctx context.Context, c client.Reader) er // ResolveReferences of this UserAttributeMapper. func (mg *UserAttributeMapper) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, - Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.LdapUserFederationIDRef, + Selector: mg.Spec.ForProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.LdapUserFederationID") } mg.Spec.ForProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, - Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, - To: reference.To{ - List: &UserFederationList{}, - Managed: &UserFederation{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("ldap.keycloak.crossplane.io", "v1alpha1", "UserFederation", "UserFederationList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.LdapUserFederationID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.LdapUserFederationIDRef, + Selector: mg.Spec.InitProvider.LdapUserFederationIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.LdapUserFederationID") } mg.Spec.InitProvider.LdapUserFederationID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.LdapUserFederationIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -856,37 +1015,45 @@ func (mg *UserAttributeMapper) ResolveReferences(ctx context.Context, c client.R // ResolveReferences of this UserFederation. func (mg *UserFederation) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } diff --git a/apis/oidc/v1alpha1/zz_generated.resolvers.go b/apis/oidc/v1alpha1/zz_generated.resolvers.go index 717f691d..7852190f 100644 --- a/apis/oidc/v1alpha1/zz_generated.resolvers.go +++ b/apis/oidc/v1alpha1/zz_generated.resolvers.go @@ -2,117 +2,138 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha11 "github.com/crossplane-contrib/provider-keycloak/apis/authenticationflow/v1alpha1" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/openidclient/v1alpha1" - v1alpha12 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" + common "github.com/crossplane-contrib/provider-keycloak/config/common" + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" ) -// ResolveReferences of this IdentityProvider. -func (mg *IdentityProvider) ResolveReferences(ctx context.Context, c client.Reader) error { +func (mg *IdentityProvider) ResolveReferences( // ResolveReferences of this IdentityProvider. + ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.ForProvider.ClientIDRef, - Selector: mg.Spec.ForProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.ForProvider.ClientIDRef, + Selector: mg.Spec.ForProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientID") } mg.Spec.ForProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.FirstBrokerLoginFlowAlias), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.ForProvider.FirstBrokerLoginFlowAliasRef, - Selector: mg.Spec.ForProvider.FirstBrokerLoginFlowAliasSelector, - To: reference.To{ - List: &v1alpha11.FlowList{}, - Managed: &v1alpha11.Flow{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.FirstBrokerLoginFlowAlias), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.ForProvider.FirstBrokerLoginFlowAliasRef, + Selector: mg.Spec.ForProvider.FirstBrokerLoginFlowAliasSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.FirstBrokerLoginFlowAlias") } mg.Spec.ForProvider.FirstBrokerLoginFlowAlias = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.FirstBrokerLoginFlowAliasRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Realm), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmRef, - Selector: mg.Spec.ForProvider.RealmSelector, - To: reference.To{ - List: &v1alpha12.RealmList{}, - Managed: &v1alpha12.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Realm), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmRef, + Selector: mg.Spec.ForProvider.RealmSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.Realm") } mg.Spec.ForProvider.Realm = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.InitProvider.ClientIDRef, - Selector: mg.Spec.InitProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.InitProvider.ClientIDRef, + Selector: mg.Spec.InitProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientID") } mg.Spec.InitProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.FirstBrokerLoginFlowAlias), - Extract: common.AuthenticationFlowAliasExtractor(), - Reference: mg.Spec.InitProvider.FirstBrokerLoginFlowAliasRef, - Selector: mg.Spec.InitProvider.FirstBrokerLoginFlowAliasSelector, - To: reference.To{ - List: &v1alpha11.FlowList{}, - Managed: &v1alpha11.Flow{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.FirstBrokerLoginFlowAlias), + Extract: common.AuthenticationFlowAliasExtractor(), + Reference: mg.Spec.InitProvider.FirstBrokerLoginFlowAliasRef, + Selector: mg.Spec.InitProvider.FirstBrokerLoginFlowAliasSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.FirstBrokerLoginFlowAlias") } mg.Spec.InitProvider.FirstBrokerLoginFlowAlias = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.FirstBrokerLoginFlowAliasRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.Realm), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmRef, - Selector: mg.Spec.InitProvider.RealmSelector, - To: reference.To{ - List: &v1alpha12.RealmList{}, - Managed: &v1alpha12.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.Realm), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmRef, + Selector: mg.Spec.InitProvider.RealmSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.Realm") } diff --git a/apis/openidclient/v1alpha1/zz_clientserviceaccountrole_types.go b/apis/openidclient/v1alpha1/zz_clientserviceaccountrole_types.go index 0c22acce..3b2d3891 100755 --- a/apis/openidclient/v1alpha1/zz_clientserviceaccountrole_types.go +++ b/apis/openidclient/v1alpha1/zz_clientserviceaccountrole_types.go @@ -41,8 +41,18 @@ type ClientServiceAccountRoleInitParameters struct { RealmIDSelector *v1.Selector `json:"realmIdSelector,omitempty" tf:"-"` // The name of the role that is assigned. + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1.Role + // +crossplane:generate:reference:extractor=github.com/crossplane/upjet/pkg/resource.ExtractParamPath("name", false) Role *string `json:"role,omitempty" tf:"role,omitempty"` + // Reference to a Role in role to populate role. + // +kubebuilder:validation:Optional + RoleRef *v1.Reference `json:"roleRef,omitempty" tf:"-"` + + // Selector for a Role in role to populate role. + // +kubebuilder:validation:Optional + RoleSelector *v1.Selector `json:"roleSelector,omitempty" tf:"-"` + // Reference to a Client in openidclient to populate serviceAccountUserId. // +kubebuilder:validation:Optional ServiceAccountUserClientIDRef *v1.Reference `json:"serviceAccountUserClientIdRef,omitempty" tf:"-"` @@ -106,9 +116,19 @@ type ClientServiceAccountRoleParameters struct { RealmIDSelector *v1.Selector `json:"realmIdSelector,omitempty" tf:"-"` // The name of the role that is assigned. + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1.Role + // +crossplane:generate:reference:extractor=github.com/crossplane/upjet/pkg/resource.ExtractParamPath("name", false) // +kubebuilder:validation:Optional Role *string `json:"role,omitempty" tf:"role,omitempty"` + // Reference to a Role in role to populate role. + // +kubebuilder:validation:Optional + RoleRef *v1.Reference `json:"roleRef,omitempty" tf:"-"` + + // Selector for a Role in role to populate role. + // +kubebuilder:validation:Optional + RoleSelector *v1.Selector `json:"roleSelector,omitempty" tf:"-"` + // Reference to a Client in openidclient to populate serviceAccountUserId. // +kubebuilder:validation:Optional ServiceAccountUserClientIDRef *v1.Reference `json:"serviceAccountUserClientIdRef,omitempty" tf:"-"` @@ -162,9 +182,8 @@ type ClientServiceAccountRoleStatus struct { type ClientServiceAccountRole struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.role) || (has(self.initProvider) && has(self.initProvider.role))",message="spec.forProvider.role is a required parameter" - Spec ClientServiceAccountRoleSpec `json:"spec"` - Status ClientServiceAccountRoleStatus `json:"status,omitempty"` + Spec ClientServiceAccountRoleSpec `json:"spec"` + Status ClientServiceAccountRoleStatus `json:"status,omitempty"` } // +kubebuilder:object:root=true diff --git a/apis/openidclient/v1alpha1/zz_generated.deepcopy.go b/apis/openidclient/v1alpha1/zz_generated.deepcopy.go index 3866304b..aa08edf8 100644 --- a/apis/openidclient/v1alpha1/zz_generated.deepcopy.go +++ b/apis/openidclient/v1alpha1/zz_generated.deepcopy.go @@ -3179,6 +3179,16 @@ func (in *ClientServiceAccountRoleInitParameters) DeepCopyInto(out *ClientServic *out = new(string) **out = **in } + if in.RoleRef != nil { + in, out := &in.RoleRef, &out.RoleRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.RoleSelector != nil { + in, out := &in.RoleSelector, &out.RoleSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.ServiceAccountUserClientIDRef != nil { in, out := &in.ServiceAccountUserClientIDRef, &out.ServiceAccountUserClientIDRef *out = new(v1.Reference) @@ -3316,6 +3326,16 @@ func (in *ClientServiceAccountRoleParameters) DeepCopyInto(out *ClientServiceAcc *out = new(string) **out = **in } + if in.RoleRef != nil { + in, out := &in.RoleRef, &out.RoleRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.RoleSelector != nil { + in, out := &in.RoleSelector, &out.RoleSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.ServiceAccountUserClientIDRef != nil { in, out := &in.ServiceAccountUserClientIDRef, &out.ServiceAccountUserClientIDRef *out = new(v1.Reference) diff --git a/apis/openidclient/v1alpha1/zz_generated.resolvers.go b/apis/openidclient/v1alpha1/zz_generated.resolvers.go index 068f015f..6fc3039d 100644 --- a/apis/openidclient/v1alpha1/zz_generated.resolvers.go +++ b/apis/openidclient/v1alpha1/zz_generated.resolvers.go @@ -2,37 +2,46 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/authenticationflow/v1alpha1" - v1alpha11 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" + common "github.com/crossplane-contrib/provider-keycloak/config/common" + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" + resource "github.com/crossplane/upjet/pkg/resource" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" + + // ResolveReferences of this Client. + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" ) -// ResolveReferences of this Client. func (mg *Client) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error for i3 := 0; i3 < len(mg.Spec.ForProvider.AuthenticationFlowBindingOverrides); i3++ { - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].BrowserID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].BrowserIDRef, - Selector: mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].BrowserIDSelector, - To: reference.To{ - List: &v1alpha1.FlowList{}, - Managed: &v1alpha1.Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].BrowserID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].BrowserIDRef, + Selector: mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].BrowserIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].BrowserID") } @@ -41,16 +50,19 @@ func (mg *Client) ResolveReferences(ctx context.Context, c client.Reader) error } for i3 := 0; i3 < len(mg.Spec.ForProvider.AuthenticationFlowBindingOverrides); i3++ { - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantIDRef, - Selector: mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantIDSelector, - To: reference.To{ - List: &v1alpha1.FlowList{}, - Managed: &v1alpha1.Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantIDRef, + Selector: mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantID") } @@ -58,32 +70,38 @@ func (mg *Client) ResolveReferences(ctx context.Context, c client.Reader) error mg.Spec.ForProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantIDRef = rsp.ResolvedReference } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.ForProvider.ClientIDRef, - Selector: mg.Spec.ForProvider.ClientIDSelector, - To: reference.To{ - List: &ClientList{}, - Managed: &Client{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.ForProvider.ClientIDRef, + Selector: mg.Spec.ForProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientID") } mg.Spec.ForProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } @@ -91,16 +109,19 @@ func (mg *Client) ResolveReferences(ctx context.Context, c client.Reader) error mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference for i3 := 0; i3 < len(mg.Spec.InitProvider.AuthenticationFlowBindingOverrides); i3++ { - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].BrowserID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].BrowserIDRef, - Selector: mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].BrowserIDSelector, - To: reference.To{ - List: &v1alpha1.FlowList{}, - Managed: &v1alpha1.Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].BrowserID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].BrowserIDRef, + Selector: mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].BrowserIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].BrowserID") } @@ -109,16 +130,19 @@ func (mg *Client) ResolveReferences(ctx context.Context, c client.Reader) error } for i3 := 0; i3 < len(mg.Spec.InitProvider.AuthenticationFlowBindingOverrides); i3++ { - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantIDRef, - Selector: mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantIDSelector, - To: reference.To{ - List: &v1alpha1.FlowList{}, - Managed: &v1alpha1.Flow{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("authenticationflow.keycloak.crossplane.io", "v1alpha1", "Flow", "FlowList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantIDRef, + Selector: mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantID") } @@ -126,32 +150,38 @@ func (mg *Client) ResolveReferences(ctx context.Context, c client.Reader) error mg.Spec.InitProvider.AuthenticationFlowBindingOverrides[i3].DirectGrantIDRef = rsp.ResolvedReference } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.InitProvider.ClientIDRef, - Selector: mg.Spec.InitProvider.ClientIDSelector, - To: reference.To{ - List: &ClientList{}, - Managed: &Client{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.InitProvider.ClientIDRef, + Selector: mg.Spec.InitProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientID") } mg.Spec.InitProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -163,37 +193,45 @@ func (mg *Client) ResolveReferences(ctx context.Context, c client.Reader) error // ResolveReferences of this ClientClientPolicy. func (mg *ClientClientPolicy) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -205,69 +243,83 @@ func (mg *ClientClientPolicy) ResolveReferences(ctx context.Context, c client.Re // ResolveReferences of this ClientDefaultScopes. func (mg *ClientDefaultScopes) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.ForProvider.ClientIDRef, - Selector: mg.Spec.ForProvider.ClientIDSelector, - To: reference.To{ - List: &ClientList{}, - Managed: &Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.ForProvider.ClientIDRef, + Selector: mg.Spec.ForProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientID") } mg.Spec.ForProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.InitProvider.ClientIDRef, - Selector: mg.Spec.InitProvider.ClientIDSelector, - To: reference.To{ - List: &ClientList{}, - Managed: &Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.InitProvider.ClientIDRef, + Selector: mg.Spec.InitProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientID") } mg.Spec.InitProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -279,37 +331,45 @@ func (mg *ClientDefaultScopes) ResolveReferences(ctx context.Context, c client.R // ResolveReferences of this ClientGroupPolicy. func (mg *ClientGroupPolicy) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -321,69 +381,83 @@ func (mg *ClientGroupPolicy) ResolveReferences(ctx context.Context, c client.Rea // ResolveReferences of this ClientPermissions. func (mg *ClientPermissions) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.ForProvider.ClientIDRef, - Selector: mg.Spec.ForProvider.ClientIDSelector, - To: reference.To{ - List: &ClientList{}, - Managed: &Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.ForProvider.ClientIDRef, + Selector: mg.Spec.ForProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientID") } mg.Spec.ForProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.InitProvider.ClientIDRef, - Selector: mg.Spec.InitProvider.ClientIDSelector, - To: reference.To{ - List: &ClientList{}, - Managed: &Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.InitProvider.ClientIDRef, + Selector: mg.Spec.InitProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientID") } mg.Spec.InitProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -395,37 +469,45 @@ func (mg *ClientPermissions) ResolveReferences(ctx context.Context, c client.Rea // ResolveReferences of this ClientRolePolicy. func (mg *ClientRolePolicy) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -437,37 +519,45 @@ func (mg *ClientRolePolicy) ResolveReferences(ctx context.Context, c client.Read // ResolveReferences of this ClientScope. func (mg *ClientScope) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -479,69 +569,83 @@ func (mg *ClientScope) ResolveReferences(ctx context.Context, c client.Reader) e // ResolveReferences of this ClientServiceAccountRealmRole. func (mg *ClientServiceAccountRealmRole) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ServiceAccountUserID), - Extract: common.ServiceAccountRoleIDExtractor(), - Reference: mg.Spec.ForProvider.ServiceAccountUserClientIDRef, - Selector: mg.Spec.ForProvider.ServiceAccountUserClientIDSelector, - To: reference.To{ - List: &ClientList{}, - Managed: &Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ServiceAccountUserID), + Extract: common.ServiceAccountRoleIDExtractor(), + Reference: mg.Spec.ForProvider.ServiceAccountUserClientIDRef, + Selector: mg.Spec.ForProvider.ServiceAccountUserClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ServiceAccountUserID") } mg.Spec.ForProvider.ServiceAccountUserID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ServiceAccountUserClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } mg.Spec.InitProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ServiceAccountUserID), - Extract: common.ServiceAccountRoleIDExtractor(), - Reference: mg.Spec.InitProvider.ServiceAccountUserClientIDRef, - Selector: mg.Spec.InitProvider.ServiceAccountUserClientIDSelector, - To: reference.To{ - List: &ClientList{}, - Managed: &Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ServiceAccountUserID), + Extract: common.ServiceAccountRoleIDExtractor(), + Reference: mg.Spec.InitProvider.ServiceAccountUserClientIDRef, + Selector: mg.Spec.InitProvider.ServiceAccountUserClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ServiceAccountUserID") } @@ -553,101 +657,159 @@ func (mg *ClientServiceAccountRealmRole) ResolveReferences(ctx context.Context, // ResolveReferences of this ClientServiceAccountRole. func (mg *ClientServiceAccountRole) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.ForProvider.ClientIDRef, - Selector: mg.Spec.ForProvider.ClientIDSelector, - To: reference.To{ - List: &ClientList{}, - Managed: &Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.ForProvider.ClientIDRef, + Selector: mg.Spec.ForProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientID") } mg.Spec.ForProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ServiceAccountUserID), - Extract: common.ServiceAccountRoleIDExtractor(), - Reference: mg.Spec.ForProvider.ServiceAccountUserClientIDRef, - Selector: mg.Spec.ForProvider.ServiceAccountUserClientIDSelector, - To: reference.To{ - List: &ClientList{}, - Managed: &Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Role), + Extract: resource.ExtractParamPath("name", false), + Reference: mg.Spec.ForProvider.RoleRef, + Selector: mg.Spec.ForProvider.RoleSelector, + To: reference.To{List: l, Managed: m}, + }) + } + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.Role") + } + mg.Spec.ForProvider.Role = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.RoleRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ServiceAccountUserID), + Extract: common.ServiceAccountRoleIDExtractor(), + Reference: mg.Spec.ForProvider.ServiceAccountUserClientIDRef, + Selector: mg.Spec.ForProvider.ServiceAccountUserClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ServiceAccountUserID") } mg.Spec.ForProvider.ServiceAccountUserID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ServiceAccountUserClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.InitProvider.ClientIDRef, - Selector: mg.Spec.InitProvider.ClientIDSelector, - To: reference.To{ - List: &ClientList{}, - Managed: &Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.InitProvider.ClientIDRef, + Selector: mg.Spec.InitProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientID") } mg.Spec.InitProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } mg.Spec.InitProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ServiceAccountUserID), - Extract: common.ServiceAccountRoleIDExtractor(), - Reference: mg.Spec.InitProvider.ServiceAccountUserClientIDRef, - Selector: mg.Spec.InitProvider.ServiceAccountUserClientIDSelector, - To: reference.To{ - List: &ClientList{}, - Managed: &Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.Role), + Extract: resource.ExtractParamPath("name", false), + Reference: mg.Spec.InitProvider.RoleRef, + Selector: mg.Spec.InitProvider.RoleSelector, + To: reference.To{List: l, Managed: m}, + }) + } + if err != nil { + return errors.Wrap(err, "mg.Spec.InitProvider.Role") + } + mg.Spec.InitProvider.Role = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.InitProvider.RoleRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ServiceAccountUserID), + Extract: common.ServiceAccountRoleIDExtractor(), + Reference: mg.Spec.InitProvider.ServiceAccountUserClientIDRef, + Selector: mg.Spec.InitProvider.ServiceAccountUserClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ServiceAccountUserID") } @@ -659,37 +821,45 @@ func (mg *ClientServiceAccountRole) ResolveReferences(ctx context.Context, c cli // ResolveReferences of this ClientUserPolicy. func (mg *ClientUserPolicy) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } diff --git a/apis/openidgroup/v1alpha1/zz_generated.resolvers.go b/apis/openidgroup/v1alpha1/zz_generated.resolvers.go index d9d8512d..4f097292 100644 --- a/apis/openidgroup/v1alpha1/zz_generated.resolvers.go +++ b/apis/openidgroup/v1alpha1/zz_generated.resolvers.go @@ -2,116 +2,138 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/openidclient/v1alpha1" - v1alpha11 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" + common "github.com/crossplane-contrib/provider-keycloak/config/common" + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" ) -// ResolveReferences of this GroupMembershipProtocolMapper. -func (mg *GroupMembershipProtocolMapper) ResolveReferences(ctx context.Context, c client.Reader) error { +func (mg *GroupMembershipProtocolMapper) ResolveReferences( // ResolveReferences of this GroupMembershipProtocolMapper. + ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.ForProvider.ClientIDRef, - Selector: mg.Spec.ForProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.ForProvider.ClientIDRef, + Selector: mg.Spec.ForProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientID") } mg.Spec.ForProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "ClientScope", "ClientScopeList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientScopeID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.ClientScopeIDRef, - Selector: mg.Spec.ForProvider.ClientScopeIDSelector, - To: reference.To{ - List: &v1alpha1.ClientScopeList{}, - Managed: &v1alpha1.ClientScope{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientScopeID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.ClientScopeIDRef, + Selector: mg.Spec.ForProvider.ClientScopeIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientScopeID") } mg.Spec.ForProvider.ClientScopeID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientScopeIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.InitProvider.ClientIDRef, - Selector: mg.Spec.InitProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.InitProvider.ClientIDRef, + Selector: mg.Spec.InitProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientID") } mg.Spec.InitProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "ClientScope", "ClientScopeList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientScopeID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.ClientScopeIDRef, - Selector: mg.Spec.InitProvider.ClientScopeIDSelector, - To: reference.To{ - List: &v1alpha1.ClientScopeList{}, - Managed: &v1alpha1.ClientScope{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientScopeID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.ClientScopeIDRef, + Selector: mg.Spec.InitProvider.ClientScopeIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientScopeID") } mg.Spec.InitProvider.ClientScopeID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientScopeIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } diff --git a/apis/realm/v1alpha1/zz_generated.resolvers.go b/apis/realm/v1alpha1/zz_generated.resolvers.go index 8aa8c70e..e891bcf5 100644 --- a/apis/realm/v1alpha1/zz_generated.resolvers.go +++ b/apis/realm/v1alpha1/zz_generated.resolvers.go @@ -2,49 +2,61 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" + + // ResolveReferences of this KeystoreRsa. + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" ) -// ResolveReferences of this KeystoreRsa. func (mg *KeystoreRsa) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &RealmList{}, - Managed: &Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &RealmList{}, - Managed: &Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -56,37 +68,45 @@ func (mg *KeystoreRsa) ResolveReferences(ctx context.Context, c client.Reader) e // ResolveReferences of this RequiredAction. func (mg *RequiredAction) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &RealmList{}, - Managed: &Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &RealmList{}, - Managed: &Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } diff --git a/apis/role/v1alpha1/zz_generated.resolvers.go b/apis/role/v1alpha1/zz_generated.resolvers.go index 2f403a4d..c89d237c 100644 --- a/apis/role/v1alpha1/zz_generated.resolvers.go +++ b/apis/role/v1alpha1/zz_generated.resolvers.go @@ -2,117 +2,140 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/openidclient/v1alpha1" - v1alpha11 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" + common "github.com/crossplane-contrib/provider-keycloak/config/common" + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" + + // ResolveReferences of this Role. + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" ) -// ResolveReferences of this Role. func (mg *Role) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var mrsp reference.MultiResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.ForProvider.ClientIDRef, - Selector: mg.Spec.ForProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.ForProvider.ClientIDRef, + Selector: mg.Spec.ForProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientID") } mg.Spec.ForProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ - CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.CompositeRoles), - Extract: reference.ExternalName(), - References: mg.Spec.ForProvider.CompositeRolesRefs, - Selector: mg.Spec.ForProvider.CompositeRolesSelector, - To: reference.To{ - List: &RoleList{}, - Managed: &Role{}, - }, - }) + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.CompositeRoles), + Extract: reference.ExternalName(), + References: mg.Spec.ForProvider.CompositeRolesRefs, + Selector: mg.Spec.ForProvider.CompositeRolesSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.CompositeRoles") } mg.Spec.ForProvider.CompositeRoles = reference.ToPtrValues(mrsp.ResolvedValues) mg.Spec.ForProvider.CompositeRolesRefs = mrsp.ResolvedReferences + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.InitProvider.ClientIDRef, - Selector: mg.Spec.InitProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.InitProvider.ClientIDRef, + Selector: mg.Spec.InitProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientID") } mg.Spec.InitProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ - CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.CompositeRoles), - Extract: reference.ExternalName(), - References: mg.Spec.InitProvider.CompositeRolesRefs, - Selector: mg.Spec.InitProvider.CompositeRolesSelector, - To: reference.To{ - List: &RoleList{}, - Managed: &Role{}, - }, - }) + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.CompositeRoles), + Extract: reference.ExternalName(), + References: mg.Spec.InitProvider.CompositeRolesRefs, + Selector: mg.Spec.InitProvider.CompositeRolesSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.CompositeRoles") } mg.Spec.InitProvider.CompositeRoles = reference.ToPtrValues(mrsp.ResolvedValues) mg.Spec.InitProvider.CompositeRolesRefs = mrsp.ResolvedReferences + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } diff --git a/apis/role/v1alpha1/zz_role_types.go b/apis/role/v1alpha1/zz_role_types.go index b6268e4b..7b76a2df 100755 --- a/apis/role/v1alpha1/zz_role_types.go +++ b/apis/role/v1alpha1/zz_role_types.go @@ -33,15 +33,15 @@ type RoleInitParameters struct { ClientIDSelector *v1.Selector `json:"clientIdSelector,omitempty" tf:"-"` // When specified, this role will be a composite role, composed of all roles that have an ID present within this list. - // +crossplane:generate:reference:type=Role + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1.Role // +listType=set CompositeRoles []*string `json:"compositeRoles,omitempty" tf:"composite_roles,omitempty"` - // References to Role to populate compositeRoles. + // References to Role in role to populate compositeRoles. // +kubebuilder:validation:Optional CompositeRolesRefs []v1.Reference `json:"compositeRolesRefs,omitempty" tf:"-"` - // Selector for a list of Role to populate compositeRoles. + // Selector for a list of Role in role to populate compositeRoles. // +kubebuilder:validation:Optional CompositeRolesSelector *v1.Selector `json:"compositeRolesSelector,omitempty" tf:"-"` @@ -111,16 +111,16 @@ type RoleParameters struct { ClientIDSelector *v1.Selector `json:"clientIdSelector,omitempty" tf:"-"` // When specified, this role will be a composite role, composed of all roles that have an ID present within this list. - // +crossplane:generate:reference:type=Role + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1.Role // +kubebuilder:validation:Optional // +listType=set CompositeRoles []*string `json:"compositeRoles,omitempty" tf:"composite_roles,omitempty"` - // References to Role to populate compositeRoles. + // References to Role in role to populate compositeRoles. // +kubebuilder:validation:Optional CompositeRolesRefs []v1.Reference `json:"compositeRolesRefs,omitempty" tf:"-"` - // Selector for a list of Role to populate compositeRoles. + // Selector for a list of Role in role to populate compositeRoles. // +kubebuilder:validation:Optional CompositeRolesSelector *v1.Selector `json:"compositeRolesSelector,omitempty" tf:"-"` diff --git a/apis/saml/v1alpha1/zz_generated.resolvers.go b/apis/saml/v1alpha1/zz_generated.resolvers.go index f9a11678..06c708e8 100644 --- a/apis/saml/v1alpha1/zz_generated.resolvers.go +++ b/apis/saml/v1alpha1/zz_generated.resolvers.go @@ -2,50 +2,61 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" + + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" ) -// ResolveReferences of this IdentityProvider. -func (mg *IdentityProvider) ResolveReferences(ctx context.Context, c client.Reader) error { +func (mg *IdentityProvider) ResolveReferences( // ResolveReferences of this IdentityProvider. + ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Realm), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmRef, - Selector: mg.Spec.ForProvider.RealmSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Realm), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmRef, + Selector: mg.Spec.ForProvider.RealmSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.Realm") } mg.Spec.ForProvider.Realm = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.Realm), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmRef, - Selector: mg.Spec.InitProvider.RealmSelector, - To: reference.To{ - List: &v1alpha1.RealmList{}, - Managed: &v1alpha1.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.Realm), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmRef, + Selector: mg.Spec.InitProvider.RealmSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.Realm") } diff --git a/apis/samlclient/v1alpha1/zz_generated.resolvers.go b/apis/samlclient/v1alpha1/zz_generated.resolvers.go index 2fc8d65e..d446ecc6 100644 --- a/apis/samlclient/v1alpha1/zz_generated.resolvers.go +++ b/apis/samlclient/v1alpha1/zz_generated.resolvers.go @@ -2,84 +2,101 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/openidclient/v1alpha1" - v1alpha11 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" + common "github.com/crossplane-contrib/provider-keycloak/config/common" + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" + + // ResolveReferences of this Client. + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" ) -// ResolveReferences of this Client. func (mg *Client) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.ForProvider.ClientIDRef, - Selector: mg.Spec.ForProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.ForProvider.ClientIDRef, + Selector: mg.Spec.ForProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientID") } mg.Spec.ForProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.InitProvider.ClientIDRef, - Selector: mg.Spec.InitProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.InitProvider.ClientIDRef, + Selector: mg.Spec.InitProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientID") } mg.Spec.InitProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -91,69 +108,83 @@ func (mg *Client) ResolveReferences(ctx context.Context, c client.Reader) error // ResolveReferences of this ClientDefaultScopes. func (mg *ClientDefaultScopes) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.ForProvider.ClientIDRef, - Selector: mg.Spec.ForProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.ForProvider.ClientIDRef, + Selector: mg.Spec.ForProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.ClientID") } mg.Spec.ForProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClientIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), - Extract: common.UUIDExtractor(), - Reference: mg.Spec.InitProvider.ClientIDRef, - Selector: mg.Spec.InitProvider.ClientIDSelector, - To: reference.To{ - List: &v1alpha1.ClientList{}, - Managed: &v1alpha1.Client{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("openidclient.keycloak.crossplane.io", "v1alpha1", "Client", "ClientList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ClientID), + Extract: common.UUIDExtractor(), + Reference: mg.Spec.InitProvider.ClientIDRef, + Selector: mg.Spec.InitProvider.ClientIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.ClientID") } mg.Spec.InitProvider.ClientID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClientIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -165,37 +196,45 @@ func (mg *ClientDefaultScopes) ResolveReferences(ctx context.Context, c client.R // ResolveReferences of this ClientScope. func (mg *ClientScope) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } diff --git a/apis/user/v1alpha1/zz_generated.resolvers.go b/apis/user/v1alpha1/zz_generated.resolvers.go index de3a40b0..f5333024 100644 --- a/apis/user/v1alpha1/zz_generated.resolvers.go +++ b/apis/user/v1alpha1/zz_generated.resolvers.go @@ -2,118 +2,101 @@ Copyright 2022 Upbound Inc. */ // Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. package v1alpha1 import ( "context" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1" - v1alpha11 "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1" - v1alpha12 "github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1" + common "github.com/crossplane-contrib/provider-keycloak/config/common" + apisresolver "github.com/crossplane-contrib/provider-keycloak/internal/apis" reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" + + // ResolveReferences of this Groups. + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" ) -// ResolveReferences of this Groups. func (mg *Groups) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse - var mrsp reference.MultiResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ - CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.GroupIds), - Extract: reference.ExternalName(), - References: mg.Spec.ForProvider.GroupIdsRefs, - Selector: mg.Spec.ForProvider.GroupIdsSelector, - To: reference.To{ - List: &v1alpha1.GroupList{}, - Managed: &v1alpha1.Group{}, - }, - }) - if err != nil { - return errors.Wrap(err, "mg.Spec.ForProvider.GroupIds") + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) } - mg.Spec.ForProvider.GroupIds = reference.ToPtrValues(mrsp.ResolvedValues) - mg.Spec.ForProvider.GroupIdsRefs = mrsp.ResolvedReferences - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("user.keycloak.crossplane.io", "v1alpha1", "User", "UserList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.UserID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.UserIDRef, - Selector: mg.Spec.ForProvider.UserIDSelector, - To: reference.To{ - List: &UserList{}, - Managed: &User{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.UserID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.UserIDRef, + Selector: mg.Spec.ForProvider.UserIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.UserID") } mg.Spec.ForProvider.UserID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.UserIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ - CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.GroupIds), - Extract: reference.ExternalName(), - References: mg.Spec.InitProvider.GroupIdsRefs, - Selector: mg.Spec.InitProvider.GroupIdsSelector, - To: reference.To{ - List: &v1alpha1.GroupList{}, - Managed: &v1alpha1.Group{}, - }, - }) - if err != nil { - return errors.Wrap(err, "mg.Spec.InitProvider.GroupIds") + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) } - mg.Spec.InitProvider.GroupIds = reference.ToPtrValues(mrsp.ResolvedValues) - mg.Spec.InitProvider.GroupIdsRefs = mrsp.ResolvedReferences - - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } mg.Spec.InitProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("user.keycloak.crossplane.io", "v1alpha1", "User", "UserList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.UserID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.UserIDRef, - Selector: mg.Spec.InitProvider.UserIDSelector, - To: reference.To{ - List: &UserList{}, - Managed: &User{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.UserID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.UserIDRef, + Selector: mg.Spec.InitProvider.UserIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.UserID") } @@ -125,37 +108,45 @@ func (mg *Groups) ResolveReferences(ctx context.Context, c client.Reader) error // ResolveReferences of this Permissions. func (mg *Permissions) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } @@ -167,102 +158,122 @@ func (mg *Permissions) ResolveReferences(ctx context.Context, c client.Reader) e // ResolveReferences of this Roles. func (mg *Roles) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var mrsp reference.MultiResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ - CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.RoleIds), - Extract: common.UUIDExtractor(), - References: mg.Spec.ForProvider.RoleIdsRefs, - Selector: mg.Spec.ForProvider.RoleIdsSelector, - To: reference.To{ - List: &v1alpha12.RoleList{}, - Managed: &v1alpha12.Role{}, - }, - }) + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.RoleIds), + Extract: common.UUIDExtractor(), + References: mg.Spec.ForProvider.RoleIdsRefs, + Selector: mg.Spec.ForProvider.RoleIdsSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RoleIds") } mg.Spec.ForProvider.RoleIds = reference.ToPtrValues(mrsp.ResolvedValues) mg.Spec.ForProvider.RoleIdsRefs = mrsp.ResolvedReferences + { + m, l, err = apisresolver.GetManagedResource("user.keycloak.crossplane.io", "v1alpha1", "User", "UserList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.UserID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.UserIDRef, - Selector: mg.Spec.ForProvider.UserIDSelector, - To: reference.To{ - List: &UserList{}, - Managed: &User{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.UserID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.UserIDRef, + Selector: mg.Spec.ForProvider.UserIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.UserID") } mg.Spec.ForProvider.UserID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.UserIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } mg.Spec.InitProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("role.keycloak.crossplane.io", "v1alpha1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ - CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.RoleIds), - Extract: common.UUIDExtractor(), - References: mg.Spec.InitProvider.RoleIdsRefs, - Selector: mg.Spec.InitProvider.RoleIdsSelector, - To: reference.To{ - List: &v1alpha12.RoleList{}, - Managed: &v1alpha12.Role{}, - }, - }) + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.RoleIds), + Extract: common.UUIDExtractor(), + References: mg.Spec.InitProvider.RoleIdsRefs, + Selector: mg.Spec.InitProvider.RoleIdsSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RoleIds") } mg.Spec.InitProvider.RoleIds = reference.ToPtrValues(mrsp.ResolvedValues) mg.Spec.InitProvider.RoleIdsRefs = mrsp.ResolvedReferences + { + m, l, err = apisresolver.GetManagedResource("user.keycloak.crossplane.io", "v1alpha1", "User", "UserList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.UserID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.UserIDRef, - Selector: mg.Spec.InitProvider.UserIDSelector, - To: reference.To{ - List: &UserList{}, - Managed: &User{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.UserID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.UserIDRef, + Selector: mg.Spec.InitProvider.UserIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.UserID") } @@ -274,37 +285,45 @@ func (mg *Roles) ResolveReferences(ctx context.Context, c client.Reader) error { // ResolveReferences of this User. func (mg *User) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse var err error + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.ForProvider.RealmIDRef, - Selector: mg.Spec.ForProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.RealmIDRef, + Selector: mg.Spec.ForProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.ForProvider.RealmID") } mg.Spec.ForProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.RealmIDRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("realm.keycloak.crossplane.io", "v1alpha1", "Realm", "RealmList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } - rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ - CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), - Extract: reference.ExternalName(), - Reference: mg.Spec.InitProvider.RealmIDRef, - Selector: mg.Spec.InitProvider.RealmIDSelector, - To: reference.To{ - List: &v1alpha11.RealmList{}, - Managed: &v1alpha11.Realm{}, - }, - }) + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RealmID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.RealmIDRef, + Selector: mg.Spec.InitProvider.RealmIDSelector, + To: reference.To{List: l, Managed: m}, + }) + } if err != nil { return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") } diff --git a/apis/user/v1alpha1/zz_groups_types.go b/apis/user/v1alpha1/zz_groups_types.go index da31bd8e..3aa03c3d 100755 --- a/apis/user/v1alpha1/zz_groups_types.go +++ b/apis/user/v1alpha1/zz_groups_types.go @@ -19,15 +19,14 @@ type GroupsInitParameters struct { Exhaustive *bool `json:"exhaustive,omitempty" tf:"exhaustive,omitempty"` // A list of group IDs that the user is member of. - // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1.Group // +listType=set GroupIds []*string `json:"groupIds,omitempty" tf:"group_ids,omitempty"` - // References to Group in group to populate groupIds. + // References to to populate groupIds. // +kubebuilder:validation:Optional GroupIdsRefs []v1.Reference `json:"groupIdsRefs,omitempty" tf:"-"` - // Selector for a list of Group in group to populate groupIds. + // Selector for a list of to populate groupIds. // +kubebuilder:validation:Optional GroupIdsSelector *v1.Selector `json:"groupIdsSelector,omitempty" tf:"-"` @@ -44,14 +43,14 @@ type GroupsInitParameters struct { RealmIDSelector *v1.Selector `json:"realmIdSelector,omitempty" tf:"-"` // The ID of the user this resource should manage groups for. - // +crossplane:generate:reference:type=User + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/user/v1alpha1.User UserID *string `json:"userId,omitempty" tf:"user_id,omitempty"` - // Reference to a User to populate userId. + // Reference to a User in user to populate userId. // +kubebuilder:validation:Optional UserIDRef *v1.Reference `json:"userIdRef,omitempty" tf:"-"` - // Selector for a User to populate userId. + // Selector for a User in user to populate userId. // +kubebuilder:validation:Optional UserIDSelector *v1.Selector `json:"userIdSelector,omitempty" tf:"-"` } @@ -81,16 +80,15 @@ type GroupsParameters struct { Exhaustive *bool `json:"exhaustive,omitempty" tf:"exhaustive,omitempty"` // A list of group IDs that the user is member of. - // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1.Group // +kubebuilder:validation:Optional // +listType=set GroupIds []*string `json:"groupIds,omitempty" tf:"group_ids,omitempty"` - // References to Group in group to populate groupIds. + // References to to populate groupIds. // +kubebuilder:validation:Optional GroupIdsRefs []v1.Reference `json:"groupIdsRefs,omitempty" tf:"-"` - // Selector for a list of Group in group to populate groupIds. + // Selector for a list of to populate groupIds. // +kubebuilder:validation:Optional GroupIdsSelector *v1.Selector `json:"groupIdsSelector,omitempty" tf:"-"` @@ -108,15 +106,15 @@ type GroupsParameters struct { RealmIDSelector *v1.Selector `json:"realmIdSelector,omitempty" tf:"-"` // The ID of the user this resource should manage groups for. - // +crossplane:generate:reference:type=User + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/user/v1alpha1.User // +kubebuilder:validation:Optional UserID *string `json:"userId,omitempty" tf:"user_id,omitempty"` - // Reference to a User to populate userId. + // Reference to a User in user to populate userId. // +kubebuilder:validation:Optional UserIDRef *v1.Reference `json:"userIdRef,omitempty" tf:"-"` - // Selector for a User to populate userId. + // Selector for a User in user to populate userId. // +kubebuilder:validation:Optional UserIDSelector *v1.Selector `json:"userIdSelector,omitempty" tf:"-"` } diff --git a/apis/user/v1alpha1/zz_roles_types.go b/apis/user/v1alpha1/zz_roles_types.go index ee7ab5be..28abda46 100755 --- a/apis/user/v1alpha1/zz_roles_types.go +++ b/apis/user/v1alpha1/zz_roles_types.go @@ -45,14 +45,14 @@ type RolesInitParameters struct { RoleIdsSelector *v1.Selector `json:"roleIdsSelector,omitempty" tf:"-"` // The ID of the user this resource should manage roles for. - // +crossplane:generate:reference:type=User + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/user/v1alpha1.User UserID *string `json:"userId,omitempty" tf:"user_id,omitempty"` - // Reference to a User to populate userId. + // Reference to a User in user to populate userId. // +kubebuilder:validation:Optional UserIDRef *v1.Reference `json:"userIdRef,omitempty" tf:"-"` - // Selector for a User to populate userId. + // Selector for a User in user to populate userId. // +kubebuilder:validation:Optional UserIDSelector *v1.Selector `json:"userIdSelector,omitempty" tf:"-"` } @@ -110,15 +110,15 @@ type RolesParameters struct { RoleIdsSelector *v1.Selector `json:"roleIdsSelector,omitempty" tf:"-"` // The ID of the user this resource should manage roles for. - // +crossplane:generate:reference:type=User + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/user/v1alpha1.User // +kubebuilder:validation:Optional UserID *string `json:"userId,omitempty" tf:"user_id,omitempty"` - // Reference to a User to populate userId. + // Reference to a User in user to populate userId. // +kubebuilder:validation:Optional UserIDRef *v1.Reference `json:"userIdRef,omitempty" tf:"-"` - // Selector for a User to populate userId. + // Selector for a User in user to populate userId. // +kubebuilder:validation:Optional UserIDSelector *v1.Selector `json:"userIdSelector,omitempty" tf:"-"` } diff --git a/dev/bugs/import.yaml b/dev/bugs/import.yaml new file mode 100644 index 00000000..39ef27b7 --- /dev/null +++ b/dev/bugs/import.yaml @@ -0,0 +1,15 @@ +apiVersion: role.keycloak.crossplane.io/v1alpha1 +kind: Role +metadata: + annotations: + crossplane.io/external-name: 182b0c9b-197f-45e3-8f4a-386cd6890d73 + name: builtin-master-realm-role-uma-authorization +spec: + deletionPolicy: Orphan + forProvider: + name: uma_authorization + realmId: master + managementPolicies: + - Observe + providerConfigRef: + name: keycloak-provider-config diff --git a/examples-generated/openidclient/v1alpha1/clientserviceaccountrole.yaml b/examples-generated/openidclient/v1alpha1/clientserviceaccountrole.yaml index 459a9bec..c593b6a2 100644 --- a/examples-generated/openidclient/v1alpha1/clientserviceaccountrole.yaml +++ b/examples-generated/openidclient/v1alpha1/clientserviceaccountrole.yaml @@ -14,7 +14,9 @@ spec: realmIdSelector: matchLabels: testing.upbound.io/example-name: realm - role: my-realm-role + roleSelector: + matchLabels: + testing.upbound.io/example-name: client1_role serviceAccountUserClientIdSelector: matchLabels: testing.upbound.io/example-name: client2 diff --git a/examples-generated/user/v1alpha1/groups.yaml b/examples-generated/user/v1alpha1/groups.yaml index 67943334..841859bb 100644 --- a/examples-generated/user/v1alpha1/groups.yaml +++ b/examples-generated/user/v1alpha1/groups.yaml @@ -8,8 +8,8 @@ metadata: name: user-groups spec: forProvider: - groupIdsRefs: - - name: group + groupIds: + - ${keycloak_group.group.id} realmIdSelector: matchLabels: testing.upbound.io/example-name: realm diff --git a/go.mod b/go.mod index 99c269dc..d588a6c4 100644 --- a/go.mod +++ b/go.mod @@ -110,16 +110,17 @@ require ( github.com/zclconf/go-cty-yaml v1.0.3 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.22.0 // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.24.0 // indirect + golang.org/x/mod v0.19.0 // indirect + golang.org/x/net v0.27.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/term v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/term v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.17.0 // indirect + golang.org/x/tools v0.23.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect diff --git a/go.sum b/go.sum index 24791f67..2c9104e9 100644 --- a/go.sum +++ b/go.sum @@ -330,8 +330,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o= golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -339,8 +339,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= @@ -355,8 +355,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -366,8 +366,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -390,15 +390,15 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -408,8 +408,8 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -420,8 +420,8 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= +golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/package/crds/group.keycloak.crossplane.io_groups.yaml b/package/crds/group.keycloak.crossplane.io_groups.yaml index dafa8cba..6ed09ee2 100644 --- a/package/crds/group.keycloak.crossplane.io_groups.yaml +++ b/package/crds/group.keycloak.crossplane.io_groups.yaml @@ -88,7 +88,7 @@ spec: will be defined at the root level. type: string parentIdRef: - description: Reference to a Group to populate parentId. + description: Reference to a Group in group to populate parentId. properties: name: description: Name of the referenced object. @@ -122,7 +122,7 @@ spec: - name type: object parentIdSelector: - description: Selector for a Group to populate parentId. + description: Selector for a Group in group to populate parentId. properties: matchControllerRef: description: |- @@ -268,7 +268,7 @@ spec: will be defined at the root level. type: string parentIdRef: - description: Reference to a Group to populate parentId. + description: Reference to a Group in group to populate parentId. properties: name: description: Name of the referenced object. @@ -302,7 +302,7 @@ spec: - name type: object parentIdSelector: - description: Selector for a Group to populate parentId. + description: Selector for a Group in group to populate parentId. properties: matchControllerRef: description: |- diff --git a/package/crds/group.keycloak.crossplane.io_memberships.yaml b/package/crds/group.keycloak.crossplane.io_memberships.yaml index b7f05f1e..99e52a57 100644 --- a/package/crds/group.keycloak.crossplane.io_memberships.yaml +++ b/package/crds/group.keycloak.crossplane.io_memberships.yaml @@ -77,7 +77,7 @@ spec: for. type: string groupIdRef: - description: Reference to a Group to populate groupId. + description: Reference to a Group in group to populate groupId. properties: name: description: Name of the referenced object. @@ -111,7 +111,7 @@ spec: - name type: object groupIdSelector: - description: Selector for a Group to populate groupId. + description: Selector for a Group in group to populate groupId. properties: matchControllerRef: description: |- @@ -252,7 +252,7 @@ spec: for. type: string groupIdRef: - description: Reference to a Group to populate groupId. + description: Reference to a Group in group to populate groupId. properties: name: description: Name of the referenced object. @@ -286,7 +286,7 @@ spec: - name type: object groupIdSelector: - description: Selector for a Group to populate groupId. + description: Selector for a Group in group to populate groupId. properties: matchControllerRef: description: |- diff --git a/package/crds/group.keycloak.crossplane.io_permissions.yaml b/package/crds/group.keycloak.crossplane.io_permissions.yaml index fa4a753c..2ae9062d 100644 --- a/package/crds/group.keycloak.crossplane.io_permissions.yaml +++ b/package/crds/group.keycloak.crossplane.io_permissions.yaml @@ -76,7 +76,7 @@ spec: description: The id of the group. type: string groupIdRef: - description: Reference to a Group to populate groupId. + description: Reference to a Group in group to populate groupId. properties: name: description: Name of the referenced object. @@ -110,7 +110,7 @@ spec: - name type: object groupIdSelector: - description: Selector for a Group to populate groupId. + description: Selector for a Group in group to populate groupId. properties: matchControllerRef: description: |- @@ -344,7 +344,7 @@ spec: description: The id of the group. type: string groupIdRef: - description: Reference to a Group to populate groupId. + description: Reference to a Group in group to populate groupId. properties: name: description: Name of the referenced object. @@ -378,7 +378,7 @@ spec: - name type: object groupIdSelector: - description: Selector for a Group to populate groupId. + description: Selector for a Group in group to populate groupId. properties: matchControllerRef: description: |- diff --git a/package/crds/group.keycloak.crossplane.io_roles.yaml b/package/crds/group.keycloak.crossplane.io_roles.yaml index 23eecd80..a66a6c82 100644 --- a/package/crds/group.keycloak.crossplane.io_roles.yaml +++ b/package/crds/group.keycloak.crossplane.io_roles.yaml @@ -82,7 +82,7 @@ spec: for. type: string groupIdRef: - description: Reference to a Group to populate groupId. + description: Reference to a Group in group to populate groupId. properties: name: description: Name of the referenced object. @@ -116,7 +116,7 @@ spec: - name type: object groupIdSelector: - description: Selector for a Group to populate groupId. + description: Selector for a Group in group to populate groupId. properties: matchControllerRef: description: |- @@ -339,7 +339,7 @@ spec: for. type: string groupIdRef: - description: Reference to a Group to populate groupId. + description: Reference to a Group in group to populate groupId. properties: name: description: Name of the referenced object. @@ -373,7 +373,7 @@ spec: - name type: object groupIdSelector: - description: Selector for a Group to populate groupId. + description: Selector for a Group in group to populate groupId. properties: matchControllerRef: description: |- diff --git a/package/crds/openidclient.keycloak.crossplane.io_clientserviceaccountroles.yaml b/package/crds/openidclient.keycloak.crossplane.io_clientserviceaccountroles.yaml index bb2f5819..283b04f8 100644 --- a/package/crds/openidclient.keycloak.crossplane.io_clientserviceaccountroles.yaml +++ b/package/crds/openidclient.keycloak.crossplane.io_clientserviceaccountroles.yaml @@ -233,6 +233,80 @@ spec: role: description: The name of the role that is assigned. type: string + roleRef: + description: Reference to a Role in role to populate role. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + roleSelector: + description: Selector for a Role in role to populate role. + properties: + matchControllerRef: + description: |- + MatchControllerRef ensures an object with the same controller reference + as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object serviceAccountUserClientIdRef: description: Reference to a Client in openidclient to populate serviceAccountUserId. @@ -487,6 +561,80 @@ spec: role: description: The name of the role that is assigned. type: string + roleRef: + description: Reference to a Role in role to populate role. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + roleSelector: + description: Selector for a Role in role to populate role. + properties: + matchControllerRef: + description: |- + MatchControllerRef ensures an object with the same controller reference + as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object serviceAccountUserClientIdRef: description: Reference to a Client in openidclient to populate serviceAccountUserId. @@ -736,11 +884,6 @@ spec: required: - forProvider type: object - x-kubernetes-validations: - - message: spec.forProvider.role is a required parameter - rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies - || ''Update'' in self.managementPolicies) || has(self.forProvider.role) - || (has(self.initProvider) && has(self.initProvider.role))' status: description: ClientServiceAccountRoleStatus defines the observed state of ClientServiceAccountRole. diff --git a/package/crds/role.keycloak.crossplane.io_roles.yaml b/package/crds/role.keycloak.crossplane.io_roles.yaml index d8abfcc7..0ad6f004 100644 --- a/package/crds/role.keycloak.crossplane.io_roles.yaml +++ b/package/crds/role.keycloak.crossplane.io_roles.yaml @@ -168,7 +168,7 @@ spec: type: array x-kubernetes-list-type: set compositeRolesRefs: - description: References to Role to populate compositeRoles. + description: References to Role in role to populate compositeRoles. items: description: A Reference to a named object. properties: @@ -205,7 +205,7 @@ spec: type: object type: array compositeRolesSelector: - description: Selector for a list of Role to populate compositeRoles. + description: Selector for a list of Role in role to populate compositeRoles. properties: matchControllerRef: description: |- @@ -437,7 +437,7 @@ spec: type: array x-kubernetes-list-type: set compositeRolesRefs: - description: References to Role to populate compositeRoles. + description: References to Role in role to populate compositeRoles. items: description: A Reference to a named object. properties: @@ -474,7 +474,7 @@ spec: type: object type: array compositeRolesSelector: - description: Selector for a list of Role to populate compositeRoles. + description: Selector for a list of Role in role to populate compositeRoles. properties: matchControllerRef: description: |- diff --git a/package/crds/user.keycloak.crossplane.io_groups.yaml b/package/crds/user.keycloak.crossplane.io_groups.yaml index 9249f6b5..23e2c8ba 100644 --- a/package/crds/user.keycloak.crossplane.io_groups.yaml +++ b/package/crds/user.keycloak.crossplane.io_groups.yaml @@ -84,7 +84,7 @@ spec: type: array x-kubernetes-list-type: set groupIdsRefs: - description: References to Group in group to populate groupIds. + description: References to to populate groupIds. items: description: A Reference to a named object. properties: @@ -121,8 +121,7 @@ spec: type: object type: array groupIdsSelector: - description: Selector for a list of Group in group to populate - groupIds. + description: Selector for a list of to populate groupIds. properties: matchControllerRef: description: |- @@ -243,7 +242,7 @@ spec: for. type: string userIdRef: - description: Reference to a User to populate userId. + description: Reference to a User in user to populate userId. properties: name: description: Name of the referenced object. @@ -277,7 +276,7 @@ spec: - name type: object userIdSelector: - description: Selector for a User to populate userId. + description: Selector for a User in user to populate userId. properties: matchControllerRef: description: |- @@ -342,7 +341,7 @@ spec: type: array x-kubernetes-list-type: set groupIdsRefs: - description: References to Group in group to populate groupIds. + description: References to to populate groupIds. items: description: A Reference to a named object. properties: @@ -379,8 +378,7 @@ spec: type: object type: array groupIdsSelector: - description: Selector for a list of Group in group to populate - groupIds. + description: Selector for a list of to populate groupIds. properties: matchControllerRef: description: |- @@ -501,7 +499,7 @@ spec: for. type: string userIdRef: - description: Reference to a User to populate userId. + description: Reference to a User in user to populate userId. properties: name: description: Name of the referenced object. @@ -535,7 +533,7 @@ spec: - name type: object userIdSelector: - description: Selector for a User to populate userId. + description: Selector for a User in user to populate userId. properties: matchControllerRef: description: |- diff --git a/package/crds/user.keycloak.crossplane.io_roles.yaml b/package/crds/user.keycloak.crossplane.io_roles.yaml index 2b40a1b1..455ea1b1 100644 --- a/package/crds/user.keycloak.crossplane.io_roles.yaml +++ b/package/crds/user.keycloak.crossplane.io_roles.yaml @@ -242,7 +242,7 @@ spec: for. type: string userIdRef: - description: Reference to a User to populate userId. + description: Reference to a User in user to populate userId. properties: name: description: Name of the referenced object. @@ -276,7 +276,7 @@ spec: - name type: object userIdSelector: - description: Selector for a User to populate userId. + description: Selector for a User in user to populate userId. properties: matchControllerRef: description: |- @@ -499,7 +499,7 @@ spec: for. type: string userIdRef: - description: Reference to a User to populate userId. + description: Reference to a User in user to populate userId. properties: name: description: Name of the referenced object. @@ -533,7 +533,7 @@ spec: - name type: object userIdSelector: - description: Selector for a User to populate userId. + description: Selector for a User in user to populate userId. properties: matchControllerRef: description: |-