From 9d304e4bd19d2ca525d4c403687faa7c3983467d Mon Sep 17 00:00:00 2001 From: Matt Bush Date: Wed, 6 Dec 2023 21:26:30 -0800 Subject: [PATCH] codegen --- apis/iot/v1beta1/zz_generated.deepcopy.go | 50 ++--- apis/iot/v1beta1/zz_generated.resolvers.go | 37 ++++ .../v1beta1/zz_topicruledestination_types.go | 30 ++- .../iot/topicruledestination.yaml | 8 +- ....aws.upbound.io_topicruledestinations.yaml | 174 ++++++++++++++++-- 5 files changed, 253 insertions(+), 46 deletions(-) diff --git a/apis/iot/v1beta1/zz_generated.deepcopy.go b/apis/iot/v1beta1/zz_generated.deepcopy.go index afb27c06d6..59020d441b 100644 --- a/apis/iot/v1beta1/zz_generated.deepcopy.go +++ b/apis/iot/v1beta1/zz_generated.deepcopy.go @@ -7438,9 +7438,7 @@ func (in *TopicRuleDestinationInitParameters) DeepCopyInto(out *TopicRuleDestina if in.VPCConfiguration != nil { in, out := &in.VPCConfiguration, &out.VPCConfiguration *out = make([]VPCConfigurationInitParameters, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + copy(*out, *in) } } @@ -9570,28 +9568,6 @@ func (in *TopicRuleTimestreamParameters) DeepCopy() *TopicRuleTimestreamParamete // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VPCConfigurationInitParameters) DeepCopyInto(out *VPCConfigurationInitParameters) { *out = *in - if in.SecurityGroups != nil { - in, out := &in.SecurityGroups, &out.SecurityGroups - *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.SubnetIds != nil { - in, out := &in.SubnetIds, &out.SubnetIds - *out = make([]*string, len(*in)) - for i := range *in { - if (*in)[i] != nil { - in, out := &(*in)[i], &(*out)[i] - *out = new(string) - **out = **in - } - } - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VPCConfigurationInitParameters. @@ -9669,6 +9645,18 @@ func (in *VPCConfigurationParameters) DeepCopyInto(out *VPCConfigurationParamete *out = new(v1.Selector) (*in).DeepCopyInto(*out) } + if in.SecurityGroupRefs != nil { + in, out := &in.SecurityGroupRefs, &out.SecurityGroupRefs + *out = make([]v1.Reference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SecurityGroupSelector != nil { + in, out := &in.SecurityGroupSelector, &out.SecurityGroupSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.SecurityGroups != nil { in, out := &in.SecurityGroups, &out.SecurityGroups *out = make([]*string, len(*in)) @@ -9680,6 +9668,18 @@ func (in *VPCConfigurationParameters) DeepCopyInto(out *VPCConfigurationParamete } } } + if in.SubnetIDRefs != nil { + in, out := &in.SubnetIDRefs, &out.SubnetIDRefs + *out = make([]v1.Reference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SubnetIDSelector != nil { + in, out := &in.SubnetIDSelector, &out.SubnetIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.SubnetIds != nil { in, out := &in.SubnetIds, &out.SubnetIds *out = make([]*string, len(*in)) diff --git a/apis/iot/v1beta1/zz_generated.resolvers.go b/apis/iot/v1beta1/zz_generated.resolvers.go index 04bf5e0a05..fc2c6fdee9 100644 --- a/apis/iot/v1beta1/zz_generated.resolvers.go +++ b/apis/iot/v1beta1/zz_generated.resolvers.go @@ -297,6 +297,7 @@ func (mg *TopicRuleDestination) ResolveReferences(ctx context.Context, c client. r := reference.NewAPIResolver(c, mg) var rsp reference.ResolutionResponse + var mrsp reference.MultiResolutionResponse var err error for i3 := 0; i3 < len(mg.Spec.ForProvider.VPCConfiguration); i3++ { @@ -316,6 +317,42 @@ func (mg *TopicRuleDestination) ResolveReferences(ctx context.Context, c client. mg.Spec.ForProvider.VPCConfiguration[i3].RoleArn = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.VPCConfiguration[i3].RoleArnRef = rsp.ResolvedReference + } + for i3 := 0; i3 < len(mg.Spec.ForProvider.VPCConfiguration); i3++ { + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.VPCConfiguration[i3].SecurityGroups), + Extract: reference.ExternalName(), + References: mg.Spec.ForProvider.VPCConfiguration[i3].SecurityGroupRefs, + Selector: mg.Spec.ForProvider.VPCConfiguration[i3].SecurityGroupSelector, + To: reference.To{ + List: &v1beta12.SecurityGroupList{}, + Managed: &v1beta12.SecurityGroup{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.VPCConfiguration[i3].SecurityGroups") + } + mg.Spec.ForProvider.VPCConfiguration[i3].SecurityGroups = reference.ToPtrValues(mrsp.ResolvedValues) + mg.Spec.ForProvider.VPCConfiguration[i3].SecurityGroupRefs = mrsp.ResolvedReferences + + } + for i3 := 0; i3 < len(mg.Spec.ForProvider.VPCConfiguration); i3++ { + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.VPCConfiguration[i3].SubnetIds), + Extract: reference.ExternalName(), + References: mg.Spec.ForProvider.VPCConfiguration[i3].SubnetIDRefs, + Selector: mg.Spec.ForProvider.VPCConfiguration[i3].SubnetIDSelector, + To: reference.To{ + List: &v1beta12.SubnetList{}, + Managed: &v1beta12.Subnet{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.VPCConfiguration[i3].SubnetIds") + } + mg.Spec.ForProvider.VPCConfiguration[i3].SubnetIds = reference.ToPtrValues(mrsp.ResolvedValues) + mg.Spec.ForProvider.VPCConfiguration[i3].SubnetIDRefs = mrsp.ResolvedReferences + } for i3 := 0; i3 < len(mg.Spec.ForProvider.VPCConfiguration); i3++ { rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ diff --git a/apis/iot/v1beta1/zz_topicruledestination_types.go b/apis/iot/v1beta1/zz_topicruledestination_types.go index 4cebf6589b..d4c153f69c 100755 --- a/apis/iot/v1beta1/zz_topicruledestination_types.go +++ b/apis/iot/v1beta1/zz_topicruledestination_types.go @@ -57,12 +57,6 @@ type TopicRuleDestinationParameters struct { } type VPCConfigurationInitParameters struct { - - // The security groups of the VPC destination. - SecurityGroups []*string `json:"securityGroups,omitempty" tf:"security_groups,omitempty"` - - // The subnet IDs of the VPC destination. - SubnetIds []*string `json:"subnetIds,omitempty" tf:"subnet_ids,omitempty"` } type VPCConfigurationObservation struct { @@ -96,13 +90,35 @@ type VPCConfigurationParameters struct { // +kubebuilder:validation:Optional RoleArnSelector *v1.Selector `json:"roleArnSelector,omitempty" tf:"-"` + // References to SecurityGroup in ec2 to populate securityGroups. + // +kubebuilder:validation:Optional + SecurityGroupRefs []v1.Reference `json:"securityGroupRefs,omitempty" tf:"-"` + + // Selector for a list of SecurityGroup in ec2 to populate securityGroups. + // +kubebuilder:validation:Optional + SecurityGroupSelector *v1.Selector `json:"securityGroupSelector,omitempty" tf:"-"` + // The security groups of the VPC destination. + // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/ec2/v1beta1.SecurityGroup + // +crossplane:generate:reference:refFieldName=SecurityGroupRefs + // +crossplane:generate:reference:selectorFieldName=SecurityGroupSelector // +kubebuilder:validation:Optional SecurityGroups []*string `json:"securityGroups,omitempty" tf:"security_groups,omitempty"` + // References to Subnet in ec2 to populate subnetIds. + // +kubebuilder:validation:Optional + SubnetIDRefs []v1.Reference `json:"subnetIdRefs,omitempty" tf:"-"` + + // Selector for a list of Subnet in ec2 to populate subnetIds. + // +kubebuilder:validation:Optional + SubnetIDSelector *v1.Selector `json:"subnetIdSelector,omitempty" tf:"-"` + // The subnet IDs of the VPC destination. + // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/ec2/v1beta1.Subnet + // +crossplane:generate:reference:refFieldName=SubnetIDRefs + // +crossplane:generate:reference:selectorFieldName=SubnetIDSelector // +kubebuilder:validation:Optional - SubnetIds []*string `json:"subnetIds" tf:"subnet_ids,omitempty"` + SubnetIds []*string `json:"subnetIds,omitempty" tf:"subnet_ids,omitempty"` // The ID of the VPC. // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/ec2/v1beta1.VPC diff --git a/examples-generated/iot/topicruledestination.yaml b/examples-generated/iot/topicruledestination.yaml index b1c581c3e8..568098b9ff 100644 --- a/examples-generated/iot/topicruledestination.yaml +++ b/examples-generated/iot/topicruledestination.yaml @@ -13,9 +13,11 @@ spec: - roleArnSelector: matchLabels: testing.upbound.io/example-name: example - securityGroups: - - ${aws_security_group.example.id} - subnetIds: ${aws_subnet.example[*].id} + securityGroupRefs: + - name: example + subnetIdSelector: + matchLabels: + testing.upbound.io/example-name: example[*] vpcIdSelector: matchLabels: testing.upbound.io/example-name: example diff --git a/package/crds/iot.aws.upbound.io_topicruledestinations.yaml b/package/crds/iot.aws.upbound.io_topicruledestinations.yaml index 3251a95304..c8b07a86e4 100644 --- a/package/crds/iot.aws.upbound.io_topicruledestinations.yaml +++ b/package/crds/iot.aws.upbound.io_topicruledestinations.yaml @@ -160,11 +160,174 @@ spec: type: string type: object type: object + securityGroupRefs: + description: References to SecurityGroup in ec2 to populate + securityGroups. + 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 + securityGroupSelector: + description: Selector for a list of SecurityGroup in ec2 + to populate securityGroups. + 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 securityGroups: description: The security groups of the VPC destination. items: type: string type: array + subnetIdRefs: + description: References to Subnet in ec2 to populate subnetIds. + 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 + subnetIdSelector: + description: Selector for a list of Subnet in ec2 to populate + subnetIds. + 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 subnetIds: description: The subnet IDs of the VPC destination. items: @@ -274,17 +437,6 @@ spec: description: Configuration of the virtual private cloud (VPC) connection. For more info, see the AWS documentation. items: - properties: - securityGroups: - description: The security groups of the VPC destination. - items: - type: string - type: array - subnetIds: - description: The subnet IDs of the VPC destination. - items: - type: string - type: array type: object type: array type: object