diff --git a/README.md b/README.md index dcc4da9..d2dce71 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ open an [issue](https://github.com/straw-hat-team/provider-digitalocean/issues). - [ ] digitalocean_certificate - [ ] digitalocean_container_registry - [ ] digitalocean_container_registry_docker_credentials -- [ ] digitalocean_custom_image +- [x] digitalocean_custom_image - [x] digitalocean_database_cluster - [ ] digitalocean_database_connection_pool - [ ] digitalocean_database_db diff --git a/apis/compute/v1alpha1/zz_droplet_types.go b/apis/compute/v1alpha1/zz_droplet_types.go index 34fd985..ab963bf 100755 --- a/apis/compute/v1alpha1/zz_droplet_types.go +++ b/apis/compute/v1alpha1/zz_droplet_types.go @@ -44,9 +44,6 @@ type DropletInitParameters struct { // The IPv6 address IPv6Address *string `json:"ipv6Address,omitempty" tf:"ipv6_address,omitempty"` - // The Droplet image ID or slug. This could be either image ID or droplet snapshot ID. - Image *string `json:"image,omitempty" tf:"image,omitempty"` - // Boolean controlling whether monitoring agent is installed. // Defaults to false. If set to true, you can configure monitor alert policies // monitor alert resource @@ -223,9 +220,18 @@ type DropletParameters struct { IPv6Address *string `json:"ipv6Address,omitempty" tf:"ipv6_address,omitempty"` // The Droplet image ID or slug. This could be either image ID or droplet snapshot ID. + // +crossplane:generate:reference:type=github.com/straw-hat-team/provider-digitalocean/apis/custom/v1alpha1.Image // +kubebuilder:validation:Optional Image *string `json:"image,omitempty" tf:"image,omitempty"` + // Reference to a Image in custom to populate image. + // +kubebuilder:validation:Optional + ImageRef *v1.Reference `json:"imageRef,omitempty" tf:"-"` + + // Selector for a Image in custom to populate image. + // +kubebuilder:validation:Optional + ImageSelector *v1.Selector `json:"imageSelector,omitempty" tf:"-"` + // Boolean controlling whether monitoring agent is installed. // Defaults to false. If set to true, you can configure monitor alert policies // monitor alert resource @@ -335,7 +341,6 @@ type DropletStatus struct { type Droplet 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.image) || (has(self.initProvider) && has(self.initProvider.image))",message="spec.forProvider.image 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.size) || (has(self.initProvider) && has(self.initProvider.size))",message="spec.forProvider.size is a required parameter" Spec DropletSpec `json:"spec"` diff --git a/apis/compute/v1alpha1/zz_generated.deepcopy.go b/apis/compute/v1alpha1/zz_generated.deepcopy.go index f76e4f7..5a413ed 100644 --- a/apis/compute/v1alpha1/zz_generated.deepcopy.go +++ b/apis/compute/v1alpha1/zz_generated.deepcopy.go @@ -68,11 +68,6 @@ func (in *DropletInitParameters) DeepCopyInto(out *DropletInitParameters) { *out = new(string) **out = **in } - if in.Image != nil { - in, out := &in.Image, &out.Image - *out = new(string) - **out = **in - } if in.Monitoring != nil { in, out := &in.Monitoring, &out.Monitoring *out = new(bool) @@ -379,6 +374,16 @@ func (in *DropletParameters) DeepCopyInto(out *DropletParameters) { *out = new(string) **out = **in } + if in.ImageRef != nil { + in, out := &in.ImageRef, &out.ImageRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.ImageSelector != nil { + in, out := &in.ImageSelector, &out.ImageSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.Monitoring != nil { in, out := &in.Monitoring, &out.Monitoring *out = new(bool) diff --git a/apis/compute/v1alpha1/zz_generated.resolvers.go b/apis/compute/v1alpha1/zz_generated.resolvers.go index e3f4b04..5c85022 100644 --- a/apis/compute/v1alpha1/zz_generated.resolvers.go +++ b/apis/compute/v1alpha1/zz_generated.resolvers.go @@ -9,8 +9,9 @@ import ( "context" reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" - v1alpha11 "github.com/straw-hat-team/provider-digitalocean/apis/digitalocean/v1alpha1" - v1alpha1 "github.com/straw-hat-team/provider-digitalocean/apis/ssh/v1alpha1" + v1alpha1 "github.com/straw-hat-team/provider-digitalocean/apis/custom/v1alpha1" + v1alpha12 "github.com/straw-hat-team/provider-digitalocean/apis/digitalocean/v1alpha1" + v1alpha11 "github.com/straw-hat-team/provider-digitalocean/apis/ssh/v1alpha1" client "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -18,17 +19,34 @@ import ( func (mg *Droplet) 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.Image), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.ImageRef, + Selector: mg.Spec.ForProvider.ImageSelector, + To: reference.To{ + List: &v1alpha1.ImageList{}, + Managed: &v1alpha1.Image{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.Image") + } + mg.Spec.ForProvider.Image = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.ImageRef = rsp.ResolvedReference + mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{ CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.SSHKeys), Extract: reference.ExternalName(), References: mg.Spec.ForProvider.SSHKeysRefs, Selector: mg.Spec.ForProvider.SSHKeysSelector, To: reference.To{ - List: &v1alpha1.KeyList{}, - Managed: &v1alpha1.Key{}, + List: &v1alpha11.KeyList{}, + Managed: &v1alpha11.Key{}, }, }) if err != nil { @@ -43,8 +61,8 @@ func (mg *Droplet) ResolveReferences(ctx context.Context, c client.Reader) error References: mg.Spec.ForProvider.TagsRefs, Selector: mg.Spec.ForProvider.TagsSelector, To: reference.To{ - List: &v1alpha11.TagList{}, - Managed: &v1alpha11.Tag{}, + List: &v1alpha12.TagList{}, + Managed: &v1alpha12.Tag{}, }, }) if err != nil { diff --git a/apis/custom/v1alpha1/zz_generated.deepcopy.go b/apis/custom/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000..32ce030 --- /dev/null +++ b/apis/custom/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,323 @@ +//go:build !ignore_autogenerated + +/* +Copyright 2022 Upbound Inc. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Image) DeepCopyInto(out *Image) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Image. +func (in *Image) DeepCopy() *Image { + if in == nil { + return nil + } + out := new(Image) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Image) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageInitParameters) DeepCopyInto(out *ImageInitParameters) { + *out = *in + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.Distribution != nil { + in, out := &in.Distribution, &out.Distribution + *out = new(string) + **out = **in + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Regions != nil { + in, out := &in.Regions, &out.Regions + *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.Tags != nil { + in, out := &in.Tags, &out.Tags + *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.URL != nil { + in, out := &in.URL, &out.URL + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageInitParameters. +func (in *ImageInitParameters) DeepCopy() *ImageInitParameters { + if in == nil { + return nil + } + out := new(ImageInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageList) DeepCopyInto(out *ImageList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Image, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageList. +func (in *ImageList) DeepCopy() *ImageList { + if in == nil { + return nil + } + out := new(ImageList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ImageList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageObservation) DeepCopyInto(out *ImageObservation) { + *out = *in + if in.CreatedAt != nil { + in, out := &in.CreatedAt, &out.CreatedAt + *out = new(string) + **out = **in + } + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.Distribution != nil { + in, out := &in.Distribution, &out.Distribution + *out = new(string) + **out = **in + } + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.ImageID != nil { + in, out := &in.ImageID, &out.ImageID + *out = new(float64) + **out = **in + } + if in.MinDiskSize != nil { + in, out := &in.MinDiskSize, &out.MinDiskSize + *out = new(float64) + **out = **in + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Public != nil { + in, out := &in.Public, &out.Public + *out = new(bool) + **out = **in + } + if in.Regions != nil { + in, out := &in.Regions, &out.Regions + *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.SizeGigabytes != nil { + in, out := &in.SizeGigabytes, &out.SizeGigabytes + *out = new(float64) + **out = **in + } + if in.Slug != nil { + in, out := &in.Slug, &out.Slug + *out = new(string) + **out = **in + } + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(string) + **out = **in + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *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.Type != nil { + in, out := &in.Type, &out.Type + *out = new(string) + **out = **in + } + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageObservation. +func (in *ImageObservation) DeepCopy() *ImageObservation { + if in == nil { + return nil + } + out := new(ImageObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageParameters) DeepCopyInto(out *ImageParameters) { + *out = *in + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.Distribution != nil { + in, out := &in.Distribution, &out.Distribution + *out = new(string) + **out = **in + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Regions != nil { + in, out := &in.Regions, &out.Regions + *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.Tags != nil { + in, out := &in.Tags, &out.Tags + *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.URL != nil { + in, out := &in.URL, &out.URL + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageParameters. +func (in *ImageParameters) DeepCopy() *ImageParameters { + if in == nil { + return nil + } + out := new(ImageParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageSpec) DeepCopyInto(out *ImageSpec) { + *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 ImageSpec. +func (in *ImageSpec) DeepCopy() *ImageSpec { + if in == nil { + return nil + } + out := new(ImageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageStatus) DeepCopyInto(out *ImageStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageStatus. +func (in *ImageStatus) DeepCopy() *ImageStatus { + if in == nil { + return nil + } + out := new(ImageStatus) + in.DeepCopyInto(out) + return out +} diff --git a/apis/custom/v1alpha1/zz_generated.managed.go b/apis/custom/v1alpha1/zz_generated.managed.go new file mode 100644 index 0000000..b7b1920 --- /dev/null +++ b/apis/custom/v1alpha1/zz_generated.managed.go @@ -0,0 +1,68 @@ +/* +Copyright 2022 Upbound Inc. +*/ +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + +// GetCondition of this Image. +func (mg *Image) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this Image. +func (mg *Image) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this Image. +func (mg *Image) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this Image. +func (mg *Image) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +// GetPublishConnectionDetailsTo of this Image. +func (mg *Image) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this Image. +func (mg *Image) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this Image. +func (mg *Image) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this Image. +func (mg *Image) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this Image. +func (mg *Image) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this Image. +func (mg *Image) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +// SetPublishConnectionDetailsTo of this Image. +func (mg *Image) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this Image. +func (mg *Image) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} diff --git a/apis/custom/v1alpha1/zz_generated.managedlist.go b/apis/custom/v1alpha1/zz_generated.managedlist.go new file mode 100644 index 0000000..4810ff5 --- /dev/null +++ b/apis/custom/v1alpha1/zz_generated.managedlist.go @@ -0,0 +1,17 @@ +/* +Copyright 2022 Upbound Inc. +*/ +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import resource "github.com/crossplane/crossplane-runtime/pkg/resource" + +// GetItems of this ImageList. +func (l *ImageList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} diff --git a/apis/custom/v1alpha1/zz_generated_terraformed.go b/apis/custom/v1alpha1/zz_generated_terraformed.go new file mode 100755 index 0000000..0785528 --- /dev/null +++ b/apis/custom/v1alpha1/zz_generated_terraformed.go @@ -0,0 +1,102 @@ +// SPDX-FileCopyrightText: 2023 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +/* +Copyright 2022 Upbound Inc. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package v1alpha1 + +import ( + "github.com/pkg/errors" + + "github.com/crossplane/upjet/pkg/resource" + "github.com/crossplane/upjet/pkg/resource/json" +) + +// GetTerraformResourceType returns Terraform resource type for this Image +func (mg *Image) GetTerraformResourceType() string { + return "digitalocean_custom_image" +} + +// GetConnectionDetailsMapping for this Image +func (tr *Image) GetConnectionDetailsMapping() map[string]string { + return nil +} + +// GetObservation of this Image +func (tr *Image) GetObservation() (map[string]any, error) { + o, err := json.TFParser.Marshal(tr.Status.AtProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(o, &base) +} + +// SetObservation for this Image +func (tr *Image) SetObservation(obs map[string]any) error { + p, err := json.TFParser.Marshal(obs) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Status.AtProvider) +} + +// GetID returns ID of underlying Terraform resource of this Image +func (tr *Image) GetID() string { + if tr.Status.AtProvider.ID == nil { + return "" + } + return *tr.Status.AtProvider.ID +} + +// GetParameters of this Image +func (tr *Image) GetParameters() (map[string]any, error) { + p, err := json.TFParser.Marshal(tr.Spec.ForProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(p, &base) +} + +// SetParameters for this Image +func (tr *Image) SetParameters(params map[string]any) error { + p, err := json.TFParser.Marshal(params) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Spec.ForProvider) +} + +// GetInitParameters of this Image +func (tr *Image) GetInitParameters() (map[string]any, error) { + p, err := json.TFParser.Marshal(tr.Spec.InitProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(p, &base) +} + +// LateInitialize this Image using its observed tfState. +// returns True if there are any spec changes for the resource. +func (tr *Image) LateInitialize(attrs []byte) (bool, error) { + params := &ImageParameters{} + if err := json.TFParser.Unmarshal(attrs, params); err != nil { + return false, errors.Wrap(err, "failed to unmarshal Terraform state parameters for late-initialization") + } + opts := []resource.GenericLateInitializerOption{resource.WithZeroValueJSONOmitEmptyFilter(resource.CNameWildcard)} + + li := resource.NewGenericLateInitializer(opts...) + return li.LateInitialize(&tr.Spec.ForProvider, params) +} + +// GetTerraformSchemaVersion returns the associated Terraform schema version +func (tr *Image) GetTerraformSchemaVersion() int { + return 0 +} diff --git a/apis/custom/v1alpha1/zz_groupversion_info.go b/apis/custom/v1alpha1/zz_groupversion_info.go new file mode 100755 index 0000000..d67e732 --- /dev/null +++ b/apis/custom/v1alpha1/zz_groupversion_info.go @@ -0,0 +1,36 @@ +// SPDX-FileCopyrightText: 2023 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +/* +Copyright 2022 Upbound Inc. +*/ + +// Code generated by upjet. DO NOT EDIT. + +// +kubebuilder:object:generate=true +// +groupName=custom.digitalocean.crossplane.io +// +versionName=v1alpha1 +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +// Package type metadata. +const ( + CRDGroup = "custom.digitalocean.crossplane.io" + CRDVersion = "v1alpha1" +) + +var ( + // CRDGroupVersion is the API Group Version used to register the objects + CRDGroupVersion = schema.GroupVersion{Group: CRDGroup, Version: CRDVersion} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: CRDGroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/apis/custom/v1alpha1/zz_image_types.go b/apis/custom/v1alpha1/zz_image_types.go new file mode 100755 index 0000000..717315e --- /dev/null +++ b/apis/custom/v1alpha1/zz_image_types.go @@ -0,0 +1,176 @@ +// SPDX-FileCopyrightText: 2023 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +/* +Copyright 2022 Upbound Inc. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" +) + +type ImageInitParameters struct { + + // An optional description for the image. + Description *string `json:"description,omitempty" tf:"description,omitempty"` + + // An optional distribution name for the image. Valid values are documented here + Distribution *string `json:"distribution,omitempty" tf:"distribution,omitempty"` + + // A name for the Custom Image. + Name *string `json:"name,omitempty" tf:"name,omitempty"` + + // A list of regions. (Currently only one is supported). + Regions []*string `json:"regions,omitempty" tf:"regions,omitempty"` + + // A list of optional tags for the image. + Tags []*string `json:"tags,omitempty" tf:"tags,omitempty"` + + // A URL from which the custom Linux virtual machine image may be retrieved. + URL *string `json:"url,omitempty" tf:"url,omitempty"` +} + +type ImageObservation struct { + + // A time value given in ISO8601 combined date and time format that represents when the image was created. + CreatedAt *string `json:"createdAt,omitempty" tf:"created_at,omitempty"` + + // An optional description for the image. + Description *string `json:"description,omitempty" tf:"description,omitempty"` + + // An optional distribution name for the image. Valid values are documented here + Distribution *string `json:"distribution,omitempty" tf:"distribution,omitempty"` + + ID *string `json:"id,omitempty" tf:"id,omitempty"` + + // A unique number that can be used to identify and reference a specific image. + ImageID *float64 `json:"imageId,omitempty" tf:"image_id,omitempty"` + + // The minimum disk size in GB required for a Droplet to use this image. + MinDiskSize *float64 `json:"minDiskSize,omitempty" tf:"min_disk_size,omitempty"` + + // A name for the Custom Image. + Name *string `json:"name,omitempty" tf:"name,omitempty"` + + // Indicates whether the image in question is public or not. + Public *bool `json:"public,omitempty" tf:"public,omitempty"` + + // A list of regions. (Currently only one is supported). + Regions []*string `json:"regions,omitempty" tf:"regions,omitempty"` + + // The size of the image in gigabytes. + SizeGigabytes *float64 `json:"sizeGigabytes,omitempty" tf:"size_gigabytes,omitempty"` + + // A uniquely identifying string for each image. + Slug *string `json:"slug,omitempty" tf:"slug,omitempty"` + + // A status string indicating the state of a custom image. + Status *string `json:"status,omitempty" tf:"status,omitempty"` + + // A list of optional tags for the image. + Tags []*string `json:"tags,omitempty" tf:"tags,omitempty"` + + // Describes the kind of image. + Type *string `json:"type,omitempty" tf:"type,omitempty"` + + // A URL from which the custom Linux virtual machine image may be retrieved. + URL *string `json:"url,omitempty" tf:"url,omitempty"` +} + +type ImageParameters struct { + + // An optional description for the image. + // +kubebuilder:validation:Optional + Description *string `json:"description,omitempty" tf:"description,omitempty"` + + // An optional distribution name for the image. Valid values are documented here + // +kubebuilder:validation:Optional + Distribution *string `json:"distribution,omitempty" tf:"distribution,omitempty"` + + // A name for the Custom Image. + // +kubebuilder:validation:Optional + Name *string `json:"name,omitempty" tf:"name,omitempty"` + + // A list of regions. (Currently only one is supported). + // +kubebuilder:validation:Optional + Regions []*string `json:"regions,omitempty" tf:"regions,omitempty"` + + // A list of optional tags for the image. + // +kubebuilder:validation:Optional + Tags []*string `json:"tags,omitempty" tf:"tags,omitempty"` + + // A URL from which the custom Linux virtual machine image may be retrieved. + // +kubebuilder:validation:Optional + URL *string `json:"url,omitempty" tf:"url,omitempty"` +} + +// ImageSpec defines the desired state of Image +type ImageSpec struct { + v1.ResourceSpec `json:",inline"` + ForProvider ImageParameters `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 + // of Identifier and other resource reference fields. The fields that are + // in InitProvider are merged into ForProvider when the resource is created. + // The same fields are also added to the terraform ignore_changes hook, to + // avoid updating them after creation. This is useful for fields that are + // 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 ImageInitParameters `json:"initProvider,omitempty"` +} + +// ImageStatus defines the observed state of Image. +type ImageStatus struct { + v1.ResourceStatus `json:",inline"` + AtProvider ImageObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true + +// Image is the Schema for the Images API. +// +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,do} +type Image 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.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.regions) || (has(self.initProvider) && has(self.initProvider.regions))",message="spec.forProvider.regions is a required parameter" + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.url) || (has(self.initProvider) && has(self.initProvider.url))",message="spec.forProvider.url is a required parameter" + Spec ImageSpec `json:"spec"` + Status ImageStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// ImageList contains a list of Images +type ImageList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Image `json:"items"` +} + +// Repository type metadata. +var ( + Image_Kind = "Image" + Image_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: Image_Kind}.String() + Image_KindAPIVersion = Image_Kind + "." + CRDGroupVersion.String() + Image_GroupVersionKind = CRDGroupVersion.WithKind(Image_Kind) +) + +func init() { + SchemeBuilder.Register(&Image{}, &ImageList{}) +} diff --git a/apis/zz_register.go b/apis/zz_register.go index 741b04f..b5c874d 100755 --- a/apis/zz_register.go +++ b/apis/zz_register.go @@ -15,6 +15,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" v1alpha1 "github.com/straw-hat-team/provider-digitalocean/apis/compute/v1alpha1" + v1alpha1custom "github.com/straw-hat-team/provider-digitalocean/apis/custom/v1alpha1" v1alpha1database "github.com/straw-hat-team/provider-digitalocean/apis/database/v1alpha1" v1alpha1digitalocean "github.com/straw-hat-team/provider-digitalocean/apis/digitalocean/v1alpha1" v1alpha1droplet "github.com/straw-hat-team/provider-digitalocean/apis/droplet/v1alpha1" @@ -35,6 +36,7 @@ func init() { // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme, + v1alpha1custom.SchemeBuilder.AddToScheme, v1alpha1database.SchemeBuilder.AddToScheme, v1alpha1digitalocean.SchemeBuilder.AddToScheme, v1alpha1droplet.SchemeBuilder.AddToScheme, diff --git a/config/provider.go b/config/provider.go index f1c5301..1f28c94 100644 --- a/config/provider.go +++ b/config/provider.go @@ -54,6 +54,7 @@ var ExternalNameConfigs = map[string]ujconfig.ExternalName{ "digitalocean_spaces_bucket_cors_configuration": ujconfig.IdentifierFromProvider, "digitalocean_spaces_bucket_object": ujconfig.IdentifierFromProvider, "digitalocean_spaces_bucket_policy": ujconfig.IdentifierFromProvider, + "digitalocean_custom_image": ujconfig.IdentifierFromProvider, } const networkingGroup = "networking" @@ -216,6 +217,10 @@ func GetProvider() *ujconfig.Provider { Type: referenceType(pc, "ssh", "v1alpha1", "Key"), TerraformName: "digitalocean_ssh_key", } + r.References["image"] = ujconfig.Reference{ + Type: referenceType(pc, "custom", "v1alpha1", "Image"), + TerraformName: "digitalocean_custom_image", + } // r.References["vpc_uuid"] = ujconfig.Reference{ // Type: referenceType(pc, "networking", "v1alpha1", "VPC"), // TerraformName: "digitalocean_vpc", diff --git a/examples-generated/compute/droplet.yaml b/examples-generated/compute/droplet.yaml index d1badf1..6363b9b 100644 --- a/examples-generated/compute/droplet.yaml +++ b/examples-generated/compute/droplet.yaml @@ -8,7 +8,9 @@ metadata: name: web spec: forProvider: - image: ubuntu-20-04-x64 + imageSelector: + matchLabels: + testing.upbound.io/example-name: example name: web-1 region: nyc2 size: s-1vcpu-1gb diff --git a/examples-generated/custom/image.yaml b/examples-generated/custom/image.yaml new file mode 100644 index 0000000..3384cc6 --- /dev/null +++ b/examples-generated/custom/image.yaml @@ -0,0 +1,35 @@ +apiVersion: custom.digitalocean.crossplane.io/v1alpha1 +kind: Image +metadata: + annotations: + meta.upbound.io/example-id: custom/v1alpha1/image + labels: + testing.upbound.io/example-name: flatcar + name: flatcar +spec: + forProvider: + name: flatcar + regions: + - nyc3 + url: https://stable.release.flatcar-linux.net/amd64-usr/2605.7.0/flatcar_production_digitalocean_image.bin.bz2 + +--- + +apiVersion: compute.digitalocean.crossplane.io/v1alpha1 +kind: Droplet +metadata: + annotations: + meta.upbound.io/example-id: custom/v1alpha1/image + labels: + testing.upbound.io/example-name: example + name: example +spec: + forProvider: + imageSelector: + matchLabels: + testing.upbound.io/example-name: flatcar + name: example-01 + region: nyc3 + size: s-1vcpu-1gb + sshKeysRefs: + - name: example diff --git a/examples-generated/digitalocean/tag.yaml b/examples-generated/digitalocean/tag.yaml index 640dc22..1f712d8 100644 --- a/examples-generated/digitalocean/tag.yaml +++ b/examples-generated/digitalocean/tag.yaml @@ -22,7 +22,9 @@ metadata: name: web spec: forProvider: - image: ubuntu-18-04-x64 + imageSelector: + matchLabels: + testing.upbound.io/example-name: example name: web-1 region: nyc3 size: s-1vcpu-1gb diff --git a/examples-generated/droplet/snapshot.yaml b/examples-generated/droplet/snapshot.yaml index 18d0e62..00be8fc 100644 --- a/examples-generated/droplet/snapshot.yaml +++ b/examples-generated/droplet/snapshot.yaml @@ -25,7 +25,9 @@ metadata: name: from-snapshot spec: forProvider: - image: ${digitalocean_droplet_snapshot.web-snapshot.id} + imageSelector: + matchLabels: + testing.upbound.io/example-name: web-snapshot name: web-02 region: nyc3 size: s-2vcpu-4gb @@ -42,7 +44,9 @@ metadata: name: web spec: forProvider: - image: ubuntu-22-04-x64 + imageSelector: + matchLabels: + testing.upbound.io/example-name: example name: web-01 region: nyc3 size: s-1vcpu-1gb diff --git a/examples-generated/monitor/alert.yaml b/examples-generated/monitor/alert.yaml index a831e74..1aea660 100644 --- a/examples-generated/monitor/alert.yaml +++ b/examples-generated/monitor/alert.yaml @@ -35,7 +35,9 @@ metadata: name: web spec: forProvider: - image: ubuntu-20-04-x64 + imageSelector: + matchLabels: + testing.upbound.io/example-name: example name: web-1 region: nyc2 size: s-1vcpu-1gb diff --git a/examples-generated/networking/firewall.yaml b/examples-generated/networking/firewall.yaml index 0e8fdf7..7b78ecf 100644 --- a/examples-generated/networking/firewall.yaml +++ b/examples-generated/networking/firewall.yaml @@ -59,7 +59,9 @@ metadata: name: web spec: forProvider: - image: ubuntu-18-04-x64 + imageSelector: + matchLabels: + testing.upbound.io/example-name: example name: web-1 region: nyc3 size: s-1vcpu-1gb diff --git a/examples-generated/networking/ip.yaml b/examples-generated/networking/ip.yaml index d023573..7cf62df 100644 --- a/examples-generated/networking/ip.yaml +++ b/examples-generated/networking/ip.yaml @@ -25,7 +25,9 @@ metadata: name: example spec: forProvider: - image: ubuntu-22-04-x64 + imageSelector: + matchLabels: + testing.upbound.io/example-name: example ipv6: true name: example privateNetworking: true diff --git a/examples-generated/networking/ipassignment.yaml b/examples-generated/networking/ipassignment.yaml index 294857d..5f3b85b 100644 --- a/examples-generated/networking/ipassignment.yaml +++ b/examples-generated/networking/ipassignment.yaml @@ -27,7 +27,9 @@ metadata: name: example spec: forProvider: - image: ubuntu-22-04-x64 + imageSelector: + matchLabels: + testing.upbound.io/example-name: example ipv6: true name: baz privateNetworking: true diff --git a/examples-generated/networking/loadbalancer.yaml b/examples-generated/networking/loadbalancer.yaml index cb7a117..fce776b 100644 --- a/examples-generated/networking/loadbalancer.yaml +++ b/examples-generated/networking/loadbalancer.yaml @@ -33,7 +33,9 @@ metadata: name: web spec: forProvider: - image: ubuntu-18-04-x64 + imageSelector: + matchLabels: + testing.upbound.io/example-name: example name: web-1 region: nyc3 size: s-1vcpu-1gb diff --git a/examples-generated/ssh/key.yaml b/examples-generated/ssh/key.yaml index fecf209..fc77070 100644 --- a/examples-generated/ssh/key.yaml +++ b/examples-generated/ssh/key.yaml @@ -23,7 +23,9 @@ metadata: name: web spec: forProvider: - image: ubuntu-18-04-x64 + imageSelector: + matchLabels: + testing.upbound.io/example-name: example name: web-1 region: nyc3 size: s-1vcpu-1gb diff --git a/examples-generated/volume/attachment.yaml b/examples-generated/volume/attachment.yaml index b2f2550..5390e3d 100644 --- a/examples-generated/volume/attachment.yaml +++ b/examples-generated/volume/attachment.yaml @@ -27,7 +27,9 @@ metadata: name: foobar spec: forProvider: - image: ubuntu-18-04-x64 + imageSelector: + matchLabels: + testing.upbound.io/example-name: example name: baz region: nyc1 size: s-1vcpu-1gb diff --git a/examples-generated/volume/volume.yaml b/examples-generated/volume/volume.yaml index 2780270..f8742b1 100644 --- a/examples-generated/volume/volume.yaml +++ b/examples-generated/volume/volume.yaml @@ -26,7 +26,9 @@ metadata: name: foobar spec: forProvider: - image: ubuntu-18-04-x64 + imageSelector: + matchLabels: + testing.upbound.io/example-name: example name: baz region: nyc1 size: s-1vcpu-1gb diff --git a/internal/controller/custom/image/zz_controller.go b/internal/controller/custom/image/zz_controller.go new file mode 100755 index 0000000..4830e29 --- /dev/null +++ b/internal/controller/custom/image/zz_controller.go @@ -0,0 +1,66 @@ +// SPDX-FileCopyrightText: 2023 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +/* +Copyright 2022 Upbound Inc. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package image + +import ( + "time" + + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + tjcontroller "github.com/crossplane/upjet/pkg/controller" + "github.com/crossplane/upjet/pkg/controller/handler" + "github.com/crossplane/upjet/pkg/terraform" + ctrl "sigs.k8s.io/controller-runtime" + + v1alpha1 "github.com/straw-hat-team/provider-digitalocean/apis/custom/v1alpha1" + features "github.com/straw-hat-team/provider-digitalocean/internal/features" +) + +// Setup adds a controller that reconciles Image managed resources. +func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { + name := managed.ControllerName(v1alpha1.Image_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.Image_GroupVersionKind))) + ac := tjcontroller.NewAPICallbacks(mgr, xpresource.ManagedKind(v1alpha1.Image_GroupVersionKind), tjcontroller.WithEventHandler(eventHandler)) + opts := []managed.ReconcilerOption{ + managed.WithExternalConnecter(tjcontroller.NewConnector(mgr.GetClient(), o.WorkspaceStore, o.SetupFn, o.Provider.Resources["digitalocean_custom_image"], tjcontroller.WithLogger(o.Logger), tjcontroller.WithConnectorEventHandler(eventHandler), + tjcontroller.WithCallbackProvider(ac), + )), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithFinalizer(terraform.NewWorkspaceFinalizer(o.WorkspaceStore, xpresource.NewAPIFinalizer(mgr.GetClient(), managed.FinalizerName))), + managed.WithTimeout(3 * time.Minute), + managed.WithInitializers(initializers), + managed.WithConnectionPublishers(cps...), + managed.WithPollInterval(o.PollInterval), + } + if o.PollJitter != 0 { + opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) + } + if o.Features.Enabled(features.EnableBetaManagementPolicies) { + opts = append(opts, managed.WithManagementPolicies()) + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1alpha1.Image_GroupVersionKind), opts...) + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(xpresource.DesiredStateChanged()). + Watches(&v1alpha1.Image{}, eventHandler). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} diff --git a/internal/controller/zz_setup.go b/internal/controller/zz_setup.go index 9c1b688..13f4b70 100755 --- a/internal/controller/zz_setup.go +++ b/internal/controller/zz_setup.go @@ -10,6 +10,7 @@ import ( "github.com/crossplane/upjet/pkg/controller" droplet "github.com/straw-hat-team/provider-digitalocean/internal/controller/compute/droplet" + image "github.com/straw-hat-team/provider-digitalocean/internal/controller/custom/image" cluster "github.com/straw-hat-team/provider-digitalocean/internal/controller/database/cluster" replica "github.com/straw-hat-team/provider-digitalocean/internal/controller/database/replica" user "github.com/straw-hat-team/provider-digitalocean/internal/controller/database/user" @@ -45,6 +46,7 @@ import ( func Setup(mgr ctrl.Manager, o controller.Options) error { for _, setup := range []func(ctrl.Manager, controller.Options) error{ droplet.Setup, + image.Setup, cluster.Setup, replica.Setup, user.Setup, diff --git a/package/crds/compute.digitalocean.crossplane.io_droplets.yaml b/package/crds/compute.digitalocean.crossplane.io_droplets.yaml index 3e407c6..cfcd165 100644 --- a/package/crds/compute.digitalocean.crossplane.io_droplets.yaml +++ b/package/crds/compute.digitalocean.crossplane.io_droplets.yaml @@ -86,6 +86,79 @@ spec: description: The Droplet image ID or slug. This could be either image ID or droplet snapshot ID. type: string + imageRef: + description: Reference to a Image in custom to populate image. + 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 + imageSelector: + description: Selector for a Image in custom to populate image. + 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 ipv6: description: Boolean controlling if IPv6 is enabled. Defaults to false. Once enabled for a Droplet, IPv6 can not be disabled. @@ -332,10 +405,6 @@ spec: description: A boolean indicating whether the droplet should be gracefully shut down before it is deleted. type: boolean - image: - description: The Droplet image ID or slug. This could be either - image ID or droplet snapshot ID. - type: string ipv6: description: Boolean controlling if IPv6 is enabled. Defaults to false. Once enabled for a Droplet, IPv6 can not be disabled. @@ -548,10 +617,6 @@ spec: - forProvider type: object x-kubernetes-validations: - - message: spec.forProvider.image is a required parameter - rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies - || ''Update'' in self.managementPolicies) || has(self.forProvider.image) - || (has(self.initProvider) && has(self.initProvider.image))' - message: spec.forProvider.name is a required parameter rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies || ''Update'' in self.managementPolicies) || has(self.forProvider.name) diff --git a/package/crds/custom.digitalocean.crossplane.io_images.yaml b/package/crds/custom.digitalocean.crossplane.io_images.yaml new file mode 100644 index 0000000..8332e05 --- /dev/null +++ b/package/crds/custom.digitalocean.crossplane.io_images.yaml @@ -0,0 +1,408 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.13.0 + name: images.custom.digitalocean.crossplane.io +spec: + group: custom.digitalocean.crossplane.io + names: + categories: + - crossplane + - managed + - do + kind: Image + listKind: ImageList + plural: images + singular: image + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: Image is the Schema for the Images API. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ImageSpec defines the desired state of Image + properties: + deletionPolicy: + default: Delete + description: 'DeletionPolicy specifies what will happen to the underlying + external when this managed resource is deleted - either "Delete" + or "Orphan" the external resource. This field is planned to be deprecated + in favor of the ManagementPolicies field in a future release. Currently, + both could be set independently and non-default values would be + honored if the feature flag is enabled. See the design doc for more + information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223' + enum: + - Orphan + - Delete + type: string + forProvider: + properties: + description: + description: An optional description for the image. + type: string + distribution: + description: An optional distribution name for the image. Valid + values are documented here + type: string + name: + description: A name for the Custom Image. + type: string + regions: + description: A list of regions. (Currently only one is supported). + items: + type: string + type: array + tags: + description: A list of optional tags for the image. + items: + type: string + type: array + url: + description: A URL from which the custom Linux virtual machine + image may be retrieved. + type: string + type: object + initProvider: + description: 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 of Identifier and other resource + reference fields. The fields that are in InitProvider are merged + into ForProvider when the resource is created. The same fields are + also added to the terraform ignore_changes hook, to avoid updating + them after creation. This is useful for fields that are 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. + properties: + description: + description: An optional description for the image. + type: string + distribution: + description: An optional distribution name for the image. Valid + values are documented here + type: string + name: + description: A name for the Custom Image. + type: string + regions: + description: A list of regions. (Currently only one is supported). + items: + type: string + type: array + tags: + description: A list of optional tags for the image. + items: + type: string + type: array + url: + description: A URL from which the custom Linux virtual machine + image may be retrieved. + type: string + type: object + managementPolicies: + default: + - '*' + description: 'THIS IS A BETA FIELD. It is on by default but can be + opted out through a Crossplane feature flag. ManagementPolicies + specify the array of actions Crossplane is allowed to take on the + managed and external resources. This field is planned to replace + the DeletionPolicy field in a future release. Currently, both could + be set independently and non-default values would be honored if + the feature flag is enabled. If both are custom, the DeletionPolicy + field will be ignored. See the design doc for more information: + https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md' + items: + description: A ManagementAction represents an action that the Crossplane + controllers can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + providerConfigRef: + default: + name: default + description: ProviderConfigReference specifies how the provider that + will be used to create, observe, update, and delete this managed + resource should be configured. + 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 + publishConnectionDetailsTo: + description: PublishConnectionDetailsTo specifies the connection secret + config which contains a name, metadata and a reference to secret + store config to which any connection details for this managed resource + should be written. Connection details frequently include the endpoint, + username, and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: SecretStoreConfigRef specifies which secret store + config should be used for this ConnectionSecret. + 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 + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the annotations to be added to + connection secret. - For Kubernetes secrets, this will be + used as "metadata.annotations". - It is up to Secret Store + implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: Labels are the labels/tags to be added to connection + secret. - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store + types. + type: object + type: + description: Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: WriteConnectionSecretToReference specifies the namespace + and name of a Secret to which any connection details for this managed + resource should be written. Connection details frequently include + the endpoint, username, and password required to connect to the + managed resource. This field is planned to be replaced in a future + release in favor of PublishConnectionDetailsTo. Currently, both + could be set independently and connection details would be published + to both without affecting each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + x-kubernetes-validations: + - message: spec.forProvider.name is a required parameter + 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.regions is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.regions) + || (has(self.initProvider) && has(self.initProvider.regions))' + - message: spec.forProvider.url is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.url) + || (has(self.initProvider) && has(self.initProvider.url))' + status: + description: ImageStatus defines the observed state of Image. + properties: + atProvider: + properties: + createdAt: + description: A time value given in ISO8601 combined date and time + format that represents when the image was created. + type: string + description: + description: An optional description for the image. + type: string + distribution: + description: An optional distribution name for the image. Valid + values are documented here + type: string + id: + type: string + imageId: + description: A unique number that can be used to identify and + reference a specific image. + type: number + minDiskSize: + description: The minimum disk size in GB required for a Droplet + to use this image. + type: number + name: + description: A name for the Custom Image. + type: string + public: + description: Indicates whether the image in question is public + or not. + type: boolean + regions: + description: A list of regions. (Currently only one is supported). + items: + type: string + type: array + sizeGigabytes: + description: The size of the image in gigabytes. + type: number + slug: + description: A uniquely identifying string for each image. + type: string + status: + description: A status string indicating the state of a custom + image. + type: string + tags: + description: A list of optional tags for the image. + items: + type: string + type: array + type: + description: Describes the kind of image. + type: string + url: + description: A URL from which the custom Linux virtual machine + image may be retrieved. + type: string + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time this condition + transitioned from one status to another. + format: date-time + type: string + message: + description: A Message containing details about this condition's + last transition from one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: Type of this condition. At most one of each condition + type may apply to a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {}