From 421d108d7e39bee67fd84037514928e95343549d Mon Sep 17 00:00:00 2001 From: Breee Date: Sun, 7 Jul 2024 16:57:55 +0200 Subject: [PATCH] feat(resolvers): add transformer for non-cross-reference resolvers --- .../v1alpha1/zz_generated.resolvers.go | 718 +++++----- .../client/v1alpha1/zz_generated.resolvers.go | 291 ++-- .../v1alpha1/zz_generated.conversion_hubs.go | 10 + .../default/v1alpha1/zz_generated.deepcopy.go | 226 +++ apis/default/v1alpha1/zz_generated.managed.go | 68 + .../v1alpha1/zz_generated.managedlist.go | 17 + .../v1alpha1/zz_generated.resolvers.go | 68 + apis/default/v1alpha1/zz_groupversion_info.go | 32 + .../v1alpha1/zz_roles_terraformed.go | 0 .../v1alpha1/zz_roles_types.go | 25 +- .../v1alpha1/zz_generated.conversion_hubs.go | 3 - .../v1alpha1/zz_generated.deepcopy.go | 236 ---- .../defaults/v1alpha1/zz_generated.managed.go | 60 - .../v1alpha1/zz_generated.managedlist.go | 9 - .../v1alpha1/zz_generated.resolvers.go | 186 +-- apis/generate.go | 4 + apis/group/v1alpha1/zz_generated.resolvers.go | 467 ++++--- apis/group/v1alpha1/zz_group_types.go | 12 +- apis/group/v1alpha1/zz_memberships_types.go | 12 +- apis/group/v1alpha1/zz_permissions_types.go | 12 +- apis/group/v1alpha1/zz_roles_types.go | 12 +- .../v1alpha1/zz_generated.resolvers.go | 57 +- apis/ldap/v1alpha1/zz_generated.resolvers.go | 1233 ++++++++++------- apis/oidc/v1alpha1/zz_generated.resolvers.go | 151 +- .../zz_clientserviceaccountrole_types.go | 25 +- .../v1alpha1/zz_generated.deepcopy.go | 20 + .../v1alpha1/zz_generated.resolvers.go | 896 +++++++----- .../v1alpha1/zz_generated.resolvers.go | 150 +- apis/realm/v1alpha1/zz_generated.resolvers.go | 102 +- apis/role/v1alpha1/zz_generated.resolvers.go | 149 +- apis/role/v1alpha1/zz_role_types.go | 12 +- apis/saml/v1alpha1/zz_generated.resolvers.go | 57 +- .../v1alpha1/zz_generated.resolvers.go | 265 ++-- apis/user/v1alpha1/zz_generated.resolvers.go | 386 +++--- apis/zz_register.go | 2 + cmd/provider/main.go | 2 + config/defaults/config.go | 9 - config/group/config.go | 8 +- config/identityprovider/config.go | 2 +- config/mapper/config.go | 2 +- config/oidc/config.go | 2 +- config/openidclient/config.go | 22 + config/provider.go | 16 +- config/role/config.go | 2 +- config/saml/config.go | 2 +- dev/bugs/import.yaml | 15 + .../{defaults => default}/v1alpha1/roles.yaml | 10 +- .../v1alpha1/clientserviceaccountrole.yaml | 4 +- internal/apis/scheme.go | 39 + .../roles/zz_controller.go | 2 +- internal/controller/zz_setup.go | 4 +- ...default.keycloak.crossplane.io_roles.yaml} | 163 +-- .../group.keycloak.crossplane.io_groups.yaml | 8 +- ...up.keycloak.crossplane.io_memberships.yaml | 8 +- ...up.keycloak.crossplane.io_permissions.yaml | 8 +- .../group.keycloak.crossplane.io_roles.yaml | 8 +- ...ossplane.io_clientserviceaccountroles.yaml | 153 +- .../role.keycloak.crossplane.io_roles.yaml | 8 +- 58 files changed, 3680 insertions(+), 2790 deletions(-) create mode 100755 apis/default/v1alpha1/zz_generated.conversion_hubs.go create mode 100644 apis/default/v1alpha1/zz_generated.deepcopy.go create mode 100644 apis/default/v1alpha1/zz_generated.managed.go create mode 100644 apis/default/v1alpha1/zz_generated.managedlist.go create mode 100644 apis/default/v1alpha1/zz_generated.resolvers.go create mode 100755 apis/default/v1alpha1/zz_groupversion_info.go rename apis/{defaults => default}/v1alpha1/zz_roles_terraformed.go (100%) rename apis/{defaults => default}/v1alpha1/zz_roles_types.go (78%) create mode 100644 dev/bugs/import.yaml rename examples-generated/{defaults => default}/v1alpha1/roles.yaml (68%) create mode 100644 internal/apis/scheme.go rename internal/controller/{defaults => default}/roles/zz_controller.go (99%) rename package/crds/{defaults.keycloak.crossplane.io_roles.yaml => default.keycloak.crossplane.io_roles.yaml} (74%) 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/default/v1alpha1/zz_generated.conversion_hubs.go b/apis/default/v1alpha1/zz_generated.conversion_hubs.go new file mode 100755 index 00000000..4f514688 --- /dev/null +++ b/apis/default/v1alpha1/zz_generated.conversion_hubs.go @@ -0,0 +1,10 @@ +/* +Copyright 2022 Upbound Inc. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package v1alpha1 + +// Hub marks this type as a conversion hub. +func (tr *Roles) Hub() {} diff --git a/apis/default/v1alpha1/zz_generated.deepcopy.go b/apis/default/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000..3a3b41d0 --- /dev/null +++ b/apis/default/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,226 @@ +//go:build !ignore_autogenerated + +/* +Copyright 2022 Upbound Inc. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "github.com/crossplane/crossplane-runtime/apis/common/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Roles) DeepCopyInto(out *Roles) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Roles. +func (in *Roles) DeepCopy() *Roles { + if in == nil { + return nil + } + out := new(Roles) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Roles) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolesInitParameters) DeepCopyInto(out *RolesInitParameters) { + *out = *in + if in.DefaultRoles != nil { + in, out := &in.DefaultRoles, &out.DefaultRoles + *out = make([]*string, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(string) + **out = **in + } + } + } + if in.RealmID != nil { + in, out := &in.RealmID, &out.RealmID + *out = new(string) + **out = **in + } + if in.RealmIDRef != nil { + in, out := &in.RealmIDRef, &out.RealmIDRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.RealmIDSelector != nil { + in, out := &in.RealmIDSelector, &out.RealmIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolesInitParameters. +func (in *RolesInitParameters) DeepCopy() *RolesInitParameters { + if in == nil { + return nil + } + out := new(RolesInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolesList) DeepCopyInto(out *RolesList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Roles, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolesList. +func (in *RolesList) DeepCopy() *RolesList { + if in == nil { + return nil + } + out := new(RolesList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RolesList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolesObservation) DeepCopyInto(out *RolesObservation) { + *out = *in + if in.DefaultRoles != nil { + in, out := &in.DefaultRoles, &out.DefaultRoles + *out = make([]*string, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(string) + **out = **in + } + } + } + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.RealmID != nil { + in, out := &in.RealmID, &out.RealmID + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolesObservation. +func (in *RolesObservation) DeepCopy() *RolesObservation { + if in == nil { + return nil + } + out := new(RolesObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolesParameters) DeepCopyInto(out *RolesParameters) { + *out = *in + if in.DefaultRoles != nil { + in, out := &in.DefaultRoles, &out.DefaultRoles + *out = make([]*string, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(string) + **out = **in + } + } + } + if in.RealmID != nil { + in, out := &in.RealmID, &out.RealmID + *out = new(string) + **out = **in + } + if in.RealmIDRef != nil { + in, out := &in.RealmIDRef, &out.RealmIDRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.RealmIDSelector != nil { + in, out := &in.RealmIDSelector, &out.RealmIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolesParameters. +func (in *RolesParameters) DeepCopy() *RolesParameters { + if in == nil { + return nil + } + out := new(RolesParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolesSpec) DeepCopyInto(out *RolesSpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + in.ForProvider.DeepCopyInto(&out.ForProvider) + in.InitProvider.DeepCopyInto(&out.InitProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolesSpec. +func (in *RolesSpec) DeepCopy() *RolesSpec { + if in == nil { + return nil + } + out := new(RolesSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolesStatus) DeepCopyInto(out *RolesStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolesStatus. +func (in *RolesStatus) DeepCopy() *RolesStatus { + if in == nil { + return nil + } + out := new(RolesStatus) + in.DeepCopyInto(out) + return out +} diff --git a/apis/default/v1alpha1/zz_generated.managed.go b/apis/default/v1alpha1/zz_generated.managed.go new file mode 100644 index 00000000..6d163153 --- /dev/null +++ b/apis/default/v1alpha1/zz_generated.managed.go @@ -0,0 +1,68 @@ +/* +Copyright 2022 Upbound Inc. +*/ +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + +// GetCondition of this Roles. +func (mg *Roles) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this Roles. +func (mg *Roles) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this Roles. +func (mg *Roles) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this Roles. +func (mg *Roles) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +// GetPublishConnectionDetailsTo of this Roles. +func (mg *Roles) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this Roles. +func (mg *Roles) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this Roles. +func (mg *Roles) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this Roles. +func (mg *Roles) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this Roles. +func (mg *Roles) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this Roles. +func (mg *Roles) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +// SetPublishConnectionDetailsTo of this Roles. +func (mg *Roles) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this Roles. +func (mg *Roles) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} diff --git a/apis/default/v1alpha1/zz_generated.managedlist.go b/apis/default/v1alpha1/zz_generated.managedlist.go new file mode 100644 index 00000000..629c2d9a --- /dev/null +++ b/apis/default/v1alpha1/zz_generated.managedlist.go @@ -0,0 +1,17 @@ +/* +Copyright 2022 Upbound Inc. +*/ +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import resource "github.com/crossplane/crossplane-runtime/pkg/resource" + +// GetItems of this RolesList. +func (l *RolesList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} diff --git a/apis/default/v1alpha1/zz_generated.resolvers.go b/apis/default/v1alpha1/zz_generated.resolvers.go new file mode 100644 index 00000000..2c778673 --- /dev/null +++ b/apis/default/v1alpha1/zz_generated.resolvers.go @@ -0,0 +1,68 @@ +/* +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 Roles. + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" +) + +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 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: 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: 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 + + return nil +} diff --git a/apis/default/v1alpha1/zz_groupversion_info.go b/apis/default/v1alpha1/zz_groupversion_info.go new file mode 100755 index 00000000..951aab7e --- /dev/null +++ b/apis/default/v1alpha1/zz_groupversion_info.go @@ -0,0 +1,32 @@ +/* +Copyright 2022 Upbound Inc. +*/ + +// Code generated by upjet. DO NOT EDIT. + +// +kubebuilder:object:generate=true +// +groupName=default.keycloak.crossplane.io +// +versionName=v1alpha1 +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +// Package type metadata. +const ( + CRDGroup = "default.keycloak.crossplane.io" + CRDVersion = "v1alpha1" +) + +var ( + // CRDGroupVersion is the API Group Version used to register the objects + CRDGroupVersion = schema.GroupVersion{Group: CRDGroup, Version: CRDVersion} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: CRDGroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/apis/defaults/v1alpha1/zz_roles_terraformed.go b/apis/default/v1alpha1/zz_roles_terraformed.go similarity index 100% rename from apis/defaults/v1alpha1/zz_roles_terraformed.go rename to apis/default/v1alpha1/zz_roles_terraformed.go diff --git a/apis/defaults/v1alpha1/zz_roles_types.go b/apis/default/v1alpha1/zz_roles_types.go similarity index 78% rename from apis/defaults/v1alpha1/zz_roles_types.go rename to apis/default/v1alpha1/zz_roles_types.go index 985f0ec7..e4df9afe 100755 --- a/apis/defaults/v1alpha1/zz_roles_types.go +++ b/apis/default/v1alpha1/zz_roles_types.go @@ -17,19 +17,9 @@ type RolesInitParameters struct { // Realm level roles assigned to new users by default. // Realm level roles assigned to new users. - // +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) // +listType=set DefaultRoles []*string `json:"defaultRoles,omitempty" tf:"default_roles,omitempty"` - // References to Role in role to populate defaultRoles. - // +kubebuilder:validation:Optional - DefaultRolesRefs []v1.Reference `json:"defaultRolesRefs,omitempty" tf:"-"` - - // Selector for a list of Role in role to populate defaultRoles. - // +kubebuilder:validation:Optional - DefaultRolesSelector *v1.Selector `json:"defaultRolesSelector,omitempty" tf:"-"` - // The realm this role exists within. // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1.Realm RealmID *string `json:"realmId,omitempty" tf:"realm_id,omitempty"` @@ -60,20 +50,10 @@ type RolesParameters struct { // Realm level roles assigned to new users by default. // Realm level roles assigned to new users. - // +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 // +listType=set DefaultRoles []*string `json:"defaultRoles,omitempty" tf:"default_roles,omitempty"` - // References to Role in role to populate defaultRoles. - // +kubebuilder:validation:Optional - DefaultRolesRefs []v1.Reference `json:"defaultRolesRefs,omitempty" tf:"-"` - - // Selector for a list of Role in role to populate defaultRoles. - // +kubebuilder:validation:Optional - DefaultRolesSelector *v1.Selector `json:"defaultRolesSelector,omitempty" tf:"-"` - // The realm this role exists within. // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1.Realm // +kubebuilder:validation:Optional @@ -124,8 +104,9 @@ type RolesStatus struct { type Roles struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec RolesSpec `json:"spec"` - Status RolesStatus `json:"status,omitempty"` + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.defaultRoles) || (has(self.initProvider) && has(self.initProvider.defaultRoles))",message="spec.forProvider.defaultRoles is a required parameter" + Spec RolesSpec `json:"spec"` + Status RolesStatus `json:"status,omitempty"` } // +kubebuilder:object:root=true diff --git a/apis/defaults/v1alpha1/zz_generated.conversion_hubs.go b/apis/defaults/v1alpha1/zz_generated.conversion_hubs.go index f2b87829..1db8e363 100755 --- a/apis/defaults/v1alpha1/zz_generated.conversion_hubs.go +++ b/apis/defaults/v1alpha1/zz_generated.conversion_hubs.go @@ -8,6 +8,3 @@ package v1alpha1 // Hub marks this type as a conversion hub. func (tr *DefaultGroups) Hub() {} - -// Hub marks this type as a conversion hub. -func (tr *Roles) Hub() {} diff --git a/apis/defaults/v1alpha1/zz_generated.deepcopy.go b/apis/defaults/v1alpha1/zz_generated.deepcopy.go index 3c1a5fda..d0629d2a 100644 --- a/apis/defaults/v1alpha1/zz_generated.deepcopy.go +++ b/apis/defaults/v1alpha1/zz_generated.deepcopy.go @@ -248,239 +248,3 @@ func (in *DefaultGroupsStatus) DeepCopy() *DefaultGroupsStatus { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Roles) DeepCopyInto(out *Roles) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Roles. -func (in *Roles) DeepCopy() *Roles { - if in == nil { - return nil - } - out := new(Roles) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Roles) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RolesInitParameters) DeepCopyInto(out *RolesInitParameters) { - *out = *in - if in.DefaultRoles != nil { - in, out := &in.DefaultRoles, &out.DefaultRoles - *out = make([]*string, len(*in)) - for i := range *in { - if (*in)[i] != nil { - in, out := &(*in)[i], &(*out)[i] - *out = new(string) - **out = **in - } - } - } - if in.DefaultRolesRefs != nil { - in, out := &in.DefaultRolesRefs, &out.DefaultRolesRefs - *out = make([]v1.Reference, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.DefaultRolesSelector != nil { - in, out := &in.DefaultRolesSelector, &out.DefaultRolesSelector - *out = new(v1.Selector) - (*in).DeepCopyInto(*out) - } - if in.RealmID != nil { - in, out := &in.RealmID, &out.RealmID - *out = new(string) - **out = **in - } - if in.RealmIDRef != nil { - in, out := &in.RealmIDRef, &out.RealmIDRef - *out = new(v1.Reference) - (*in).DeepCopyInto(*out) - } - if in.RealmIDSelector != nil { - in, out := &in.RealmIDSelector, &out.RealmIDSelector - *out = new(v1.Selector) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolesInitParameters. -func (in *RolesInitParameters) DeepCopy() *RolesInitParameters { - if in == nil { - return nil - } - out := new(RolesInitParameters) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RolesList) DeepCopyInto(out *RolesList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Roles, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolesList. -func (in *RolesList) DeepCopy() *RolesList { - if in == nil { - return nil - } - out := new(RolesList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *RolesList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RolesObservation) DeepCopyInto(out *RolesObservation) { - *out = *in - if in.DefaultRoles != nil { - in, out := &in.DefaultRoles, &out.DefaultRoles - *out = make([]*string, len(*in)) - for i := range *in { - if (*in)[i] != nil { - in, out := &(*in)[i], &(*out)[i] - *out = new(string) - **out = **in - } - } - } - if in.ID != nil { - in, out := &in.ID, &out.ID - *out = new(string) - **out = **in - } - if in.RealmID != nil { - in, out := &in.RealmID, &out.RealmID - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolesObservation. -func (in *RolesObservation) DeepCopy() *RolesObservation { - if in == nil { - return nil - } - out := new(RolesObservation) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RolesParameters) DeepCopyInto(out *RolesParameters) { - *out = *in - if in.DefaultRoles != nil { - in, out := &in.DefaultRoles, &out.DefaultRoles - *out = make([]*string, len(*in)) - for i := range *in { - if (*in)[i] != nil { - in, out := &(*in)[i], &(*out)[i] - *out = new(string) - **out = **in - } - } - } - if in.DefaultRolesRefs != nil { - in, out := &in.DefaultRolesRefs, &out.DefaultRolesRefs - *out = make([]v1.Reference, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.DefaultRolesSelector != nil { - in, out := &in.DefaultRolesSelector, &out.DefaultRolesSelector - *out = new(v1.Selector) - (*in).DeepCopyInto(*out) - } - if in.RealmID != nil { - in, out := &in.RealmID, &out.RealmID - *out = new(string) - **out = **in - } - if in.RealmIDRef != nil { - in, out := &in.RealmIDRef, &out.RealmIDRef - *out = new(v1.Reference) - (*in).DeepCopyInto(*out) - } - if in.RealmIDSelector != nil { - in, out := &in.RealmIDSelector, &out.RealmIDSelector - *out = new(v1.Selector) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolesParameters. -func (in *RolesParameters) DeepCopy() *RolesParameters { - if in == nil { - return nil - } - out := new(RolesParameters) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RolesSpec) DeepCopyInto(out *RolesSpec) { - *out = *in - in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) - in.ForProvider.DeepCopyInto(&out.ForProvider) - in.InitProvider.DeepCopyInto(&out.InitProvider) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolesSpec. -func (in *RolesSpec) DeepCopy() *RolesSpec { - if in == nil { - return nil - } - out := new(RolesSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RolesStatus) DeepCopyInto(out *RolesStatus) { - *out = *in - in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) - in.AtProvider.DeepCopyInto(&out.AtProvider) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolesStatus. -func (in *RolesStatus) DeepCopy() *RolesStatus { - if in == nil { - return nil - } - out := new(RolesStatus) - in.DeepCopyInto(out) - return out -} diff --git a/apis/defaults/v1alpha1/zz_generated.managed.go b/apis/defaults/v1alpha1/zz_generated.managed.go index e929f6ca..8beccec3 100644 --- a/apis/defaults/v1alpha1/zz_generated.managed.go +++ b/apis/defaults/v1alpha1/zz_generated.managed.go @@ -66,63 +66,3 @@ func (mg *DefaultGroups) SetPublishConnectionDetailsTo(r *xpv1.PublishConnection func (mg *DefaultGroups) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { mg.Spec.WriteConnectionSecretToReference = r } - -// GetCondition of this Roles. -func (mg *Roles) GetCondition(ct xpv1.ConditionType) xpv1.Condition { - return mg.Status.GetCondition(ct) -} - -// GetDeletionPolicy of this Roles. -func (mg *Roles) GetDeletionPolicy() xpv1.DeletionPolicy { - return mg.Spec.DeletionPolicy -} - -// GetManagementPolicies of this Roles. -func (mg *Roles) GetManagementPolicies() xpv1.ManagementPolicies { - return mg.Spec.ManagementPolicies -} - -// GetProviderConfigReference of this Roles. -func (mg *Roles) GetProviderConfigReference() *xpv1.Reference { - return mg.Spec.ProviderConfigReference -} - -// GetPublishConnectionDetailsTo of this Roles. -func (mg *Roles) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { - return mg.Spec.PublishConnectionDetailsTo -} - -// GetWriteConnectionSecretToReference of this Roles. -func (mg *Roles) GetWriteConnectionSecretToReference() *xpv1.SecretReference { - return mg.Spec.WriteConnectionSecretToReference -} - -// SetConditions of this Roles. -func (mg *Roles) SetConditions(c ...xpv1.Condition) { - mg.Status.SetConditions(c...) -} - -// SetDeletionPolicy of this Roles. -func (mg *Roles) SetDeletionPolicy(r xpv1.DeletionPolicy) { - mg.Spec.DeletionPolicy = r -} - -// SetManagementPolicies of this Roles. -func (mg *Roles) SetManagementPolicies(r xpv1.ManagementPolicies) { - mg.Spec.ManagementPolicies = r -} - -// SetProviderConfigReference of this Roles. -func (mg *Roles) SetProviderConfigReference(r *xpv1.Reference) { - mg.Spec.ProviderConfigReference = r -} - -// SetPublishConnectionDetailsTo of this Roles. -func (mg *Roles) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { - mg.Spec.PublishConnectionDetailsTo = r -} - -// SetWriteConnectionSecretToReference of this Roles. -func (mg *Roles) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { - mg.Spec.WriteConnectionSecretToReference = r -} diff --git a/apis/defaults/v1alpha1/zz_generated.managedlist.go b/apis/defaults/v1alpha1/zz_generated.managedlist.go index 7d923f3a..61ef9980 100644 --- a/apis/defaults/v1alpha1/zz_generated.managedlist.go +++ b/apis/defaults/v1alpha1/zz_generated.managedlist.go @@ -15,12 +15,3 @@ func (l *DefaultGroupsList) GetItems() []resource.Managed { } return items } - -// GetItems of this RolesList. -func (l *RolesList) GetItems() []resource.Managed { - items := make([]resource.Managed, len(l.Items)) - for i := range l.Items { - items[i] = &l.Items[i] - } - return items -} diff --git a/apis/defaults/v1alpha1/zz_generated.resolvers.go b/apis/defaults/v1alpha1/zz_generated.resolvers.go index 6badcf93..fd00c1b7 100644 --- a/apis/defaults/v1alpha1/zz_generated.resolvers.go +++ b/apis/defaults/v1alpha1/zz_generated.resolvers.go @@ -2,161 +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" + + 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{}, - }, - }) - if err != nil { - return errors.Wrap(err, "mg.Spec.InitProvider.RealmID") + { + 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}, + }) } - mg.Spec.InitProvider.RealmID = reference.ToPtrValue(rsp.ResolvedValue) - mg.Spec.InitProvider.RealmIDRef = rsp.ResolvedReference - - return nil -} - -// ResolveReferences of this Roles. -func (mg *Roles) ResolveReferences(ctx context.Context, c client.Reader) error { - 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{}, - }, - }) - 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{}, - }, - }) - 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{}, - }, - }) - 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{}, - }, - }) 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..290e9a99 100644 --- a/apis/user/v1alpha1/zz_generated.resolvers.go +++ b/apis/user/v1alpha1/zz_generated.resolvers.go @@ -2,118 +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/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("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: &v1alpha1.GroupList{}, - Managed: &v1alpha1.Group{}, - }, - }) + 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 + { + 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("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("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: &v1alpha1.GroupList{}, - Managed: &v1alpha1.Group{}, - }, - }) + 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 + { + 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("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 +147,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 +197,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 +324,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/zz_register.go b/apis/zz_register.go index fe19eac8..36dc5da1 100755 --- a/apis/zz_register.go +++ b/apis/zz_register.go @@ -12,6 +12,7 @@ import ( v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/authenticationflow/v1alpha1" v1alpha1client "github.com/crossplane-contrib/provider-keycloak/apis/client/v1alpha1" + v1alpha1default "github.com/crossplane-contrib/provider-keycloak/apis/default/v1alpha1" v1alpha1defaults "github.com/crossplane-contrib/provider-keycloak/apis/defaults/v1alpha1" v1alpha1group "github.com/crossplane-contrib/provider-keycloak/apis/group/v1alpha1" v1alpha1identityprovider "github.com/crossplane-contrib/provider-keycloak/apis/identityprovider/v1alpha1" @@ -33,6 +34,7 @@ func init() { AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme, v1alpha1client.SchemeBuilder.AddToScheme, + v1alpha1default.SchemeBuilder.AddToScheme, v1alpha1defaults.SchemeBuilder.AddToScheme, v1alpha1group.SchemeBuilder.AddToScheme, v1alpha1identityprovider.SchemeBuilder.AddToScheme, diff --git a/cmd/provider/main.go b/cmd/provider/main.go index 7aa0ce9e..bae30639 100644 --- a/cmd/provider/main.go +++ b/cmd/provider/main.go @@ -32,6 +32,7 @@ import ( "github.com/crossplane-contrib/provider-keycloak/apis" "github.com/crossplane-contrib/provider-keycloak/apis/v1alpha1" "github.com/crossplane-contrib/provider-keycloak/config" + resolverapis "github.com/crossplane-contrib/provider-keycloak/internal/apis" "github.com/crossplane-contrib/provider-keycloak/internal/clients" "github.com/crossplane-contrib/provider-keycloak/internal/controller" "github.com/crossplane-contrib/provider-keycloak/internal/features" @@ -88,6 +89,7 @@ func main() { metrics.Registry.MustRegister(metricRecorder) metrics.Registry.MustRegister(stateMetrics) kingpin.FatalIfError(apis.AddToScheme(mgr.GetScheme()), "Cannot add keycloak APIs to scheme") + kingpin.FatalIfError(resolverapis.BuildScheme(apis.AddToSchemes), "Cannot register the keycloak APIs with the API resolver's runtime scheme") provider, err := config.GetProvider(false) kingpin.FatalIfError(err, "Cannot get provider configuration") diff --git a/config/defaults/config.go b/config/defaults/config.go index eb1792b4..39a575de 100644 --- a/config/defaults/config.go +++ b/config/defaults/config.go @@ -5,15 +5,6 @@ import "github.com/crossplane/upjet/pkg/config" // Configure configures individual resources by adding custom ResourceConfigurators. func Configure(p *config.Provider) { - p.AddResourceConfigurator("keycloak_default_roles", func(r *config.Resource) { - r.ShortGroup = "defaults" - r.References["default_roles"] = config.Reference{ - Type: "github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1.Role", - Extractor: `github.com/crossplane/upjet/pkg/resource.ExtractParamPath("name", false)`, - } - - }) - p.AddResourceConfigurator("keycloak_default_groups", func(r *config.Resource) { // We need to override the default group that upjet generated for // this resource, which would be "github" diff --git a/config/group/config.go b/config/group/config.go index 6420542a..32bc659b 100644 --- a/config/group/config.go +++ b/config/group/config.go @@ -9,14 +9,14 @@ func Configure(p *config.Provider) { r.ShortGroup = "group" r.References["parent_id"] = config.Reference{ - Type: "Group", + TerraformName: "keycloak_group", } }) p.AddResourceConfigurator("keycloak_group_memberships", func(r *config.Resource) { // We need to override the default group that upjet generated for r.ShortGroup = "group" r.References["group_id"] = config.Reference{ - Type: "Group", + TerraformName: "keycloak_group", } }) @@ -24,14 +24,14 @@ func Configure(p *config.Provider) { // We need to override the default group that upjet generated for r.ShortGroup = "group" r.References["group_id"] = config.Reference{ - Type: "Group", + TerraformName: "keycloak_group", } }) p.AddResourceConfigurator("keycloak_group_permissions", func(r *config.Resource) { // We need to override the default group that upjet generated for r.ShortGroup = "group" r.References["group_id"] = config.Reference{ - Type: "Group", + TerraformName: "keycloak_group", } }) } diff --git a/config/identityprovider/config.go b/config/identityprovider/config.go index 2ff82b1e..2d1ccac7 100644 --- a/config/identityprovider/config.go +++ b/config/identityprovider/config.go @@ -12,7 +12,7 @@ func Configure(p *config.Provider) { p.AddResourceConfigurator("keycloak_custom_identity_provider_mapper", func(r *config.Resource) { r.ShortGroup = Group r.References["realm"] = config.Reference{ - Type: "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1.Realm", + TerraformName: "keycloak_realm", } }) } diff --git a/config/mapper/config.go b/config/mapper/config.go index acb08a42..cf4b70ce 100644 --- a/config/mapper/config.go +++ b/config/mapper/config.go @@ -14,7 +14,7 @@ func Configure(p *config.Provider) { p.AddResourceConfigurator("keycloak_generic_role_mapper", func(r *config.Resource) { r.ShortGroup = "client" r.References["role_id"] = config.Reference{ - Type: "github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1.Role", + TerraformName: "keycloak_role", } }) diff --git a/config/oidc/config.go b/config/oidc/config.go index 07cbe593..41118bcb 100644 --- a/config/oidc/config.go +++ b/config/oidc/config.go @@ -11,7 +11,7 @@ func Configure(p *config.Provider) { // We need to override the default group that upjet generated for r.ShortGroup = "oidc" r.References["realm"] = config.Reference{ - Type: "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1.Realm", + TerraformName: "keycloak_realm", } r.References["first_broker_login_flow_alias"] = config.Reference{ Type: "github.com/crossplane-contrib/provider-keycloak/apis/authenticationflow/v1alpha1.Flow", diff --git a/config/openidclient/config.go b/config/openidclient/config.go index 94278684..6d1f6096 100644 --- a/config/openidclient/config.go +++ b/config/openidclient/config.go @@ -1,6 +1,7 @@ package openidclient import ( + "github.com/crossplane-contrib/provider-keycloak/config/common" "github.com/crossplane/upjet/pkg/config" ) @@ -36,6 +37,27 @@ func Configure(p *config.Provider) { p.AddResourceConfigurator("keycloak_openid_client_service_account_role", func(r *config.Resource) { r.ShortGroup = Group + // The id of the client that provides the role. + r.References["client_id"] = config.Reference{ + + TerraformName: "keycloak_openid_client", + Extractor: common.PathUUIDExtractor, + } + // The id of the service account that is assigned the role (the service account of the client that "consumes" the role). + r.References["service_account_user_id"] = config.Reference{ + TerraformName: "keycloak_openid_client", + Extractor: common.PathServiceAccountRoleIDExtractor, + RefFieldName: "ServiceAccountUserClientIDRef", + SelectorFieldName: "ServiceAccountUserClientIDSelector", + } + // The name of the role that is assigned. + r.References["role"] = config.Reference{ + TerraformName: "keycloak_role", + Extractor: `github.com/crossplane/upjet/pkg/resource.ExtractParamPath("name", false)`, + } + r.LateInitializer = config.LateInitializer{ + IgnoredFields: []string{"service_account_user_id"}, + } }) diff --git a/config/provider.go b/config/provider.go index 13364018..c515ffc6 100644 --- a/config/provider.go +++ b/config/provider.go @@ -128,16 +128,16 @@ func KnownReferencers() config.ResourceOption { //nolint:gocyclo switch k { case "realm_id": r.References["realm_id"] = config.Reference{ - Type: "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1.Realm", + TerraformName: "keycloak_realm", } case "client_id": r.References["client_id"] = config.Reference{ - Type: "github.com/crossplane-contrib/provider-keycloak/apis/openidclient/v1alpha1.Client", - Extractor: common.PathUUIDExtractor, + TerraformName: "keycloak_openid_client", + Extractor: common.PathUUIDExtractor, } case "service_account_user_id": r.References["service_account_user_id"] = config.Reference{ - Type: "github.com/crossplane-contrib/provider-keycloak/apis/openidclient/v1alpha1.Client", + TerraformName: "keycloak_openid_client", Extractor: common.PathServiceAccountRoleIDExtractor, RefFieldName: "ServiceAccountUserClientIDRef", SelectorFieldName: "ServiceAccountUserClientIDSelector", @@ -148,14 +148,14 @@ func KnownReferencers() config.ResourceOption { //nolint:gocyclo case "role_ids": r.References["role_ids"] = config.Reference{ - Type: "github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1.Role", - Extractor: common.PathUUIDExtractor, + TerraformName: "keycloak_role", + Extractor: common.PathUUIDExtractor, } case "role_id": r.References["role_id"] = config.Reference{ - Type: "github.com/crossplane-contrib/provider-keycloak/apis/role/v1alpha1.Role", - Extractor: common.PathUUIDExtractor, + TerraformName: "keycloak_role", + Extractor: common.PathUUIDExtractor, } } diff --git a/config/role/config.go b/config/role/config.go index ad37b523..8966cac1 100644 --- a/config/role/config.go +++ b/config/role/config.go @@ -9,7 +9,7 @@ func Configure(p *config.Provider) { // this resource, which would be "github" r.ShortGroup = "role" r.References["composite_roles"] = config.Reference{ - Type: "Role", + TerraformName: "keycloak_role", } }) } diff --git a/config/saml/config.go b/config/saml/config.go index 71c855ec..cf09c35e 100644 --- a/config/saml/config.go +++ b/config/saml/config.go @@ -11,7 +11,7 @@ func Configure(p *config.Provider) { // We need to override the default group that upjet generated for r.ShortGroup = "saml" r.References["realm"] = config.Reference{ - Type: "github.com/crossplane-contrib/provider-keycloak/apis/realm/v1alpha1.Realm", + TerraformName: "keycloak_realm", } }) p.AddResourceConfigurator("keycloak_saml_client", func(r *config.Resource) { 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/defaults/v1alpha1/roles.yaml b/examples-generated/default/v1alpha1/roles.yaml similarity index 68% rename from examples-generated/defaults/v1alpha1/roles.yaml rename to examples-generated/default/v1alpha1/roles.yaml index 662300f6..85af917a 100644 --- a/examples-generated/defaults/v1alpha1/roles.yaml +++ b/examples-generated/default/v1alpha1/roles.yaml @@ -1,15 +1,15 @@ -apiVersion: defaults.keycloak.crossplane.io/v1alpha1 +apiVersion: default.keycloak.crossplane.io/v1alpha1 kind: Roles metadata: annotations: - meta.upbound.io/example-id: defaults/v1alpha1/roles + meta.upbound.io/example-id: default/v1alpha1/roles labels: testing.upbound.io/example-name: default_roles name: default-roles spec: forProvider: - defaultRolesRefs: - - name: example + defaultRoles: + - uma_authorization realmIdSelector: matchLabels: testing.upbound.io/example-name: realm @@ -20,7 +20,7 @@ apiVersion: realm.keycloak.crossplane.io/v1alpha1 kind: Realm metadata: annotations: - meta.upbound.io/example-id: defaults/v1alpha1/roles + meta.upbound.io/example-id: default/v1alpha1/roles labels: testing.upbound.io/example-name: realm name: realm 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/internal/apis/scheme.go b/internal/apis/scheme.go new file mode 100644 index 00000000..2c7dbe24 --- /dev/null +++ b/internal/apis/scheme.go @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +package apis + +import ( + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/pkg/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var s = runtime.NewScheme() + +// GetManagedResource is Function to eliminate cross references using a transformer scheme +func GetManagedResource(group, version, kind, listKind string) (xpresource.Managed, xpresource.ManagedList, error) { + gv := schema.GroupVersion{ + Group: group, + Version: version, + } + kingGVK := gv.WithKind(kind) + m, err := s.New(kingGVK) + if err != nil { + return nil, nil, errors.Wrapf(err, "failed to get a new API object of GVK %q from the runtime scheme", kingGVK) + } + + listGVK := gv.WithKind(listKind) + l, err := s.New(listGVK) + if err != nil { + return nil, nil, errors.Wrapf(err, "failed to get a new API object list of GVK %q from the runtime scheme", listGVK) + } + return m.(xpresource.Managed), l.(xpresource.ManagedList), nil +} + +// BuildScheme builds the runtime scheme for the Crossplane resources +func BuildScheme(sb runtime.SchemeBuilder) error { + return errors.Wrap(sb.AddToScheme(s), "failed to register the GVKs with the runtime scheme") +} diff --git a/internal/controller/defaults/roles/zz_controller.go b/internal/controller/default/roles/zz_controller.go similarity index 99% rename from internal/controller/defaults/roles/zz_controller.go rename to internal/controller/default/roles/zz_controller.go index 42ea7e2d..b694f296 100755 --- a/internal/controller/defaults/roles/zz_controller.go +++ b/internal/controller/default/roles/zz_controller.go @@ -21,7 +21,7 @@ import ( "github.com/pkg/errors" ctrl "sigs.k8s.io/controller-runtime" - v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/defaults/v1alpha1" + v1alpha1 "github.com/crossplane-contrib/provider-keycloak/apis/default/v1alpha1" features "github.com/crossplane-contrib/provider-keycloak/internal/features" ) diff --git a/internal/controller/zz_setup.go b/internal/controller/zz_setup.go index 4fcca6c6..db445602 100755 --- a/internal/controller/zz_setup.go +++ b/internal/controller/zz_setup.go @@ -16,8 +16,8 @@ import ( subflow "github.com/crossplane-contrib/provider-keycloak/internal/controller/authenticationflow/subflow" protocolmapper "github.com/crossplane-contrib/provider-keycloak/internal/controller/client/protocolmapper" rolemapper "github.com/crossplane-contrib/provider-keycloak/internal/controller/client/rolemapper" + roles "github.com/crossplane-contrib/provider-keycloak/internal/controller/default/roles" defaultgroups "github.com/crossplane-contrib/provider-keycloak/internal/controller/defaults/defaultgroups" - roles "github.com/crossplane-contrib/provider-keycloak/internal/controller/defaults/roles" group "github.com/crossplane-contrib/provider-keycloak/internal/controller/group/group" memberships "github.com/crossplane-contrib/provider-keycloak/internal/controller/group/memberships" permissions "github.com/crossplane-contrib/provider-keycloak/internal/controller/group/permissions" @@ -72,8 +72,8 @@ func Setup(mgr ctrl.Manager, o controller.Options) error { subflow.Setup, protocolmapper.Setup, rolemapper.Setup, - defaultgroups.Setup, roles.Setup, + defaultgroups.Setup, group.Setup, memberships.Setup, permissions.Setup, diff --git a/package/crds/defaults.keycloak.crossplane.io_roles.yaml b/package/crds/default.keycloak.crossplane.io_roles.yaml similarity index 74% rename from package/crds/defaults.keycloak.crossplane.io_roles.yaml rename to package/crds/default.keycloak.crossplane.io_roles.yaml index 5a33d519..0bd6c9fb 100644 --- a/package/crds/defaults.keycloak.crossplane.io_roles.yaml +++ b/package/crds/default.keycloak.crossplane.io_roles.yaml @@ -4,9 +4,9 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.14.0 - name: roles.defaults.keycloak.crossplane.io + name: roles.default.keycloak.crossplane.io spec: - group: defaults.keycloak.crossplane.io + group: default.keycloak.crossplane.io names: categories: - crossplane @@ -80,83 +80,6 @@ spec: type: string type: array x-kubernetes-list-type: set - defaultRolesRefs: - description: References to Role in role to populate defaultRoles. - items: - description: A Reference to a named object. - 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 - type: array - defaultRolesSelector: - description: Selector for a list of Role in role to populate defaultRoles. - 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 realmId: description: The realm this role exists within. type: string @@ -256,83 +179,6 @@ spec: type: string type: array x-kubernetes-list-type: set - defaultRolesRefs: - description: References to Role in role to populate defaultRoles. - items: - description: A Reference to a named object. - 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 - type: array - defaultRolesSelector: - description: Selector for a list of Role in role to populate defaultRoles. - 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 realmId: description: The realm this role exists within. type: string @@ -578,6 +424,11 @@ spec: required: - forProvider type: object + x-kubernetes-validations: + - message: spec.forProvider.defaultRoles is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.defaultRoles) + || (has(self.initProvider) && has(self.initProvider.defaultRoles))' status: description: RolesStatus defines the observed state of Roles. properties: 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: |-