diff --git a/apis/metal/v1alpha1/zz_device_types.go b/apis/metal/v1alpha1/zz_device_types.go index 821730b..14a4caf 100755 --- a/apis/metal/v1alpha1/zz_device_types.go +++ b/apis/metal/v1alpha1/zz_device_types.go @@ -123,8 +123,17 @@ type DeviceInitParameters struct { // (List of String) Array of IDs of the project SSH keys which should be added to the device. If you specify this array, only the listed project SSH keys (and any SSH keys for the users specified in user_ssh_key_ids) will be added. If no SSH keys are specified (both user_ssh_keys_ids and project_ssh_key_ids are empty lists or omitted), all parent project keys, parent project members keys and organization members keys will be included. Project SSH keys can be created with the equinix_metal_project_ssh_key resource // Array of IDs of the project SSH keys which should be added to the device. If you specify this array, only the listed project SSH keys (and any SSH keys for the users specified in user_ssh_key_ids) will be added. If no SSH keys are specified (both user_ssh_keys_ids and project_ssh_key_ids are empty lists or omitted), all parent project keys, parent project members keys and organization members keys will be included. Project SSH keys can be created with the [equinix_metal_project_ssh_key](equinix_metal_project_ssh_key.md) resource + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-jet-equinix/apis/metal/v1alpha1.ProjectSSHKey ProjectSSHKeyIds []*string `json:"projectSshKeyIds,omitempty" tf:"project_ssh_key_ids,omitempty"` + // References to ProjectSSHKey in metal to populate projectSshKeyIds. + // +kubebuilder:validation:Optional + ProjectSSHKeyIdsRefs []v1.Reference `json:"projectSshKeyIdsRefs,omitempty" tf:"-"` + + // Selector for a list of ProjectSSHKey in metal to populate projectSshKeyIds. + // +kubebuilder:validation:Optional + ProjectSSHKeyIdsSelector *v1.Selector `json:"projectSshKeyIdsSelector,omitempty" tf:"-"` + // (Block List, Max: 1) (see below for nested schema) Reinstall *ReinstallInitParameters `json:"reinstall,omitempty" tf:"reinstall,omitempty"` @@ -146,8 +155,17 @@ type DeviceInitParameters struct { // (List of String) Array of IDs of the users whose SSH keys should be added to the device. If you specify this array, only the listed users' SSH keys (and any project SSH keys specified in project_ssh_key_ids) will be added. If no SSH keys are specified (both user_ssh_keys_ids and project_ssh_key_ids are empty lists or omitted), all parent project keys, parent project members keys and organization members keys will be included. User SSH keys can be created with the equinix_metal_ssh_key resource // Array of IDs of the users whose SSH keys should be added to the device. If you specify this array, only the listed users' SSH keys (and any project SSH keys specified in project_ssh_key_ids) will be added. If no SSH keys are specified (both user_ssh_keys_ids and project_ssh_key_ids are empty lists or omitted), all parent project keys, parent project members keys and organization members keys will be included. User SSH keys can be created with the [equinix_metal_ssh_key](equinix_metal_ssh_key.md) resource + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-jet-equinix/apis/metal/v1alpha1.SSHKey UserSSHKeyIds []*string `json:"userSshKeyIds,omitempty" tf:"user_ssh_key_ids,omitempty"` + // References to SSHKey in metal to populate userSshKeyIds. + // +kubebuilder:validation:Optional + UserSSHKeyIdsRefs []v1.Reference `json:"userSshKeyIdsRefs,omitempty" tf:"-"` + + // Selector for a list of SSHKey in metal to populate userSshKeyIds. + // +kubebuilder:validation:Optional + UserSSHKeyIdsSelector *v1.Selector `json:"userSshKeyIdsSelector,omitempty" tf:"-"` + // (Boolean) Only used for devices in reserved hardware. If set, the deletion of this device will block until the hardware reservation is marked provisionable (about 4 minutes in August 2019) // Only used for devices in reserved hardware. If set, the deletion of this device will block until the hardware reservation is marked provisionable (about 4 minutes in August 2019) WaitForReservationDeprovision *bool `json:"waitForReservationDeprovision,omitempty" tf:"wait_for_reservation_deprovision,omitempty"` @@ -389,9 +407,18 @@ type DeviceParameters struct { // (List of String) Array of IDs of the project SSH keys which should be added to the device. If you specify this array, only the listed project SSH keys (and any SSH keys for the users specified in user_ssh_key_ids) will be added. If no SSH keys are specified (both user_ssh_keys_ids and project_ssh_key_ids are empty lists or omitted), all parent project keys, parent project members keys and organization members keys will be included. Project SSH keys can be created with the equinix_metal_project_ssh_key resource // Array of IDs of the project SSH keys which should be added to the device. If you specify this array, only the listed project SSH keys (and any SSH keys for the users specified in user_ssh_key_ids) will be added. If no SSH keys are specified (both user_ssh_keys_ids and project_ssh_key_ids are empty lists or omitted), all parent project keys, parent project members keys and organization members keys will be included. Project SSH keys can be created with the [equinix_metal_project_ssh_key](equinix_metal_project_ssh_key.md) resource + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-jet-equinix/apis/metal/v1alpha1.ProjectSSHKey // +kubebuilder:validation:Optional ProjectSSHKeyIds []*string `json:"projectSshKeyIds,omitempty" tf:"project_ssh_key_ids,omitempty"` + // References to ProjectSSHKey in metal to populate projectSshKeyIds. + // +kubebuilder:validation:Optional + ProjectSSHKeyIdsRefs []v1.Reference `json:"projectSshKeyIdsRefs,omitempty" tf:"-"` + + // Selector for a list of ProjectSSHKey in metal to populate projectSshKeyIds. + // +kubebuilder:validation:Optional + ProjectSSHKeyIdsSelector *v1.Selector `json:"projectSshKeyIdsSelector,omitempty" tf:"-"` + // (Block List, Max: 1) (see below for nested schema) // +kubebuilder:validation:Optional Reinstall *ReinstallParameters `json:"reinstall,omitempty" tf:"reinstall,omitempty"` @@ -418,9 +445,18 @@ type DeviceParameters struct { // (List of String) Array of IDs of the users whose SSH keys should be added to the device. If you specify this array, only the listed users' SSH keys (and any project SSH keys specified in project_ssh_key_ids) will be added. If no SSH keys are specified (both user_ssh_keys_ids and project_ssh_key_ids are empty lists or omitted), all parent project keys, parent project members keys and organization members keys will be included. User SSH keys can be created with the equinix_metal_ssh_key resource // Array of IDs of the users whose SSH keys should be added to the device. If you specify this array, only the listed users' SSH keys (and any project SSH keys specified in project_ssh_key_ids) will be added. If no SSH keys are specified (both user_ssh_keys_ids and project_ssh_key_ids are empty lists or omitted), all parent project keys, parent project members keys and organization members keys will be included. User SSH keys can be created with the [equinix_metal_ssh_key](equinix_metal_ssh_key.md) resource + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-jet-equinix/apis/metal/v1alpha1.SSHKey // +kubebuilder:validation:Optional UserSSHKeyIds []*string `json:"userSshKeyIds,omitempty" tf:"user_ssh_key_ids,omitempty"` + // References to SSHKey in metal to populate userSshKeyIds. + // +kubebuilder:validation:Optional + UserSSHKeyIdsRefs []v1.Reference `json:"userSshKeyIdsRefs,omitempty" tf:"-"` + + // Selector for a list of SSHKey in metal to populate userSshKeyIds. + // +kubebuilder:validation:Optional + UserSSHKeyIdsSelector *v1.Selector `json:"userSshKeyIdsSelector,omitempty" tf:"-"` + // (Boolean) Only used for devices in reserved hardware. If set, the deletion of this device will block until the hardware reservation is marked provisionable (about 4 minutes in August 2019) // Only used for devices in reserved hardware. If set, the deletion of this device will block until the hardware reservation is marked provisionable (about 4 minutes in August 2019) // +kubebuilder:validation:Optional diff --git a/apis/metal/v1alpha1/zz_generated.deepcopy.go b/apis/metal/v1alpha1/zz_generated.deepcopy.go index 98ffc1d..b88ca44 100644 --- a/apis/metal/v1alpha1/zz_generated.deepcopy.go +++ b/apis/metal/v1alpha1/zz_generated.deepcopy.go @@ -1163,6 +1163,18 @@ func (in *DeviceInitParameters) DeepCopyInto(out *DeviceInitParameters) { } } } + if in.ProjectSSHKeyIdsRefs != nil { + in, out := &in.ProjectSSHKeyIdsRefs, &out.ProjectSSHKeyIdsRefs + *out = make([]v1.Reference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ProjectSSHKeyIdsSelector != nil { + in, out := &in.ProjectSSHKeyIdsSelector, &out.ProjectSSHKeyIdsSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.Reinstall != nil { in, out := &in.Reinstall, &out.Reinstall *out = new(ReinstallInitParameters) @@ -1205,6 +1217,18 @@ func (in *DeviceInitParameters) DeepCopyInto(out *DeviceInitParameters) { } } } + if in.UserSSHKeyIdsRefs != nil { + in, out := &in.UserSSHKeyIdsRefs, &out.UserSSHKeyIdsRefs + *out = make([]v1.Reference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.UserSSHKeyIdsSelector != nil { + in, out := &in.UserSSHKeyIdsSelector, &out.UserSSHKeyIdsSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.WaitForReservationDeprovision != nil { in, out := &in.WaitForReservationDeprovision, &out.WaitForReservationDeprovision *out = new(bool) @@ -1791,6 +1815,18 @@ func (in *DeviceParameters) DeepCopyInto(out *DeviceParameters) { } } } + if in.ProjectSSHKeyIdsRefs != nil { + in, out := &in.ProjectSSHKeyIdsRefs, &out.ProjectSSHKeyIdsRefs + *out = make([]v1.Reference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ProjectSSHKeyIdsSelector != nil { + in, out := &in.ProjectSSHKeyIdsSelector, &out.ProjectSSHKeyIdsSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.Reinstall != nil { in, out := &in.Reinstall, &out.Reinstall *out = new(ReinstallParameters) @@ -1833,6 +1869,18 @@ func (in *DeviceParameters) DeepCopyInto(out *DeviceParameters) { } } } + if in.UserSSHKeyIdsRefs != nil { + in, out := &in.UserSSHKeyIdsRefs, &out.UserSSHKeyIdsRefs + *out = make([]v1.Reference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.UserSSHKeyIdsSelector != nil { + in, out := &in.UserSSHKeyIdsSelector, &out.UserSSHKeyIdsSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.WaitForReservationDeprovision != nil { in, out := &in.WaitForReservationDeprovision, &out.WaitForReservationDeprovision *out = new(bool) @@ -3619,6 +3667,18 @@ func (in *PortInitParameters) DeepCopyInto(out *PortInitParameters) { } } } + if in.VlanIdsRefs != nil { + in, out := &in.VlanIdsRefs, &out.VlanIdsRefs + *out = make([]v1.Reference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.VlanIdsSelector != nil { + in, out := &in.VlanIdsSelector, &out.VlanIdsSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.VxlanIds != nil { in, out := &in.VxlanIds, &out.VxlanIds *out = make([]*float64, len(*in)) @@ -3825,6 +3885,18 @@ func (in *PortParameters) DeepCopyInto(out *PortParameters) { } } } + if in.VlanIdsRefs != nil { + in, out := &in.VlanIdsRefs, &out.VlanIdsRefs + *out = make([]v1.Reference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.VlanIdsSelector != nil { + in, out := &in.VlanIdsSelector, &out.VlanIdsSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.VxlanIds != nil { in, out := &in.VxlanIds, &out.VxlanIds *out = make([]*float64, len(*in)) diff --git a/apis/metal/v1alpha1/zz_generated.resolvers.go b/apis/metal/v1alpha1/zz_generated.resolvers.go index 4e59338..97497ca 100644 --- a/apis/metal/v1alpha1/zz_generated.resolvers.go +++ b/apis/metal/v1alpha1/zz_generated.resolvers.go @@ -145,6 +145,7 @@ func (mg *Device) 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{ @@ -163,6 +164,38 @@ func (mg *Device) ResolveReferences(ctx context.Context, c client.Reader) error mg.Spec.ForProvider.ProjectID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ProjectIDRef = rsp.ResolvedReference + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.ProjectSSHKeyIds), + Extract: reference.ExternalName(), + References: mg.Spec.ForProvider.ProjectSSHKeyIdsRefs, + Selector: mg.Spec.ForProvider.ProjectSSHKeyIdsSelector, + To: reference.To{ + List: &ProjectSSHKeyList{}, + Managed: &ProjectSSHKey{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.ProjectSSHKeyIds") + } + mg.Spec.ForProvider.ProjectSSHKeyIds = reference.ToPtrValues(mrsp.ResolvedValues) + mg.Spec.ForProvider.ProjectSSHKeyIdsRefs = mrsp.ResolvedReferences + + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.UserSSHKeyIds), + Extract: reference.ExternalName(), + References: mg.Spec.ForProvider.UserSSHKeyIdsRefs, + Selector: mg.Spec.ForProvider.UserSSHKeyIdsSelector, + To: reference.To{ + List: &SSHKeyList{}, + Managed: &SSHKey{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.UserSSHKeyIds") + } + mg.Spec.ForProvider.UserSSHKeyIds = reference.ToPtrValues(mrsp.ResolvedValues) + mg.Spec.ForProvider.UserSSHKeyIdsRefs = mrsp.ResolvedReferences + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.ProjectID), Extract: reference.ExternalName(), @@ -179,6 +212,38 @@ func (mg *Device) ResolveReferences(ctx context.Context, c client.Reader) error mg.Spec.InitProvider.ProjectID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ProjectIDRef = rsp.ResolvedReference + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.ProjectSSHKeyIds), + Extract: reference.ExternalName(), + References: mg.Spec.InitProvider.ProjectSSHKeyIdsRefs, + Selector: mg.Spec.InitProvider.ProjectSSHKeyIdsSelector, + To: reference.To{ + List: &ProjectSSHKeyList{}, + Managed: &ProjectSSHKey{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.InitProvider.ProjectSSHKeyIds") + } + mg.Spec.InitProvider.ProjectSSHKeyIds = reference.ToPtrValues(mrsp.ResolvedValues) + mg.Spec.InitProvider.ProjectSSHKeyIdsRefs = mrsp.ResolvedReferences + + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.UserSSHKeyIds), + Extract: reference.ExternalName(), + References: mg.Spec.InitProvider.UserSSHKeyIdsRefs, + Selector: mg.Spec.InitProvider.UserSSHKeyIdsSelector, + To: reference.To{ + List: &SSHKeyList{}, + Managed: &SSHKey{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.InitProvider.UserSSHKeyIds") + } + mg.Spec.InitProvider.UserSSHKeyIds = reference.ToPtrValues(mrsp.ResolvedValues) + mg.Spec.InitProvider.UserSSHKeyIdsRefs = mrsp.ResolvedReferences + return nil } @@ -419,6 +484,7 @@ func (mg *Port) 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{ @@ -437,6 +503,22 @@ func (mg *Port) ResolveReferences(ctx context.Context, c client.Reader) error { mg.Spec.ForProvider.NativeVlanID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.NativeVlanIDRef = rsp.ResolvedReference + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.VlanIds), + Extract: reference.ExternalName(), + References: mg.Spec.ForProvider.VlanIdsRefs, + Selector: mg.Spec.ForProvider.VlanIdsSelector, + To: reference.To{ + List: &VlanList{}, + Managed: &Vlan{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.VlanIds") + } + mg.Spec.ForProvider.VlanIds = reference.ToPtrValues(mrsp.ResolvedValues) + mg.Spec.ForProvider.VlanIdsRefs = mrsp.ResolvedReferences + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.NativeVlanID), Extract: reference.ExternalName(), @@ -453,6 +535,22 @@ func (mg *Port) ResolveReferences(ctx context.Context, c client.Reader) error { mg.Spec.InitProvider.NativeVlanID = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.NativeVlanIDRef = rsp.ResolvedReference + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ + CurrentValues: reference.FromPtrValues(mg.Spec.InitProvider.VlanIds), + Extract: reference.ExternalName(), + References: mg.Spec.InitProvider.VlanIdsRefs, + Selector: mg.Spec.InitProvider.VlanIdsSelector, + To: reference.To{ + List: &VlanList{}, + Managed: &Vlan{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.InitProvider.VlanIds") + } + mg.Spec.InitProvider.VlanIds = reference.ToPtrValues(mrsp.ResolvedValues) + mg.Spec.InitProvider.VlanIdsRefs = mrsp.ResolvedReferences + return nil } diff --git a/apis/metal/v1alpha1/zz_port_types.go b/apis/metal/v1alpha1/zz_port_types.go index e0d079e..c996d46 100755 --- a/apis/metal/v1alpha1/zz_port_types.go +++ b/apis/metal/v1alpha1/zz_port_types.go @@ -52,9 +52,18 @@ type PortInitParameters struct { ResetOnDelete *bool `json:"resetOnDelete,omitempty" tf:"reset_on_delete,omitempty"` // UUIDs VLANs to attach. To avoid jitter, use the UUID and not the VXLAN + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-jet-equinix/apis/metal/v1alpha1.Vlan // +listType=set VlanIds []*string `json:"vlanIds,omitempty" tf:"vlan_ids,omitempty"` + // References to Vlan in metal to populate vlanIds. + // +kubebuilder:validation:Optional + VlanIdsRefs []v1.Reference `json:"vlanIdsRefs,omitempty" tf:"-"` + + // Selector for a list of Vlan in metal to populate vlanIds. + // +kubebuilder:validation:Optional + VlanIdsSelector *v1.Selector `json:"vlanIdsSelector,omitempty" tf:"-"` + // VLAN VXLAN ids to attach (example: [1000]) // +listType=set VxlanIds []*float64 `json:"vxlanIds,omitempty" tf:"vxlan_ids,omitempty"` @@ -141,10 +150,19 @@ type PortParameters struct { ResetOnDelete *bool `json:"resetOnDelete,omitempty" tf:"reset_on_delete,omitempty"` // UUIDs VLANs to attach. To avoid jitter, use the UUID and not the VXLAN + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-jet-equinix/apis/metal/v1alpha1.Vlan // +kubebuilder:validation:Optional // +listType=set VlanIds []*string `json:"vlanIds,omitempty" tf:"vlan_ids,omitempty"` + // References to Vlan in metal to populate vlanIds. + // +kubebuilder:validation:Optional + VlanIdsRefs []v1.Reference `json:"vlanIdsRefs,omitempty" tf:"-"` + + // Selector for a list of Vlan in metal to populate vlanIds. + // +kubebuilder:validation:Optional + VlanIdsSelector *v1.Selector `json:"vlanIdsSelector,omitempty" tf:"-"` + // VLAN VXLAN ids to attach (example: [1000]) // +kubebuilder:validation:Optional // +listType=set diff --git a/config/overrides.go b/config/overrides.go index a2a56a0..6f748a5 100644 --- a/config/overrides.go +++ b/config/overrides.go @@ -27,6 +27,7 @@ import ( // IdentifierAssignedByEquinix will work for all Equinix types because even if // the ID is assigned by user, we'll see it in the TF State ID. The // resource-specific configurations should override this whenever possible. +// See https://github.com/crossplane/upjet/blob/main/docs/configuring-a-resource.md#case-2-identifier-from-provider for more details. func IdentifierAssignedByEquinix() upconfig.ResourceOption { return func(r *upconfig.Resource) { r.ExternalName = upconfig.IdentifierFromProvider @@ -35,20 +36,30 @@ func IdentifierAssignedByEquinix() upconfig.ResourceOption { var knownReferencerTFResource = map[string]map[string]string{ "metal": { - "project_id": "equinix_metal_project", - "organization_id": "equinix_metal_organization", - "connection_id": "equinix_metal_connection", - "device_id": "equinix_metal_device", - "vlan_id": "equinix_metal_vlan", - "vrf_id": "equinix_metal_vrf", - "ip_reservation_id": "equinix_metal_reserved_ip_block", - "virtual_circuit_id": "equinix_metal_virtual_circuit", - "gateway_id": "equinix_metal_gateway", + "project_id": "equinix_metal_project", + "project_ids": "equinix_metal_project", + "organization_id": "equinix_metal_organization", + "connection_id": "equinix_metal_connection", + "device_id": "equinix_metal_device", + "vlan_id": "equinix_metal_vlan", + "vlan_ids": "equinix_metal_vlan", + "vrf_id": "equinix_metal_vrf", + "ip_reservation_id": "equinix_metal_reserved_ip_block", + "virtual_circuit_id": "equinix_metal_virtual_circuit", + "gateway_id": "equinix_metal_gateway", + "project_ssh_key_ids": "equinix_metal_project_ssh_key", + "user_ssh_key_ids": "equinix_metal_ssh_key", + // "ssh_key_ids" // These would be ambiguously matched to the above at random, so leave them out. + }, + "network": { + // TODO: need a way to disambiguate id from redundant_uuid. the user may want to reference both from the same equinix_network_device. + // "device_ids": "equinix_network_device", }, } // KnownReferencers adds referencers for fields that are known and common among // more than a few resources. +// See https://github.com/crossplane/upjet/blob/main/docs/configuring-a-resource.md#cross-resource-referencing for more details. func KnownReferencers() upconfig.ResourceOption { return func(r *upconfig.Resource) { for k, s := range r.TerraformResource.Schema { @@ -67,12 +78,15 @@ func KnownReferencers() upconfig.ResourceOption { r.References[k] = upconfig.Reference{ TerraformName: resource, } + break // TODO: if there are multiple suffix matches, only the first processed will be handled. Go map order is random. } } } } // SkipOptCompLateIntialization generalize the LateInitializer rule above to apply to allow fields that are Optional + Computed + ConflictsWith another Computed + Optional field +// See https://github.com/crossplane/upjet/blob/main/docs/configuring-a-resource.md#further-details-on-late-initialization for details on this mutually-exclusive scenario +// See https://github.com/crossplane/upjet/blob/main/docs/configuring-a-resource.md#overriding-terraform-resource-schema for default behavior func SkipOptCompLateInitialization() upconfig.ResourceOption { return func(r *upconfig.Resource) { for k, s := range r.TerraformResource.Schema { diff --git a/examples-generated/metal/v1alpha1/projectsshkey.yaml b/examples-generated/metal/v1alpha1/projectsshkey.yaml index 14f82b1..be4b592 100644 --- a/examples-generated/metal/v1alpha1/projectsshkey.yaml +++ b/examples-generated/metal/v1alpha1/projectsshkey.yaml @@ -35,5 +35,5 @@ spec: projectIdSelector: matchLabels: testing.upbound.io/example-name: example - projectSshKeyIds: - - ${equinix_metal_project_ssh_key.test.id} + projectSshKeyIdsRefs: + - name: test diff --git a/package/crds/metal.equinix.jet.crossplane.io_devices.yaml b/package/crds/metal.equinix.jet.crossplane.io_devices.yaml index 6d413c1..49d07a3 100644 --- a/package/crds/metal.equinix.jet.crossplane.io_devices.yaml +++ b/package/crds/metal.equinix.jet.crossplane.io_devices.yaml @@ -275,6 +275,85 @@ spec: items: type: string type: array + projectSshKeyIdsRefs: + description: References to ProjectSSHKey in metal to populate + projectSshKeyIds. + 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 + projectSshKeyIdsSelector: + description: Selector for a list of ProjectSSHKey in metal to + populate projectSshKeyIds. + 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 reinstall: description: '(Block List, Max: 1) (see below for nested schema)' properties: @@ -337,6 +416,84 @@ spec: items: type: string type: array + userSshKeyIdsRefs: + description: References to SSHKey in metal to populate userSshKeyIds. + 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 + userSshKeyIdsSelector: + description: Selector for a list of SSHKey in metal to populate + userSshKeyIds. + 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 waitForReservationDeprovision: description: |- (Boolean) Only used for devices in reserved hardware. If set, the deletion of this device will block until the hardware reservation is marked provisionable (about 4 minutes in August 2019) @@ -559,6 +716,85 @@ spec: items: type: string type: array + projectSshKeyIdsRefs: + description: References to ProjectSSHKey in metal to populate + projectSshKeyIds. + 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 + projectSshKeyIdsSelector: + description: Selector for a list of ProjectSSHKey in metal to + populate projectSshKeyIds. + 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 reinstall: description: '(Block List, Max: 1) (see below for nested schema)' properties: @@ -621,6 +857,84 @@ spec: items: type: string type: array + userSshKeyIdsRefs: + description: References to SSHKey in metal to populate userSshKeyIds. + 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 + userSshKeyIdsSelector: + description: Selector for a list of SSHKey in metal to populate + userSshKeyIds. + 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 waitForReservationDeprovision: description: |- (Boolean) Only used for devices in reserved hardware. If set, the deletion of this device will block until the hardware reservation is marked provisionable (about 4 minutes in August 2019) diff --git a/package/crds/metal.equinix.jet.crossplane.io_ports.yaml b/package/crds/metal.equinix.jet.crossplane.io_ports.yaml index cc4a891..441d0bf 100644 --- a/package/crds/metal.equinix.jet.crossplane.io_ports.yaml +++ b/package/crds/metal.equinix.jet.crossplane.io_ports.yaml @@ -170,6 +170,84 @@ spec: type: string type: array x-kubernetes-list-type: set + vlanIdsRefs: + description: References to Vlan in metal to populate vlanIds. + 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 + vlanIdsSelector: + description: Selector for a list of Vlan in metal to populate + vlanIds. + 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 vxlanIds: description: 'VLAN VXLAN ids to attach (example: [1000])' items: @@ -288,6 +366,84 @@ spec: type: string type: array x-kubernetes-list-type: set + vlanIdsRefs: + description: References to Vlan in metal to populate vlanIds. + 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 + vlanIdsSelector: + description: Selector for a list of Vlan in metal to populate + vlanIds. + 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 vxlanIds: description: 'VLAN VXLAN ids to attach (example: [1000])' items: