diff --git a/Makefile b/Makefile index 8f40efc..5d370b2 100644 --- a/Makefile +++ b/Makefile @@ -168,7 +168,7 @@ submodules: run: go.build @$(INFO) Running Crossplane locally out-of-cluster . . . @# To see other arguments that can be provided, run the command with --help instead - UPBOUND_CONTEXT="local" $(GO_OUT_DIR)/provider --debug + UPBOUND_CONTEXT="local" $(GO_OUT_DIR)/provider --debug --poll 1m # ==================================================================================== # End to End Testing diff --git a/apis/ecs/v1alpha1/zz_generated.deepcopy.go b/apis/ecs/v1alpha1/zz_generated.deepcopy.go index 7a72f0c..b81e149 100644 --- a/apis/ecs/v1alpha1/zz_generated.deepcopy.go +++ b/apis/ecs/v1alpha1/zz_generated.deepcopy.go @@ -185,11 +185,6 @@ func (in *InstanceV1InitParameters) DeepCopyInto(out *InstanceV1InitParameters) *out = new(string) **out = **in } - if in.KeyName != nil { - in, out := &in.KeyName, &out.KeyName - *out = new(string) - **out = **in - } if in.Name != nil { in, out := &in.Name, &out.Name *out = new(string) @@ -202,17 +197,6 @@ func (in *InstanceV1InitParameters) DeepCopyInto(out *InstanceV1InitParameters) (*in)[i].DeepCopyInto(&(*out)[i]) } } - 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.SystemDiskKMSID != nil { in, out := &in.SystemDiskKMSID, &out.SystemDiskKMSID *out = new(string) @@ -249,11 +233,6 @@ func (in *InstanceV1InitParameters) DeepCopyInto(out *InstanceV1InitParameters) *out = new(string) **out = **in } - if in.VPCID != nil { - in, out := &in.VPCID, &out.VPCID - *out = new(string) - **out = **in - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceV1InitParameters. @@ -444,6 +423,18 @@ func (in *InstanceV1Parameters) DeepCopyInto(out *InstanceV1Parameters) { *out = new(string) **out = **in } + if in.ComputeSecurityGroupIDRefs != nil { + in, out := &in.ComputeSecurityGroupIDRefs, &out.ComputeSecurityGroupIDRefs + *out = make([]v1.Reference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ComputeSecurityGroupIDSelector != nil { + in, out := &in.ComputeSecurityGroupIDSelector, &out.ComputeSecurityGroupIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.DataDisks != nil { in, out := &in.DataDisks, &out.DataDisks *out = make([]DataDisksParameters, len(*in)) @@ -471,6 +462,16 @@ func (in *InstanceV1Parameters) DeepCopyInto(out *InstanceV1Parameters) { *out = new(string) **out = **in } + if in.KeyNameRef != nil { + in, out := &in.KeyNameRef, &out.KeyNameRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.KeyNameSelector != nil { + in, out := &in.KeyNameSelector, &out.KeyNameSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.Name != nil { in, out := &in.Name, &out.Name *out = new(string) @@ -540,6 +541,16 @@ func (in *InstanceV1Parameters) DeepCopyInto(out *InstanceV1Parameters) { *out = new(string) **out = **in } + if in.VPCIDRef != nil { + in, out := &in.VPCIDRef, &out.VPCIDRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.VPCIDSelector != nil { + in, out := &in.VPCIDSelector, &out.VPCIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceV1Parameters. @@ -595,11 +606,6 @@ func (in *NicsInitParameters) DeepCopyInto(out *NicsInitParameters) { *out = new(string) **out = **in } - if in.NetworkID != nil { - in, out := &in.NetworkID, &out.NetworkID - *out = new(string) - **out = **in - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NicsInitParameters. @@ -665,6 +671,16 @@ func (in *NicsParameters) DeepCopyInto(out *NicsParameters) { *out = new(string) **out = **in } + if in.NetworkIDRef != nil { + in, out := &in.NetworkIDRef, &out.NetworkIDRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.NetworkIDSelector != nil { + in, out := &in.NetworkIDSelector, &out.NetworkIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NicsParameters. diff --git a/apis/ecs/v1alpha1/zz_generated.resolvers.go b/apis/ecs/v1alpha1/zz_generated.resolvers.go new file mode 100644 index 0000000..524372c --- /dev/null +++ b/apis/ecs/v1alpha1/zz_generated.resolvers.go @@ -0,0 +1,93 @@ +/* +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" + compute "github.com/opentelekomcloud/provider-opentelekomcloud/config/compute" + errors "github.com/pkg/errors" + client "sigs.k8s.io/controller-runtime/pkg/client" +) + +// ResolveReferences of this InstanceV1. +func (mg *InstanceV1) ResolveReferences(ctx context.Context, c client.Reader) error { + 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.KeyName), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.KeyNameRef, + Selector: mg.Spec.ForProvider.KeyNameSelector, + To: reference.To{ + List: &v1alpha1.KeypairV2List{}, + Managed: &v1alpha1.KeypairV2{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.KeyName") + } + mg.Spec.ForProvider.KeyName = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.KeyNameRef = rsp.ResolvedReference + + for i3 := 0; i3 < len(mg.Spec.ForProvider.Nics); i3++ { + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Nics[i3].NetworkID), + Extract: compute.ExtractNetworkID(), + Reference: mg.Spec.ForProvider.Nics[i3].NetworkIDRef, + Selector: mg.Spec.ForProvider.Nics[i3].NetworkIDSelector, + To: reference.To{ + List: &v1alpha11.SubnetV1List{}, + Managed: &v1alpha11.SubnetV1{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.Nics[i3].NetworkID") + } + mg.Spec.ForProvider.Nics[i3].NetworkID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.Nics[i3].NetworkIDRef = rsp.ResolvedReference + + } + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.SecurityGroups), + Extract: reference.ExternalName(), + References: mg.Spec.ForProvider.ComputeSecurityGroupIDRefs, + Selector: mg.Spec.ForProvider.ComputeSecurityGroupIDSelector, + To: reference.To{ + List: &v1alpha1.SecgroupV2List{}, + Managed: &v1alpha1.SecgroupV2{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.SecurityGroups") + } + mg.Spec.ForProvider.SecurityGroups = reference.ToPtrValues(mrsp.ResolvedValues) + mg.Spec.ForProvider.ComputeSecurityGroupIDRefs = mrsp.ResolvedReferences + + 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 + + return nil +} diff --git a/apis/ecs/v1alpha1/zz_instancev1_types.go b/apis/ecs/v1alpha1/zz_instancev1_types.go index 406814e..eeb9646 100755 --- a/apis/ecs/v1alpha1/zz_instancev1_types.go +++ b/apis/ecs/v1alpha1/zz_instancev1_types.go @@ -103,11 +103,6 @@ type InstanceV1InitParameters struct { // The ID of the desired image for the server. Changing this creates a new server. ImageID *string `json:"imageId,omitempty" tf:"image_id,omitempty"` - // The name of a key pair to put on the server. The key - // pair must already be created and associated with the tenant's account. - // Changing this creates a new server. - KeyName *string `json:"keyName,omitempty" tf:"key_name,omitempty"` - // A unique name for the instance. Name *string `json:"name,omitempty" tf:"name,omitempty"` @@ -116,11 +111,6 @@ type InstanceV1InitParameters struct { // creates a new server. Nics []NicsInitParameters `json:"nics,omitempty" tf:"nics,omitempty"` - // An array of one or more security group IDs - // to associate with the server. If this parameter is left blank, the default - // security group is bound to the ECS by default. - SecurityGroups []*string `json:"securityGroups,omitempty" tf:"security_groups,omitempty"` - // The Encryption KMS ID of the system disk. Changing this // creates a new server. SystemDiskKMSID *string `json:"systemDiskKmsId,omitempty" tf:"system_disk_kms_id,omitempty"` @@ -139,9 +129,6 @@ type InstanceV1InitParameters struct { // The user data to provide when launching the instance. // Changing this creates a new server. UserData *string `json:"userData,omitempty" tf:"user_data,omitempty"` - - // The ID of the desired VPC for the server. Changing this creates a new server. - VPCID *string `json:"vpcId,omitempty" tf:"vpc_id,omitempty"` } type InstanceV1Observation struct { @@ -227,6 +214,14 @@ type InstanceV1Parameters struct { // +kubebuilder:validation:Optional AvailabilityZone *string `json:"availabilityZone,omitempty" tf:"availability_zone,omitempty"` + // References to SecgroupV2 in compute to populate securityGroups. + // +kubebuilder:validation:Optional + ComputeSecurityGroupIDRefs []v1.Reference `json:"computeSecurityGroupIdRefs,omitempty" tf:"-"` + + // Selector for a list of SecgroupV2 in compute to populate securityGroups. + // +kubebuilder:validation:Optional + ComputeSecurityGroupIDSelector *v1.Selector `json:"computeSecurityGroupIdSelector,omitempty" tf:"-"` + // An array of one or more data disks to attach to the // instance. The data_disks object structure is documented below. Changing this // creates a new server. @@ -249,9 +244,18 @@ type InstanceV1Parameters struct { // The name of a key pair to put on the server. The key // pair must already be created and associated with the tenant's account. // Changing this creates a new server. + // +crossplane:generate:reference:type=github.com/opentelekomcloud/provider-opentelekomcloud/apis/compute/v1alpha1.KeypairV2 // +kubebuilder:validation:Optional KeyName *string `json:"keyName,omitempty" tf:"key_name,omitempty"` + // Reference to a KeypairV2 in compute to populate keyName. + // +kubebuilder:validation:Optional + KeyNameRef *v1.Reference `json:"keyNameRef,omitempty" tf:"-"` + + // Selector for a KeypairV2 in compute to populate keyName. + // +kubebuilder:validation:Optional + KeyNameSelector *v1.Selector `json:"keyNameSelector,omitempty" tf:"-"` + // A unique name for the instance. // +kubebuilder:validation:Optional Name *string `json:"name,omitempty" tf:"name,omitempty"` @@ -270,6 +274,9 @@ type InstanceV1Parameters struct { // An array of one or more security group IDs // to associate with the server. If this parameter is left blank, the default // security group is bound to the ECS by default. + // +crossplane:generate:reference:type=github.com/opentelekomcloud/provider-opentelekomcloud/apis/compute/v1alpha1.SecgroupV2 + // +crossplane:generate:reference:refFieldName=ComputeSecurityGroupIDRefs + // +crossplane:generate:reference:selectorFieldName=ComputeSecurityGroupIDSelector // +kubebuilder:validation:Optional SecurityGroups []*string `json:"securityGroups,omitempty" tf:"security_groups,omitempty"` @@ -298,8 +305,17 @@ type InstanceV1Parameters struct { UserData *string `json:"userData,omitempty" tf:"user_data,omitempty"` // The ID of the desired VPC for the server. Changing this creates a new server. + // +crossplane:generate:reference:type=github.com/opentelekomcloud/provider-opentelekomcloud/apis/vpc/v1alpha1.VpcV1 // +kubebuilder:validation:Optional VPCID *string `json:"vpcId,omitempty" tf:"vpc_id,omitempty"` + + // Reference to a VpcV1 in vpc to populate vpcId. + // +kubebuilder:validation:Optional + VPCIDRef *v1.Reference `json:"vpcIdRef,omitempty" tf:"-"` + + // Selector for a VpcV1 in vpc to populate vpcId. + // +kubebuilder:validation:Optional + VPCIDSelector *v1.Selector `json:"vpcIdSelector,omitempty" tf:"-"` } type NicsInitParameters struct { @@ -307,9 +323,6 @@ type NicsInitParameters struct { // Specifies a fixed IPv4 address to be used on this // network. Changing this creates a new server. IPAddress *string `json:"ipAddress,omitempty" tf:"ip_address,omitempty"` - - // The network UUID to attach to the server. Changing this creates a new server. - NetworkID *string `json:"networkId,omitempty" tf:"network_id,omitempty"` } type NicsObservation struct { @@ -338,8 +351,18 @@ type NicsParameters struct { IPAddress *string `json:"ipAddress,omitempty" tf:"ip_address,omitempty"` // The network UUID to attach to the server. Changing this creates a new server. + // +crossplane:generate:reference:type=github.com/opentelekomcloud/provider-opentelekomcloud/apis/vpc/v1alpha1.SubnetV1 + // +crossplane:generate:reference:extractor=github.com/opentelekomcloud/provider-opentelekomcloud/config/compute.ExtractNetworkID() + // +kubebuilder:validation:Optional + NetworkID *string `json:"networkId,omitempty" tf:"network_id,omitempty"` + + // Reference to a SubnetV1 in vpc to populate networkId. + // +kubebuilder:validation:Optional + NetworkIDRef *v1.Reference `json:"networkIdRef,omitempty" tf:"-"` + + // Selector for a SubnetV1 in vpc to populate networkId. // +kubebuilder:validation:Optional - NetworkID *string `json:"networkId" tf:"network_id,omitempty"` + NetworkIDSelector *v1.Selector `json:"networkIdSelector,omitempty" tf:"-"` } type VolumesAttachedInitParameters struct { @@ -408,7 +431,6 @@ type InstanceV1 struct { // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.imageId) || (has(self.initProvider) && has(self.initProvider.imageId))",message="spec.forProvider.imageId is a required parameter" // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.name) || (has(self.initProvider) && has(self.initProvider.name))",message="spec.forProvider.name is a required parameter" // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.nics) || (has(self.initProvider) && has(self.initProvider.nics))",message="spec.forProvider.nics is a required parameter" - // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.vpcId) || (has(self.initProvider) && has(self.initProvider.vpcId))",message="spec.forProvider.vpcId is a required parameter" Spec InstanceV1Spec `json:"spec"` Status InstanceV1Status `json:"status,omitempty"` } diff --git a/apis/vpc/v1alpha1/zz_generated.deepcopy.go b/apis/vpc/v1alpha1/zz_generated.deepcopy.go index b683398..40f34b7 100644 --- a/apis/vpc/v1alpha1/zz_generated.deepcopy.go +++ b/apis/vpc/v1alpha1/zz_generated.deepcopy.go @@ -9,6 +9,7 @@ Copyright 2022 Upbound Inc. package v1alpha1 import ( + "github.com/crossplane/crossplane-runtime/apis/common/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -2371,11 +2372,6 @@ func (in *SubnetV1InitParameters) DeepCopyInto(out *SubnetV1InitParameters) { (*out)[key] = outVal } } - if in.VPCID != nil { - in, out := &in.VPCID, &out.VPCID - *out = new(string) - **out = **in - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubnetV1InitParameters. @@ -2642,6 +2638,16 @@ func (in *SubnetV1Parameters) DeepCopyInto(out *SubnetV1Parameters) { *out = new(string) **out = **in } + if in.VPCIDRef != nil { + in, out := &in.VPCIDRef, &out.VPCIDRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.VPCIDSelector != nil { + in, out := &in.VPCIDSelector, &out.VPCIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubnetV1Parameters. @@ -2690,7 +2696,7 @@ func (in *SubnetV1Status) DeepCopy() *SubnetV1Status { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *V1) DeepCopyInto(out *V1) { +func (in *VpcV1) DeepCopyInto(out *VpcV1) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) @@ -2698,18 +2704,18 @@ func (in *V1) DeepCopyInto(out *V1) { in.Status.DeepCopyInto(&out.Status) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new V1. -func (in *V1) DeepCopy() *V1 { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VpcV1. +func (in *VpcV1) DeepCopy() *VpcV1 { if in == nil { return nil } - out := new(V1) + out := new(VpcV1) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *V1) DeepCopyObject() runtime.Object { +func (in *VpcV1) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -2717,7 +2723,7 @@ func (in *V1) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *V1InitParameters) DeepCopyInto(out *V1InitParameters) { +func (in *VpcV1InitParameters) DeepCopyInto(out *VpcV1InitParameters) { *out = *in if in.Cidr != nil { in, out := &in.Cidr, &out.Cidr @@ -2767,42 +2773,42 @@ func (in *V1InitParameters) DeepCopyInto(out *V1InitParameters) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new V1InitParameters. -func (in *V1InitParameters) DeepCopy() *V1InitParameters { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VpcV1InitParameters. +func (in *VpcV1InitParameters) DeepCopy() *VpcV1InitParameters { if in == nil { return nil } - out := new(V1InitParameters) + out := new(VpcV1InitParameters) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *V1List) DeepCopyInto(out *V1List) { +func (in *VpcV1List) DeepCopyInto(out *VpcV1List) { *out = *in out.TypeMeta = in.TypeMeta in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]V1, len(*in)) + *out = make([]VpcV1, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new V1List. -func (in *V1List) DeepCopy() *V1List { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VpcV1List. +func (in *VpcV1List) DeepCopy() *VpcV1List { if in == nil { return nil } - out := new(V1List) + out := new(VpcV1List) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *V1List) DeepCopyObject() runtime.Object { +func (in *VpcV1List) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -2810,7 +2816,7 @@ func (in *V1List) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *V1Observation) DeepCopyInto(out *V1Observation) { +func (in *VpcV1Observation) DeepCopyInto(out *VpcV1Observation) { *out = *in if in.Cidr != nil { in, out := &in.Cidr, &out.Cidr @@ -2870,18 +2876,18 @@ func (in *V1Observation) DeepCopyInto(out *V1Observation) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new V1Observation. -func (in *V1Observation) DeepCopy() *V1Observation { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VpcV1Observation. +func (in *VpcV1Observation) DeepCopy() *VpcV1Observation { if in == nil { return nil } - out := new(V1Observation) + out := new(VpcV1Observation) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *V1Parameters) DeepCopyInto(out *V1Parameters) { +func (in *VpcV1Parameters) DeepCopyInto(out *VpcV1Parameters) { *out = *in if in.Cidr != nil { in, out := &in.Cidr, &out.Cidr @@ -2931,47 +2937,47 @@ func (in *V1Parameters) DeepCopyInto(out *V1Parameters) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new V1Parameters. -func (in *V1Parameters) DeepCopy() *V1Parameters { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VpcV1Parameters. +func (in *VpcV1Parameters) DeepCopy() *VpcV1Parameters { if in == nil { return nil } - out := new(V1Parameters) + out := new(VpcV1Parameters) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *V1Spec) DeepCopyInto(out *V1Spec) { +func (in *VpcV1Spec) DeepCopyInto(out *VpcV1Spec) { *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 V1Spec. -func (in *V1Spec) DeepCopy() *V1Spec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VpcV1Spec. +func (in *VpcV1Spec) DeepCopy() *VpcV1Spec { if in == nil { return nil } - out := new(V1Spec) + out := new(VpcV1Spec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *V1Status) DeepCopyInto(out *V1Status) { +func (in *VpcV1Status) DeepCopyInto(out *VpcV1Status) { *out = *in in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) in.AtProvider.DeepCopyInto(&out.AtProvider) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new V1Status. -func (in *V1Status) DeepCopy() *V1Status { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VpcV1Status. +func (in *VpcV1Status) DeepCopy() *VpcV1Status { if in == nil { return nil } - out := new(V1Status) + out := new(VpcV1Status) in.DeepCopyInto(out) return out } diff --git a/apis/vpc/v1alpha1/zz_generated.managed.go b/apis/vpc/v1alpha1/zz_generated.managed.go index f443770..06752a4 100644 --- a/apis/vpc/v1alpha1/zz_generated.managed.go +++ b/apis/vpc/v1alpha1/zz_generated.managed.go @@ -547,62 +547,62 @@ func (mg *SubnetV1) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) mg.Spec.WriteConnectionSecretToReference = r } -// GetCondition of this V1. -func (mg *V1) GetCondition(ct xpv1.ConditionType) xpv1.Condition { +// GetCondition of this VpcV1. +func (mg *VpcV1) GetCondition(ct xpv1.ConditionType) xpv1.Condition { return mg.Status.GetCondition(ct) } -// GetDeletionPolicy of this V1. -func (mg *V1) GetDeletionPolicy() xpv1.DeletionPolicy { +// GetDeletionPolicy of this VpcV1. +func (mg *VpcV1) GetDeletionPolicy() xpv1.DeletionPolicy { return mg.Spec.DeletionPolicy } -// GetManagementPolicies of this V1. -func (mg *V1) GetManagementPolicies() xpv1.ManagementPolicies { +// GetManagementPolicies of this VpcV1. +func (mg *VpcV1) GetManagementPolicies() xpv1.ManagementPolicies { return mg.Spec.ManagementPolicies } -// GetProviderConfigReference of this V1. -func (mg *V1) GetProviderConfigReference() *xpv1.Reference { +// GetProviderConfigReference of this VpcV1. +func (mg *VpcV1) GetProviderConfigReference() *xpv1.Reference { return mg.Spec.ProviderConfigReference } -// GetPublishConnectionDetailsTo of this V1. -func (mg *V1) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { +// GetPublishConnectionDetailsTo of this VpcV1. +func (mg *VpcV1) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { return mg.Spec.PublishConnectionDetailsTo } -// GetWriteConnectionSecretToReference of this V1. -func (mg *V1) GetWriteConnectionSecretToReference() *xpv1.SecretReference { +// GetWriteConnectionSecretToReference of this VpcV1. +func (mg *VpcV1) GetWriteConnectionSecretToReference() *xpv1.SecretReference { return mg.Spec.WriteConnectionSecretToReference } -// SetConditions of this V1. -func (mg *V1) SetConditions(c ...xpv1.Condition) { +// SetConditions of this VpcV1. +func (mg *VpcV1) SetConditions(c ...xpv1.Condition) { mg.Status.SetConditions(c...) } -// SetDeletionPolicy of this V1. -func (mg *V1) SetDeletionPolicy(r xpv1.DeletionPolicy) { +// SetDeletionPolicy of this VpcV1. +func (mg *VpcV1) SetDeletionPolicy(r xpv1.DeletionPolicy) { mg.Spec.DeletionPolicy = r } -// SetManagementPolicies of this V1. -func (mg *V1) SetManagementPolicies(r xpv1.ManagementPolicies) { +// SetManagementPolicies of this VpcV1. +func (mg *VpcV1) SetManagementPolicies(r xpv1.ManagementPolicies) { mg.Spec.ManagementPolicies = r } -// SetProviderConfigReference of this V1. -func (mg *V1) SetProviderConfigReference(r *xpv1.Reference) { +// SetProviderConfigReference of this VpcV1. +func (mg *VpcV1) SetProviderConfigReference(r *xpv1.Reference) { mg.Spec.ProviderConfigReference = r } -// SetPublishConnectionDetailsTo of this V1. -func (mg *V1) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { +// SetPublishConnectionDetailsTo of this VpcV1. +func (mg *VpcV1) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { mg.Spec.PublishConnectionDetailsTo = r } -// SetWriteConnectionSecretToReference of this V1. -func (mg *V1) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { +// SetWriteConnectionSecretToReference of this VpcV1. +func (mg *VpcV1) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { mg.Spec.WriteConnectionSecretToReference = r } diff --git a/apis/vpc/v1alpha1/zz_generated.managedlist.go b/apis/vpc/v1alpha1/zz_generated.managedlist.go index 11df6ff..ec96044 100644 --- a/apis/vpc/v1alpha1/zz_generated.managedlist.go +++ b/apis/vpc/v1alpha1/zz_generated.managedlist.go @@ -88,8 +88,8 @@ func (l *SubnetV1List) GetItems() []resource.Managed { return items } -// GetItems of this V1List. -func (l *V1List) GetItems() []resource.Managed { +// GetItems of this VpcV1List. +func (l *VpcV1List) GetItems() []resource.Managed { items := make([]resource.Managed, len(l.Items)) for i := range l.Items { items[i] = &l.Items[i] diff --git a/apis/vpc/v1alpha1/zz_generated.resolvers.go b/apis/vpc/v1alpha1/zz_generated.resolvers.go new file mode 100644 index 0000000..40befb6 --- /dev/null +++ b/apis/vpc/v1alpha1/zz_generated.resolvers.go @@ -0,0 +1,39 @@ +/* +Copyright 2022 Upbound Inc. +*/ +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + reference "github.com/crossplane/crossplane-runtime/pkg/reference" + errors "github.com/pkg/errors" + client "sigs.k8s.io/controller-runtime/pkg/client" +) + +// ResolveReferences of this SubnetV1. +func (mg *SubnetV1) 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.VPCID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.VPCIDRef, + Selector: mg.Spec.ForProvider.VPCIDSelector, + To: reference.To{ + List: &VpcV1List{}, + Managed: &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 + + return nil +} diff --git a/apis/vpc/v1alpha1/zz_generated_terraformed.go b/apis/vpc/v1alpha1/zz_generated_terraformed.go index 9632c72..9fcfccc 100755 --- a/apis/vpc/v1alpha1/zz_generated_terraformed.go +++ b/apis/vpc/v1alpha1/zz_generated_terraformed.go @@ -773,18 +773,18 @@ func (tr *SubnetV1) GetTerraformSchemaVersion() int { return 0 } -// GetTerraformResourceType returns Terraform resource type for this V1 -func (mg *V1) GetTerraformResourceType() string { +// GetTerraformResourceType returns Terraform resource type for this VpcV1 +func (mg *VpcV1) GetTerraformResourceType() string { return "opentelekomcloud_vpc_v1" } -// GetConnectionDetailsMapping for this V1 -func (tr *V1) GetConnectionDetailsMapping() map[string]string { +// GetConnectionDetailsMapping for this VpcV1 +func (tr *VpcV1) GetConnectionDetailsMapping() map[string]string { return nil } -// GetObservation of this V1 -func (tr *V1) GetObservation() (map[string]any, error) { +// GetObservation of this VpcV1 +func (tr *VpcV1) GetObservation() (map[string]any, error) { o, err := json.TFParser.Marshal(tr.Status.AtProvider) if err != nil { return nil, err @@ -793,8 +793,8 @@ func (tr *V1) GetObservation() (map[string]any, error) { return base, json.TFParser.Unmarshal(o, &base) } -// SetObservation for this V1 -func (tr *V1) SetObservation(obs map[string]any) error { +// SetObservation for this VpcV1 +func (tr *VpcV1) SetObservation(obs map[string]any) error { p, err := json.TFParser.Marshal(obs) if err != nil { return err @@ -802,16 +802,16 @@ func (tr *V1) SetObservation(obs map[string]any) error { return json.TFParser.Unmarshal(p, &tr.Status.AtProvider) } -// GetID returns ID of underlying Terraform resource of this V1 -func (tr *V1) GetID() string { +// GetID returns ID of underlying Terraform resource of this VpcV1 +func (tr *VpcV1) GetID() string { if tr.Status.AtProvider.ID == nil { return "" } return *tr.Status.AtProvider.ID } -// GetParameters of this V1 -func (tr *V1) GetParameters() (map[string]any, error) { +// GetParameters of this VpcV1 +func (tr *VpcV1) GetParameters() (map[string]any, error) { p, err := json.TFParser.Marshal(tr.Spec.ForProvider) if err != nil { return nil, err @@ -820,8 +820,8 @@ func (tr *V1) GetParameters() (map[string]any, error) { return base, json.TFParser.Unmarshal(p, &base) } -// SetParameters for this V1 -func (tr *V1) SetParameters(params map[string]any) error { +// SetParameters for this VpcV1 +func (tr *VpcV1) SetParameters(params map[string]any) error { p, err := json.TFParser.Marshal(params) if err != nil { return err @@ -829,8 +829,8 @@ func (tr *V1) SetParameters(params map[string]any) error { return json.TFParser.Unmarshal(p, &tr.Spec.ForProvider) } -// GetInitParameters of this V1 -func (tr *V1) GetInitParameters() (map[string]any, error) { +// GetInitParameters of this VpcV1 +func (tr *VpcV1) GetInitParameters() (map[string]any, error) { p, err := json.TFParser.Marshal(tr.Spec.InitProvider) if err != nil { return nil, err @@ -839,10 +839,10 @@ func (tr *V1) GetInitParameters() (map[string]any, error) { return base, json.TFParser.Unmarshal(p, &base) } -// LateInitialize this V1 using its observed tfState. +// LateInitialize this VpcV1 using its observed tfState. // returns True if there are any spec changes for the resource. -func (tr *V1) LateInitialize(attrs []byte) (bool, error) { - params := &V1Parameters{} +func (tr *VpcV1) LateInitialize(attrs []byte) (bool, error) { + params := &VpcV1Parameters{} if err := json.TFParser.Unmarshal(attrs, params); err != nil { return false, errors.Wrap(err, "failed to unmarshal Terraform state parameters for late-initialization") } @@ -853,6 +853,6 @@ func (tr *V1) LateInitialize(attrs []byte) (bool, error) { } // GetTerraformSchemaVersion returns the associated Terraform schema version -func (tr *V1) GetTerraformSchemaVersion() int { +func (tr *VpcV1) GetTerraformSchemaVersion() int { return 0 } diff --git a/apis/vpc/v1alpha1/zz_subnetv1_types.go b/apis/vpc/v1alpha1/zz_subnetv1_types.go index 403a042..9a932e0 100755 --- a/apis/vpc/v1alpha1/zz_subnetv1_types.go +++ b/apis/vpc/v1alpha1/zz_subnetv1_types.go @@ -67,9 +67,6 @@ type SubnetV1InitParameters struct { // The key/value pairs to associate with the subnet. Tags map[string]*string `json:"tags,omitempty" tf:"tags,omitempty"` - - // Specifies the ID of the VPC to which the subnet belongs. Changing this creates a new Subnet. - VPCID *string `json:"vpcId,omitempty" tf:"vpc_id,omitempty"` } type SubnetV1Observation struct { @@ -208,8 +205,17 @@ type SubnetV1Parameters struct { Tags map[string]*string `json:"tags,omitempty" tf:"tags,omitempty"` // Specifies the ID of the VPC to which the subnet belongs. Changing this creates a new Subnet. + // +crossplane:generate:reference:type=github.com/opentelekomcloud/provider-opentelekomcloud/apis/vpc/v1alpha1.VpcV1 // +kubebuilder:validation:Optional VPCID *string `json:"vpcId,omitempty" tf:"vpc_id,omitempty"` + + // Reference to a VpcV1 in vpc to populate vpcId. + // +kubebuilder:validation:Optional + VPCIDRef *v1.Reference `json:"vpcIdRef,omitempty" tf:"-"` + + // Selector for a VpcV1 in vpc to populate vpcId. + // +kubebuilder:validation:Optional + VPCIDSelector *v1.Selector `json:"vpcIdSelector,omitempty" tf:"-"` } // SubnetV1Spec defines the desired state of SubnetV1 @@ -250,7 +256,6 @@ type SubnetV1 struct { // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.cidr) || (has(self.initProvider) && has(self.initProvider.cidr))",message="spec.forProvider.cidr is a required parameter" // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.gatewayIp) || (has(self.initProvider) && has(self.initProvider.gatewayIp))",message="spec.forProvider.gatewayIp is a required parameter" // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.name) || (has(self.initProvider) && has(self.initProvider.name))",message="spec.forProvider.name is a required parameter" - // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.vpcId) || (has(self.initProvider) && has(self.initProvider.vpcId))",message="spec.forProvider.vpcId is a required parameter" Spec SubnetV1Spec `json:"spec"` Status SubnetV1Status `json:"status,omitempty"` } diff --git a/apis/vpc/v1alpha1/zz_v1_types.go b/apis/vpc/v1alpha1/zz_vpcv1_types.go similarity index 87% rename from apis/vpc/v1alpha1/zz_v1_types.go rename to apis/vpc/v1alpha1/zz_vpcv1_types.go index c1e0c89..1e58709 100755 --- a/apis/vpc/v1alpha1/zz_v1_types.go +++ b/apis/vpc/v1alpha1/zz_vpcv1_types.go @@ -17,7 +17,7 @@ import ( v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" ) -type V1InitParameters struct { +type VpcV1InitParameters struct { // The range of available subnets in the VPC. The value ranges from // 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, @@ -48,7 +48,7 @@ type V1InitParameters struct { Tags map[string]*string `json:"tags,omitempty" tf:"tags,omitempty"` } -type V1Observation struct { +type VpcV1Observation struct { // The range of available subnets in the VPC. The value ranges from // 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, @@ -85,7 +85,7 @@ type V1Observation struct { Tags map[string]*string `json:"tags,omitempty" tf:"tags,omitempty"` } -type V1Parameters struct { +type VpcV1Parameters struct { // The range of available subnets in the VPC. The value ranges from // 10.0.0.0/8 to 10.255.255.0/24, 172.16.0.0/12 to 172.31.255.0/24, @@ -123,10 +123,10 @@ type V1Parameters struct { Tags map[string]*string `json:"tags,omitempty" tf:"tags,omitempty"` } -// V1Spec defines the desired state of V1 -type V1Spec struct { +// VpcV1Spec defines the desired state of VpcV1 +type VpcV1Spec struct { v1.ResourceSpec `json:",inline"` - ForProvider V1Parameters `json:"forProvider"` + ForProvider VpcV1Parameters `json:"forProvider"` // THIS IS A BETA FIELD. It will be honored // unless the Management Policies feature flag is disabled. // InitProvider holds the same fields as ForProvider, with the exception @@ -137,50 +137,50 @@ type V1Spec struct { // required on creation, but we do not desire to update them after creation, // for example because of an external controller is managing them, like an // autoscaler. - InitProvider V1InitParameters `json:"initProvider,omitempty"` + InitProvider VpcV1InitParameters `json:"initProvider,omitempty"` } -// V1Status defines the observed state of V1. -type V1Status struct { +// VpcV1Status defines the observed state of VpcV1. +type VpcV1Status struct { v1.ResourceStatus `json:",inline"` - AtProvider V1Observation `json:"atProvider,omitempty"` + AtProvider VpcV1Observation `json:"atProvider,omitempty"` } // +kubebuilder:object:root=true -// V1 is the Schema for the V1s API. Manages a VPC resource within OpenTelekomCloud. +// VpcV1 is the Schema for the VpcV1s API. Manages a VPC resource within OpenTelekomCloud. // +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" // +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" // +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" // +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" // +kubebuilder:subresource:status // +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,opentelekomcloud} -type V1 struct { +type VpcV1 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.cidr) || (has(self.initProvider) && has(self.initProvider.cidr))",message="spec.forProvider.cidr is a required parameter" // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.name) || (has(self.initProvider) && has(self.initProvider.name))",message="spec.forProvider.name is a required parameter" - Spec V1Spec `json:"spec"` - Status V1Status `json:"status,omitempty"` + Spec VpcV1Spec `json:"spec"` + Status VpcV1Status `json:"status,omitempty"` } // +kubebuilder:object:root=true -// V1List contains a list of V1s -type V1List struct { +// VpcV1List contains a list of VpcV1s +type VpcV1List struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []V1 `json:"items"` + Items []VpcV1 `json:"items"` } // Repository type metadata. var ( - V1_Kind = "V1" - V1_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: V1_Kind}.String() - V1_KindAPIVersion = V1_Kind + "." + CRDGroupVersion.String() - V1_GroupVersionKind = CRDGroupVersion.WithKind(V1_Kind) + VpcV1_Kind = "VpcV1" + VpcV1_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: VpcV1_Kind}.String() + VpcV1_KindAPIVersion = VpcV1_Kind + "." + CRDGroupVersion.String() + VpcV1_GroupVersionKind = CRDGroupVersion.WithKind(VpcV1_Kind) ) func init() { - SchemeBuilder.Register(&V1{}, &V1List{}) + SchemeBuilder.Register(&VpcV1{}, &VpcV1List{}) } diff --git a/config/compute/config.go b/config/compute/config.go index 22ff055..868f0b7 100644 --- a/config/compute/config.go +++ b/config/compute/config.go @@ -1,10 +1,16 @@ package compute -import "github.com/crossplane/upjet/pkg/config" +import ( + xpref "github.com/crossplane/crossplane-runtime/pkg/reference" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/upjet/pkg/config" + "github.com/crossplane/upjet/pkg/resource" +) // Configure configures individual resources by adding custom ResourceConfigurators. func Configure(p *config.Provider) { p.AddResourceConfigurator("opentelekomcloud_compute_instance_v2", func(r *config.Resource) { + r.UseAsync = true r.References["key_pair"] = config.Reference{ Type: "KeypairV2", } @@ -12,4 +18,54 @@ func Configure(p *config.Provider) { Type: "SecgroupV2", } }) + p.AddResourceConfigurator("opentelekomcloud_compute_keypair_v2", func(r *config.Resource) { + r.UseAsync = true + }) + p.AddResourceConfigurator("opentelekomcloud_ecs_instance_v1", func(r *config.Resource) { + r.UseAsync = true + r.References["key_name"] = config.Reference{ + TerraformName: "opentelekomcloud_compute_keypair_v2", + } + r.References["security_groups"] = config.Reference{ + TerraformName: "opentelekomcloud_compute_secgroup_v2", + RefFieldName: "ComputeSecurityGroupIDRefs", + SelectorFieldName: "ComputeSecurityGroupIDSelector", + } + r.References["vpc_id"] = config.Reference{ + TerraformName: "opentelekomcloud_vpc_v1", + } + r.References["nics.network_id"] = config.Reference{ + TerraformName: "opentelekomcloud_vpc_subnet_v1", + Extractor: ExtractNetworkIDFunc, + } + }) +} + +const ( + // APISPackagePath is the package path for generated APIs root package + APISPackagePath = "github.com/opentelekomcloud/provider-opentelekomcloud/config/compute" + + // ExtractNetworkIDFunc extracts network_id from subnet resource + ExtractNetworkIDFunc = APISPackagePath + ".ExtractNetworkID()" +) + +// ExtractNetworkID extracts the value of `spec.forProvider.network_id` +// from a Observable resource. If mr is not a Observable +// resource, returns an empty string. +func ExtractNetworkID() xpref.ExtractValueFn { + return func(mr xpresource.Managed) string { + tr, ok := mr.(resource.Observable) + if !ok { + return "" + } + o, err := tr.GetObservation() + if err != nil { + return "" + } + + if k := o["network_id"]; k != nil { + return k.(string) + } + return "" + } } diff --git a/config/external_name.go b/config/external_name.go index c22b281..c02f740 100644 --- a/config/external_name.go +++ b/config/external_name.go @@ -4,7 +4,9 @@ Copyright 2022 Upbound Inc. package config -import "github.com/crossplane/upjet/pkg/config" +import ( + "github.com/crossplane/upjet/pkg/config" +) // ExternalNameConfigs contains all external name configurations for this // provider. diff --git a/config/provider.go b/config/provider.go index bd482fb..98a4ec6 100644 --- a/config/provider.go +++ b/config/provider.go @@ -8,6 +8,8 @@ import ( // Note(turkenh): we are importing this to embed provider schema document _ "embed" + "github.com/opentelekomcloud/provider-opentelekomcloud/config/vpc" + "github.com/opentelekomcloud/provider-opentelekomcloud/config/blockstorage" "github.com/opentelekomcloud/provider-opentelekomcloud/config/cce" "github.com/opentelekomcloud/provider-opentelekomcloud/config/compute" @@ -77,6 +79,7 @@ func GetProvider() *ujconfig.Provider { sfs.Configure, smn.Configure, vpcep.Configure, + vpc.Configure, vpnaas.Configure, wafd.Configure, } { diff --git a/config/vpc/config.go b/config/vpc/config.go new file mode 100644 index 0000000..2be57af --- /dev/null +++ b/config/vpc/config.go @@ -0,0 +1,15 @@ +package vpc + +import "github.com/crossplane/upjet/pkg/config" + +// Configure configures individual resources by adding custom ResourceConfigurators. +func Configure(p *config.Provider) { + p.AddResourceConfigurator("opentelekomcloud_vpc_subnet_v1", func(r *config.Resource) { + r.References["vpc_id"] = config.Reference{ + TerraformName: "opentelekomcloud_vpc_v1", + } + }) + p.AddResourceConfigurator("opentelekomcloud_vpc_v1", func(r *config.Resource) { + r.Kind = "VpcV1" + }) +} diff --git a/examples-generated/ecs/instancev1.yaml b/examples-generated/ecs/instancev1.yaml index ce67d00..9344763 100644 --- a/examples-generated/ecs/instancev1.yaml +++ b/examples-generated/ecs/instancev1.yaml @@ -11,10 +11,16 @@ spec: availabilityZone: eu-de-01 flavor: s2.large.2 imageId: ad091b52-742f-469e-8f3c-fd81cadf0743 - keyName: KeyPair-test + keyNameSelector: + matchLabels: + testing.upbound.io/example-name: example name: server_1 nics: - - networkId: 55534eaa-533a-419d-9b40-ec427ea7195a + - networkIdSelector: + matchLabels: + testing.upbound.io/example-name: example tags: muh: kuh - vpcId: 8eed4fc7-e5e5-44a2-b5f2-23b3e5d46235 + vpcIdSelector: + matchLabels: + testing.upbound.io/example-name: example diff --git a/examples-generated/sfs/shareaccessrulesv2.yaml b/examples-generated/sfs/shareaccessrulesv2.yaml index d10c2d0..acab6d3 100644 --- a/examples-generated/sfs/shareaccessrulesv2.yaml +++ b/examples-generated/sfs/shareaccessrulesv2.yaml @@ -37,7 +37,7 @@ spec: --- apiVersion: vpc.opentelekomcloud.crossplane.io/v1alpha1 -kind: V1 +kind: VpcV1 metadata: annotations: meta.upbound.io/example-id: sfs/v1alpha1/shareaccessrulesv2 @@ -52,7 +52,7 @@ spec: --- apiVersion: vpc.opentelekomcloud.crossplane.io/v1alpha1 -kind: V1 +kind: VpcV1 metadata: annotations: meta.upbound.io/example-id: sfs/v1alpha1/shareaccessrulesv2 diff --git a/examples-generated/vpc/flowlogv1.yaml b/examples-generated/vpc/flowlogv1.yaml index ff89f43..510be46 100644 --- a/examples-generated/vpc/flowlogv1.yaml +++ b/examples-generated/vpc/flowlogv1.yaml @@ -19,7 +19,7 @@ spec: --- apiVersion: vpc.opentelekomcloud.crossplane.io/v1alpha1 -kind: V1 +kind: VpcV1 metadata: annotations: meta.upbound.io/example-id: vpc/v1alpha1/flowlogv1 diff --git a/examples-generated/vpc/peeringconnectionaccepterv2.yaml b/examples-generated/vpc/peeringconnectionaccepterv2.yaml index d21ea69..8914092 100644 --- a/examples-generated/vpc/peeringconnectionaccepterv2.yaml +++ b/examples-generated/vpc/peeringconnectionaccepterv2.yaml @@ -33,7 +33,7 @@ spec: --- apiVersion: vpc.opentelekomcloud.crossplane.io/v1alpha1 -kind: V1 +kind: VpcV1 metadata: annotations: meta.upbound.io/example-id: vpc/v1alpha1/peeringconnectionaccepterv2 @@ -49,7 +49,7 @@ spec: --- apiVersion: vpc.opentelekomcloud.crossplane.io/v1alpha1 -kind: V1 +kind: VpcV1 metadata: annotations: meta.upbound.io/example-id: vpc/v1alpha1/peeringconnectionaccepterv2 diff --git a/examples-generated/vpc/routetablev1.yaml b/examples-generated/vpc/routetablev1.yaml index 89f7b39..cdd1c31 100644 --- a/examples-generated/vpc/routetablev1.yaml +++ b/examples-generated/vpc/routetablev1.yaml @@ -48,7 +48,9 @@ spec: cidr: 192.168.0.0/24 gatewayIp: 192.168.0.1 name: vpc-1-subnet-1-1 - vpcId: ${opentelekomcloud_vpc_v1.vpc_1.id} + vpcIdSelector: + matchLabels: + testing.upbound.io/example-name: vpc_1 --- @@ -65,7 +67,9 @@ spec: cidr: 192.168.10.0/24 gatewayIp: 192.168.10.1 name: vpc-1-subnet-1-2 - vpcId: ${opentelekomcloud_vpc_v1.vpc_1.id} + vpcIdSelector: + matchLabels: + testing.upbound.io/example-name: vpc_1 --- @@ -82,12 +86,14 @@ spec: cidr: 172.16.10.0/24 gatewayIp: 172.16.10.1 name: vpc-2-subnet-2-1 - vpcId: ${opentelekomcloud_vpc_v1.vpc_2.id} + vpcIdSelector: + matchLabels: + testing.upbound.io/example-name: vpc_2 --- apiVersion: vpc.opentelekomcloud.crossplane.io/v1alpha1 -kind: V1 +kind: VpcV1 metadata: annotations: meta.upbound.io/example-id: vpc/v1alpha1/routetablev1 @@ -102,7 +108,7 @@ spec: --- apiVersion: vpc.opentelekomcloud.crossplane.io/v1alpha1 -kind: V1 +kind: VpcV1 metadata: annotations: meta.upbound.io/example-id: vpc/v1alpha1/routetablev1 diff --git a/examples-generated/vpc/subnetv1.yaml b/examples-generated/vpc/subnetv1.yaml index 7b7d2d2..95a6bfc 100644 --- a/examples-generated/vpc/subnetv1.yaml +++ b/examples-generated/vpc/subnetv1.yaml @@ -12,12 +12,14 @@ spec: gatewayIp: ${var.subnet_gateway_ip} name: ${var.subnet_name} ntpAddresses: 10.100.0.33,10.100.0.34 - vpcId: ${opentelekomcloud_vpc_v1.vpc_v1.id} + vpcIdSelector: + matchLabels: + testing.upbound.io/example-name: vpc_v1 --- apiVersion: vpc.opentelekomcloud.crossplane.io/v1alpha1 -kind: V1 +kind: VpcV1 metadata: annotations: meta.upbound.io/example-id: vpc/v1alpha1/subnetv1 diff --git a/examples-generated/vpc/v1.yaml b/examples-generated/vpc/vpcv1.yaml similarity index 77% rename from examples-generated/vpc/v1.yaml rename to examples-generated/vpc/vpcv1.yaml index e2f33e0..f8313e8 100644 --- a/examples-generated/vpc/v1.yaml +++ b/examples-generated/vpc/vpcv1.yaml @@ -1,8 +1,8 @@ apiVersion: vpc.opentelekomcloud.crossplane.io/v1alpha1 -kind: V1 +kind: VpcV1 metadata: annotations: - meta.upbound.io/example-id: vpc/v1alpha1/v1 + meta.upbound.io/example-id: vpc/v1alpha1/vpcv1 labels: testing.upbound.io/example-name: vpc_v1 name: vpc-v1 diff --git a/examples/ecs/instance.yaml b/examples/ecs/instance.yaml new file mode 100644 index 0000000..9293135 --- /dev/null +++ b/examples/ecs/instance.yaml @@ -0,0 +1,106 @@ +apiVersion: compute.opentelekomcloud.crossplane.io/v1alpha1 +kind: KeypairV2 +metadata: + annotations: + meta.upbound.io/example-id: compute/v1alpha1/keypairv2 + labels: + testing.upbound.io/example-name: sample-instance + name: sample-instance +spec: + forProvider: + name: crossplane-keypair + publicKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDTUED6lEQhwmmpqypHQLqGu8xoUzvT8/uHb9c/uSTNq/qk5GN7gOeK8bs9DvPf4BIYBj5CPzhaidVDue+poqfL9su0mZ1K+eldWoGwkmjOB22kiA9vYmKDEG5u+S3S2UxsM+k09Qh8WGGMuvmCRF7KyNf8rlSJns3bsyG0vDjKuo3hdoCQi5RW950VtaAaefRXfQqgk1y8SR2xZKM0e24yICHd1C40tb5RgiNx7s45VHfVY6XMO+eESeHyDEJMr1AoJhkuiziE1feYmLIC2C02wpRXdLxqu2DbrJfqaPWe0J5mZKTXAFzpr/kdReDDp0lgJhjcralcLSZVa1JhQ1iX4n7+v0YKa6WHInnjmeN4PLz8gBanE40OpkZI/DVIWbhX/CrYi+tpZKzYc9ZGdd9UDGPNUNwIMMvat73zp/arAhh9n2nl68/iqM/Xhs8BQ8PYYSuMkhEAZksmSN3Qr6PuE3OpmoHRt+nWwtap751O3JwI8Kmt2iH+I4EOD5cx2CPNjFEOnLLSRqcnQ6CszDfDxDfEAT3wNT/4spM7xqDcvUD523b91fJb1N5NjgmxAmksOxJlrJzTUbVLwLh+RcPd/Lz8kB/NX/peZhcUFLdRbdAUIIgKuEOPBTbFm39Hgj5YVSnSQIkXp6hwO7FSh88ps+8fTPgW01IKr8MG4GhiWQ== + +--- + +apiVersion: vpc.opentelekomcloud.crossplane.io/v1alpha1 +kind: VpcV1 +metadata: + annotations: + meta.upbound.io/example-id: vpc/v1alpha1/v1 + labels: + testing.upbound.io/example-name: sample-instance + name: sample-instance +spec: + forProvider: + cidr: "192.168.0.0/16" + name: crossplane-vpc + tags: + managed-by: crossplane +--- + +apiVersion: vpc.opentelekomcloud.crossplane.io/v1alpha1 +kind: SubnetV1 +metadata: + annotations: + meta.upbound.io/example-id: vpc/v1alpha1/subnetv1 + labels: + testing.upbound.io/example-name: sample-instance + name: sample-instance +spec: + forProvider: + cidr: "192.168.0.0/16" + gatewayIp: "192.168.0.1" + name: crossplane-subnet + ntpAddresses: "10.100.0.33,10.100.0.34" + vpcIdSelector: + matchLabels: + testing.upbound.io/example-name: sample-instance + tags: + managed-by: crossplane + +--- + +apiVersion: compute.opentelekomcloud.crossplane.io/v1alpha1 +kind: SecgroupV2 +metadata: + annotations: + meta.upbound.io/example-id: compute/v1alpha1/secgroupv2 + labels: + testing.upbound.io/example-name: sample-instance + name: sample-instance +spec: + forProvider: + description: crossplane security group + name: crossplane-sg + rule: + - cidr: 0.0.0.0/0 + fromPort: 22 + ipProtocol: tcp + toPort: 22 + - cidr: 0.0.0.0/0 + fromPort: 8080 + ipProtocol: tcp + toPort: 8080 + +--- + +apiVersion: ecs.opentelekomcloud.crossplane.io/v1alpha1 +kind: InstanceV1 +metadata: + annotations: + meta.upbound.io/example-id: ecs/v1alpha1/instancev1 + labels: + testing.upbound.io/example-name: sample-instance + name: sample-instance +spec: + forProvider: + availabilityZone: eu-de-01 + flavor: s2.large.2 + imageId: 54c617ad-5c85-4426-b721-494a9c7719c2 + keyNameSelector: + matchLabels: + testing.upbound.io/example-name: sample-instance + computeSecurityGroupIdSelector: + matchLabels: + testing.upbound.io/example-name: sample-instance + name: crossplane-instance-01 + nics: + - networkIdSelector: + matchLabels: + testing.upbound.io/example-name: sample-instance + tags: + managed-by: crossplane + vpcIdSelector: + matchLabels: + testing.upbound.io/example-name: sample-instance diff --git a/internal/controller/vpc/v1/zz_controller.go b/internal/controller/vpc/vpcv1/zz_controller.go similarity index 87% rename from internal/controller/vpc/v1/zz_controller.go rename to internal/controller/vpc/vpcv1/zz_controller.go index b6e0a76..19eca2d 100755 --- a/internal/controller/vpc/v1/zz_controller.go +++ b/internal/controller/vpc/vpcv1/zz_controller.go @@ -8,7 +8,7 @@ Copyright 2022 Upbound Inc. // Code generated by upjet. DO NOT EDIT. -package v1 +package vpcv1 import ( "time" @@ -27,16 +27,16 @@ import ( features "github.com/opentelekomcloud/provider-opentelekomcloud/internal/features" ) -// Setup adds a controller that reconciles V1 managed resources. +// Setup adds a controller that reconciles VpcV1 managed resources. func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { - name := managed.ControllerName(v1alpha1.V1_GroupVersionKind.String()) + name := managed.ControllerName(v1alpha1.VpcV1_GroupVersionKind.String()) var initializers managed.InitializerChain cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} if o.SecretStoreConfigGVK != nil { cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), *o.SecretStoreConfigGVK, connection.WithTLSConfig(o.ESSOptions.TLSConfig))) } - eventHandler := handler.NewEventHandler(handler.WithLogger(o.Logger.WithValues("gvk", v1alpha1.V1_GroupVersionKind))) - ac := tjcontroller.NewAPICallbacks(mgr, xpresource.ManagedKind(v1alpha1.V1_GroupVersionKind), tjcontroller.WithEventHandler(eventHandler)) + eventHandler := handler.NewEventHandler(handler.WithLogger(o.Logger.WithValues("gvk", v1alpha1.VpcV1_GroupVersionKind))) + ac := tjcontroller.NewAPICallbacks(mgr, xpresource.ManagedKind(v1alpha1.VpcV1_GroupVersionKind), tjcontroller.WithEventHandler(eventHandler)) opts := []managed.ReconcilerOption{ managed.WithExternalConnecter(tjcontroller.NewConnector(mgr.GetClient(), o.WorkspaceStore, o.SetupFn, o.Provider.Resources["opentelekomcloud_vpc_v1"], tjcontroller.WithLogger(o.Logger), tjcontroller.WithConnectorEventHandler(eventHandler), tjcontroller.WithCallbackProvider(ac), @@ -55,12 +55,12 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { if o.Features.Enabled(features.EnableBetaManagementPolicies) { opts = append(opts, managed.WithManagementPolicies()) } - r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1alpha1.V1_GroupVersionKind), opts...) + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1alpha1.VpcV1_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). Named(name). WithOptions(o.ForControllerRuntime()). WithEventFilter(xpresource.DesiredStateChanged()). - Watches(&v1alpha1.V1{}, eventHandler). + Watches(&v1alpha1.VpcV1{}, eventHandler). Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) } diff --git a/internal/controller/zz_setup.go b/internal/controller/zz_setup.go index ef1b2f4..0431759 100755 --- a/internal/controller/zz_setup.go +++ b/internal/controller/zz_setup.go @@ -132,7 +132,7 @@ import ( routetablev1 "github.com/opentelekomcloud/provider-opentelekomcloud/internal/controller/vpc/routetablev1" routev2 "github.com/opentelekomcloud/provider-opentelekomcloud/internal/controller/vpc/routev2" subnetv1 "github.com/opentelekomcloud/provider-opentelekomcloud/internal/controller/vpc/subnetv1" - v1 "github.com/opentelekomcloud/provider-opentelekomcloud/internal/controller/vpc/v1" + vpcv1 "github.com/opentelekomcloud/provider-opentelekomcloud/internal/controller/vpc/vpcv1" endpointv1 "github.com/opentelekomcloud/provider-opentelekomcloud/internal/controller/vpcep/endpointv1" servicev1 "github.com/opentelekomcloud/provider-opentelekomcloud/internal/controller/vpcep/servicev1" endpointgroupv2 "github.com/opentelekomcloud/provider-opentelekomcloud/internal/controller/vpnaas/endpointgroupv2" @@ -284,7 +284,7 @@ func Setup(mgr ctrl.Manager, o controller.Options) error { routetablev1.Setup, routev2.Setup, subnetv1.Setup, - v1.Setup, + vpcv1.Setup, endpointv1.Setup, servicev1.Setup, endpointgroupv2.Setup, diff --git a/package/crds/ecs.opentelekomcloud.crossplane.io_instancev1s.yaml b/package/crds/ecs.opentelekomcloud.crossplane.io_instancev1s.yaml index a9bbc2f..2ec7678 100644 --- a/package/crds/ecs.opentelekomcloud.crossplane.io_instancev1s.yaml +++ b/package/crds/ecs.opentelekomcloud.crossplane.io_instancev1s.yaml @@ -74,6 +74,83 @@ spec: description: The availability zone in which to create the server. Changing this creates a new server. type: string + computeSecurityGroupIdRefs: + description: References to SecgroupV2 in compute 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 + computeSecurityGroupIdSelector: + description: Selector for a list of SecgroupV2 in compute 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 dataDisks: description: An array of one or more data disks to attach to the instance. The data_disks object structure is documented below. @@ -117,6 +194,79 @@ spec: key pair must already be created and associated with the tenant's account. Changing this creates a new server. type: string + keyNameRef: + description: Reference to a KeypairV2 in compute to populate keyName. + 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 + keyNameSelector: + description: Selector for a KeypairV2 in compute to populate keyName. + 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 name: description: A unique name for the instance. type: string @@ -134,6 +284,84 @@ spec: description: The network UUID to attach to the server. Changing this creates a new server. type: string + networkIdRef: + description: Reference to a SubnetV1 in vpc to populate + networkId. + 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 + networkIdSelector: + description: Selector for a SubnetV1 in vpc to populate + networkId. + 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 type: object type: array passwordSecretRef: @@ -188,6 +416,79 @@ spec: description: The ID of the desired VPC for the server. Changing this creates a new server. type: string + vpcIdRef: + description: Reference to a VpcV1 in vpc to populate vpcId. + 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 + vpcIdSelector: + description: Selector for a VpcV1 in vpc to populate vpcId. + 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 type: object initProvider: description: THIS IS A BETA FIELD. It will be honored unless the Management @@ -246,11 +547,6 @@ spec: description: The ID of the desired image for the server. Changing this creates a new server. type: string - keyName: - description: The name of a key pair to put on the server. The - key pair must already be created and associated with the tenant's - account. Changing this creates a new server. - type: string name: description: A unique name for the instance. type: string @@ -264,19 +560,8 @@ spec: description: Specifies a fixed IPv4 address to be used on this network. Changing this creates a new server. type: string - networkId: - description: The network UUID to attach to the server. Changing - this creates a new server. - type: string type: object type: array - securityGroups: - description: An array of one or more security group IDs to associate - with the server. If this parameter is left blank, the default - security group is bound to the ECS by default. - items: - type: string - type: array systemDiskKmsId: description: The Encryption KMS ID of the system disk. Changing this creates a new server. @@ -300,10 +585,6 @@ spec: description: The user data to provide when launching the instance. Changing this creates a new server. type: string - vpcId: - description: The ID of the desired VPC for the server. Changing - this creates a new server. - type: string type: object managementPolicies: default: @@ -486,10 +767,6 @@ spec: rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies || ''Update'' in self.managementPolicies) || has(self.forProvider.nics) || (has(self.initProvider) && has(self.initProvider.nics))' - - message: spec.forProvider.vpcId is a required parameter - rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies - || ''Update'' in self.managementPolicies) || has(self.forProvider.vpcId) - || (has(self.initProvider) && has(self.initProvider.vpcId))' status: description: InstanceV1Status defines the observed state of InstanceV1. properties: diff --git a/package/crds/vpc.opentelekomcloud.crossplane.io_subnetv1s.yaml b/package/crds/vpc.opentelekomcloud.crossplane.io_subnetv1s.yaml index cf5f0fe..d2fc9e1 100644 --- a/package/crds/vpc.opentelekomcloud.crossplane.io_subnetv1s.yaml +++ b/package/crds/vpc.opentelekomcloud.crossplane.io_subnetv1s.yaml @@ -134,6 +134,79 @@ spec: description: Specifies the ID of the VPC to which the subnet belongs. Changing this creates a new Subnet. type: string + vpcIdRef: + description: Reference to a VpcV1 in vpc to populate vpcId. + 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 + vpcIdSelector: + description: Selector for a VpcV1 in vpc to populate vpcId. + 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 type: object initProvider: description: THIS IS A BETA FIELD. It will be honored unless the Management @@ -210,10 +283,6 @@ spec: type: string description: The key/value pairs to associate with the subnet. type: object - vpcId: - description: Specifies the ID of the VPC to which the subnet belongs. - Changing this creates a new Subnet. - type: string type: object managementPolicies: default: @@ -388,10 +457,6 @@ spec: rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies || ''Update'' in self.managementPolicies) || has(self.forProvider.name) || (has(self.initProvider) && has(self.initProvider.name))' - - message: spec.forProvider.vpcId is a required parameter - rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies - || ''Update'' in self.managementPolicies) || has(self.forProvider.vpcId) - || (has(self.initProvider) && has(self.initProvider.vpcId))' status: description: SubnetV1Status defines the observed state of SubnetV1. properties: diff --git a/package/crds/vpc.opentelekomcloud.crossplane.io_v1s.yaml b/package/crds/vpc.opentelekomcloud.crossplane.io_vpcv1s.yaml similarity index 98% rename from package/crds/vpc.opentelekomcloud.crossplane.io_v1s.yaml rename to package/crds/vpc.opentelekomcloud.crossplane.io_vpcv1s.yaml index 8aae96d..121e010 100644 --- a/package/crds/vpc.opentelekomcloud.crossplane.io_v1s.yaml +++ b/package/crds/vpc.opentelekomcloud.crossplane.io_vpcv1s.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.13.0 - name: v1s.vpc.opentelekomcloud.crossplane.io + name: vpcv1s.vpc.opentelekomcloud.crossplane.io spec: group: vpc.opentelekomcloud.crossplane.io names: @@ -12,10 +12,10 @@ spec: - crossplane - managed - opentelekomcloud - kind: V1 - listKind: V1List - plural: v1s - singular: v1 + kind: VpcV1 + listKind: VpcV1List + plural: vpcv1s + singular: vpcv1 scope: Cluster versions: - additionalPrinterColumns: @@ -34,8 +34,8 @@ spec: name: v1alpha1 schema: openAPIV3Schema: - description: V1 is the Schema for the V1s API. Manages a VPC resource within - OpenTelekomCloud. + description: VpcV1 is the Schema for the VpcV1s API. Manages a VPC resource + within OpenTelekomCloud. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -50,7 +50,7 @@ spec: metadata: type: object spec: - description: V1Spec defines the desired state of V1 + description: VpcV1Spec defines the desired state of VpcV1 properties: deletionPolicy: default: Delete @@ -319,7 +319,7 @@ spec: || ''Update'' in self.managementPolicies) || has(self.forProvider.name) || (has(self.initProvider) && has(self.initProvider.name))' status: - description: V1Status defines the observed state of V1. + description: VpcV1Status defines the observed state of VpcV1. properties: atProvider: properties: