diff --git a/apis/dcs/v1alpha1/zz_generated.resolvers.go b/apis/dcs/v1alpha1/zz_generated.resolvers.go new file mode 100644 index 0000000..9ae8b5f --- /dev/null +++ b/apis/dcs/v1alpha1/zz_generated.resolvers.go @@ -0,0 +1,122 @@ +/* +Copyright 2022 Upbound Inc. +*/ +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + reference "github.com/crossplane/crossplane-runtime/pkg/reference" + v1alpha1 "github.com/opentelekomcloud/provider-opentelekomcloud/apis/compute/v1alpha1" + v1alpha11 "github.com/opentelekomcloud/provider-opentelekomcloud/apis/vpc/v1alpha1" + common "github.com/opentelekomcloud/provider-opentelekomcloud/config/common" + errors "github.com/pkg/errors" + client "sigs.k8s.io/controller-runtime/pkg/client" +) + +// ResolveReferences of this InstanceV2. +func (mg *InstanceV2) ResolveReferences(ctx context.Context, c client.Reader) error { + 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.SecurityGroupID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.SecurityGroupIDRef, + Selector: mg.Spec.ForProvider.SecurityGroupIDSelector, + To: reference.To{ + List: &v1alpha1.SecgroupV2List{}, + Managed: &v1alpha1.SecgroupV2{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.SecurityGroupID") + } + mg.Spec.ForProvider.SecurityGroupID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.SecurityGroupIDRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.SubnetID), + Extract: common.ExtractNetworkID(), + Reference: mg.Spec.ForProvider.SubnetIDRef, + Selector: mg.Spec.ForProvider.SubnetIDSelector, + To: reference.To{ + List: &v1alpha11.SubnetV1List{}, + Managed: &v1alpha11.SubnetV1{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.SubnetID") + } + mg.Spec.ForProvider.SubnetID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.SubnetIDRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.VPCID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.VPCIDRef, + Selector: mg.Spec.ForProvider.VPCIDSelector, + To: reference.To{ + List: &v1alpha11.VpcV1List{}, + Managed: &v1alpha11.VpcV1{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.VPCID") + } + mg.Spec.ForProvider.VPCID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.VPCIDRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.SecurityGroupID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.SecurityGroupIDRef, + Selector: mg.Spec.InitProvider.SecurityGroupIDSelector, + To: reference.To{ + List: &v1alpha1.SecgroupV2List{}, + Managed: &v1alpha1.SecgroupV2{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.InitProvider.SecurityGroupID") + } + mg.Spec.InitProvider.SecurityGroupID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.InitProvider.SecurityGroupIDRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.SubnetID), + Extract: common.ExtractNetworkID(), + Reference: mg.Spec.InitProvider.SubnetIDRef, + Selector: mg.Spec.InitProvider.SubnetIDSelector, + To: reference.To{ + List: &v1alpha11.SubnetV1List{}, + Managed: &v1alpha11.SubnetV1{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.InitProvider.SubnetID") + } + mg.Spec.InitProvider.SubnetID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.InitProvider.SubnetIDRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.VPCID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.VPCIDRef, + Selector: mg.Spec.InitProvider.VPCIDSelector, + To: reference.To{ + List: &v1alpha11.VpcV1List{}, + Managed: &v1alpha11.VpcV1{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.InitProvider.VPCID") + } + mg.Spec.InitProvider.VPCID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.InitProvider.VPCIDRef = rsp.ResolvedReference + + return nil +}