diff --git a/PROJECT b/PROJECT index 54fc55950..547d6dec1 100644 --- a/PROJECT +++ b/PROJECT @@ -144,6 +144,14 @@ resources: kind: Service path: github.com/k-orc/openstack-resource-controller/api/v1alpha1 version: v1alpha1 +- api: + crdVersion: v1 + namespaced: true + domain: k-orc.cloud + group: openstack + kind: Share + path: github.com/k-orc/openstack-resource-controller/api/v1alpha1 + version: v1alpha1 - api: crdVersion: v1 namespaced: true diff --git a/README.md b/README.md index c05143838..23fd1ff2d 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ kubectl delete -f $ORC_RELEASE | server | | ◐ | ◐ | | server group | | ✔ | ✔ | | service | | ✔ | ✔ | +| share | | ◐ | ◐ | | subnet | | ◐ | ◐ | | trunk | | ✔ | ✔ | | volume | | ◐ | ◐ | diff --git a/api/v1alpha1/share_types.go b/api/v1alpha1/share_types.go new file mode 100644 index 000000000..6dc91b73e --- /dev/null +++ b/api/v1alpha1/share_types.go @@ -0,0 +1,182 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// ShareResourceSpec contains the desired state of the resource. +type ShareResourceSpec struct { + // name will be the name of the created resource. If not specified, the + // name of the ORC object will be used. + // +optional + Name *OpenStackName `json:"name,omitempty"` + + // description is a human-readable description for the resource. + // +kubebuilder:validation:MinLength:=1 + // +kubebuilder:validation:MaxLength:=255 + // +optional + Description *string `json:"description,omitempty"` + + // size is the size of the share, in gibibytes (GiB). + // +kubebuilder:validation:Minimum=1 + // +required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="size is immutable" + Size int32 `json:"size,omitempty"` + + // shareProto is the file system protocol for the share. + // Valid values are NFS, CIFS, GlusterFS, HDFS, CephFS, or MAPRFS. + // +kubebuilder:validation:Enum=NFS;CIFS;GlusterFS;HDFS;CephFS;MAPRFS + // +required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="shareProto is immutable" + ShareProto string `json:"shareProto,omitempty"` + + // availabilityZone is the availability zone in which to create the share. + // +kubebuilder:validation:MaxLength:=255 + // +optional + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="availabilityZone is immutable" + AvailabilityZone string `json:"availabilityZone,omitempty"` + + // metadata key and value pairs to be associated with the share. + // +kubebuilder:validation:MaxItems:=64 + // +listType=atomic + // +optional + Metadata []ShareMetadata `json:"metadata,omitempty"` + + // isPublic defines whether the share is publicly visible. + // +optional + IsPublic *bool `json:"isPublic,omitempty"` +} + +// ShareFilter defines an existing resource by its properties +// +kubebuilder:validation:MinProperties:=1 +type ShareFilter struct { + // name of the existing resource + // +optional + Name *OpenStackName `json:"name,omitempty"` + + // description of the existing resource + // +kubebuilder:validation:MinLength:=1 + // +kubebuilder:validation:MaxLength:=255 + // +optional + Description *string `json:"description,omitempty"` + + // shareProto is the file system protocol to filter by + // +kubebuilder:validation:Enum=NFS;CIFS;GlusterFS;HDFS;CephFS;MAPRFS + // +optional + ShareProto *string `json:"shareProto,omitempty"` + + // status is the share status to filter by + // +kubebuilder:validation:Enum=creating;available;deleting;error;error_deleting;manage_starting;manage_error;unmanage_starting;unmanage_error;extending;extending_error;shrinking;shrinking_error + // +optional + Status *string `json:"status,omitempty"` + + // isPublic filters by public visibility + // +optional + IsPublic *bool `json:"isPublic,omitempty"` +} + +// ShareResourceStatus represents the observed state of the resource. +type ShareResourceStatus struct { + // name is a Human-readable name for the resource. Might not be unique. + // +kubebuilder:validation:MaxLength=1024 + // +optional + Name string `json:"name,omitempty"` + + // description is a human-readable description for the resource. + // +kubebuilder:validation:MaxLength=1024 + // +optional + Description string `json:"description,omitempty"` + + // size is the size of the share in GiB. + // +optional + Size *int32 `json:"size,omitempty"` + + // shareProto is the file system protocol. + // +kubebuilder:validation:MaxLength=1024 + // +optional + ShareProto string `json:"shareProto,omitempty"` + + // status represents the current status of the share. + // +kubebuilder:validation:MaxLength=1024 + // +optional + Status string `json:"status,omitempty"` + + // availabilityZone is which availability zone the share is in. + // +kubebuilder:validation:MaxLength=1024 + // +optional + AvailabilityZone string `json:"availabilityZone,omitempty"` + + // exportLocations contains paths for accessing the share. + // +kubebuilder:validation:MaxItems:=32 + // +listType=atomic + // +optional + ExportLocations []ShareExportLocation `json:"exportLocations,omitempty"` + + // metadata key and value pairs associated with the share. + // +kubebuilder:validation:MaxItems:=64 + // +listType=atomic + // +optional + Metadata []ShareMetadataStatus `json:"metadata,omitempty"` + + // isPublic indicates whether the share is publicly visible. + // +optional + IsPublic *bool `json:"isPublic,omitempty"` + + // createdAt shows the date and time when the resource was created. The date and time stamp format is ISO 8601. + // +optional + CreatedAt *metav1.Time `json:"createdAt,omitempty"` + + // projectID is the ID of the project that owns the share. + // +kubebuilder:validation:MaxLength=1024 + // +optional + ProjectID string `json:"projectID,omitempty"` +} + +type ShareMetadata struct { + // name is the name of the metadata + // +kubebuilder:validation:MaxLength:=255 + // +required + Name string `json:"name"` + + // value is the value of the metadata + // +kubebuilder:validation:MaxLength:=255 + // +required + Value string `json:"value"` +} + +type ShareMetadataStatus struct { + // name is the name of the metadata + // +kubebuilder:validation:MaxLength:=255 + // +optional + Name string `json:"name,omitempty"` + + // value is the value of the metadata + // +kubebuilder:validation:MaxLength:=255 + // +optional + Value string `json:"value,omitempty"` +} + +type ShareExportLocation struct { + // path is the export path for accessing the share + // +kubebuilder:validation:MaxLength:=1024 + // +optional + Path string `json:"path,omitempty"` + + // preferred indicates if this is the preferred export location + // +optional + Preferred *bool `json:"preferred,omitempty"` +} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 3f9a9f21f..e3233adaf 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -4902,6 +4902,319 @@ func (in *ServiceStatus) DeepCopy() *ServiceStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Share) DeepCopyInto(out *Share) { + *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 Share. +func (in *Share) DeepCopy() *Share { + if in == nil { + return nil + } + out := new(Share) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Share) 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 *ShareExportLocation) DeepCopyInto(out *ShareExportLocation) { + *out = *in + if in.Preferred != nil { + in, out := &in.Preferred, &out.Preferred + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShareExportLocation. +func (in *ShareExportLocation) DeepCopy() *ShareExportLocation { + if in == nil { + return nil + } + out := new(ShareExportLocation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ShareFilter) DeepCopyInto(out *ShareFilter) { + *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(OpenStackName) + **out = **in + } + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.ShareProto != nil { + in, out := &in.ShareProto, &out.ShareProto + *out = new(string) + **out = **in + } + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(string) + **out = **in + } + if in.IsPublic != nil { + in, out := &in.IsPublic, &out.IsPublic + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShareFilter. +func (in *ShareFilter) DeepCopy() *ShareFilter { + if in == nil { + return nil + } + out := new(ShareFilter) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ShareImport) DeepCopyInto(out *ShareImport) { + *out = *in + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.Filter != nil { + in, out := &in.Filter, &out.Filter + *out = new(ShareFilter) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShareImport. +func (in *ShareImport) DeepCopy() *ShareImport { + if in == nil { + return nil + } + out := new(ShareImport) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ShareList) DeepCopyInto(out *ShareList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Share, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShareList. +func (in *ShareList) DeepCopy() *ShareList { + if in == nil { + return nil + } + out := new(ShareList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ShareList) 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 *ShareMetadata) DeepCopyInto(out *ShareMetadata) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShareMetadata. +func (in *ShareMetadata) DeepCopy() *ShareMetadata { + if in == nil { + return nil + } + out := new(ShareMetadata) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ShareMetadataStatus) DeepCopyInto(out *ShareMetadataStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShareMetadataStatus. +func (in *ShareMetadataStatus) DeepCopy() *ShareMetadataStatus { + if in == nil { + return nil + } + out := new(ShareMetadataStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ShareResourceSpec) DeepCopyInto(out *ShareResourceSpec) { + *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(OpenStackName) + **out = **in + } + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.Metadata != nil { + in, out := &in.Metadata, &out.Metadata + *out = make([]ShareMetadata, len(*in)) + copy(*out, *in) + } + if in.IsPublic != nil { + in, out := &in.IsPublic, &out.IsPublic + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShareResourceSpec. +func (in *ShareResourceSpec) DeepCopy() *ShareResourceSpec { + if in == nil { + return nil + } + out := new(ShareResourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ShareResourceStatus) DeepCopyInto(out *ShareResourceStatus) { + *out = *in + if in.Size != nil { + in, out := &in.Size, &out.Size + *out = new(int32) + **out = **in + } + if in.ExportLocations != nil { + in, out := &in.ExportLocations, &out.ExportLocations + *out = make([]ShareExportLocation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Metadata != nil { + in, out := &in.Metadata, &out.Metadata + *out = make([]ShareMetadataStatus, len(*in)) + copy(*out, *in) + } + if in.IsPublic != nil { + in, out := &in.IsPublic, &out.IsPublic + *out = new(bool) + **out = **in + } + if in.CreatedAt != nil { + in, out := &in.CreatedAt, &out.CreatedAt + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShareResourceStatus. +func (in *ShareResourceStatus) DeepCopy() *ShareResourceStatus { + if in == nil { + return nil + } + out := new(ShareResourceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ShareSpec) DeepCopyInto(out *ShareSpec) { + *out = *in + if in.Import != nil { + in, out := &in.Import, &out.Import + *out = new(ShareImport) + (*in).DeepCopyInto(*out) + } + if in.Resource != nil { + in, out := &in.Resource, &out.Resource + *out = new(ShareResourceSpec) + (*in).DeepCopyInto(*out) + } + if in.ManagedOptions != nil { + in, out := &in.ManagedOptions, &out.ManagedOptions + *out = new(ManagedOptions) + **out = **in + } + out.CloudCredentialsRef = in.CloudCredentialsRef +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShareSpec. +func (in *ShareSpec) DeepCopy() *ShareSpec { + if in == nil { + return nil + } + out := new(ShareSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ShareStatus) DeepCopyInto(out *ShareStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.Resource != nil { + in, out := &in.Resource, &out.Resource + *out = new(ShareResourceStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShareStatus. +func (in *ShareStatus) DeepCopy() *ShareStatus { + if in == nil { + return nil + } + out := new(ShareStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Subnet) DeepCopyInto(out *Subnet) { *out = *in diff --git a/api/v1alpha1/zz_generated.share-resource.go b/api/v1alpha1/zz_generated.share-resource.go new file mode 100644 index 000000000..b7d508472 --- /dev/null +++ b/api/v1alpha1/zz_generated.share-resource.go @@ -0,0 +1,179 @@ +// Code generated by resource-generator. DO NOT EDIT. +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ShareImport specifies an existing resource which will be imported instead of +// creating a new one +// +kubebuilder:validation:MinProperties:=1 +// +kubebuilder:validation:MaxProperties:=1 +type ShareImport struct { + // id contains the unique identifier of an existing OpenStack resource. Note + // that when specifying an import by ID, the resource MUST already exist. + // The ORC object will enter an error state if the resource does not exist. + // +kubebuilder:validation:Format:=uuid + // +kubebuilder:validation:MaxLength:=36 + // +optional + ID *string `json:"id,omitempty"` //nolint:kubeapilinter + + // filter contains a resource query which is expected to return a single + // result. The controller will continue to retry if filter returns no + // results. If filter returns multiple results the controller will set an + // error state and will not continue to retry. + // +optional + Filter *ShareFilter `json:"filter,omitempty"` +} + +// ShareSpec defines the desired state of an ORC object. +// +kubebuilder:validation:XValidation:rule="self.managementPolicy == 'managed' ? has(self.resource) : true",message="resource must be specified when policy is managed" +// +kubebuilder:validation:XValidation:rule="self.managementPolicy == 'managed' ? !has(self.__import__) : true",message="import may not be specified when policy is managed" +// +kubebuilder:validation:XValidation:rule="self.managementPolicy == 'unmanaged' ? !has(self.resource) : true",message="resource may not be specified when policy is unmanaged" +// +kubebuilder:validation:XValidation:rule="self.managementPolicy == 'unmanaged' ? has(self.__import__) : true",message="import must be specified when policy is unmanaged" +// +kubebuilder:validation:XValidation:rule="has(self.managedOptions) ? self.managementPolicy == 'managed' : true",message="managedOptions may only be provided when policy is managed" +type ShareSpec struct { + // import refers to an existing OpenStack resource which will be imported instead of + // creating a new one. + // +optional + Import *ShareImport `json:"import,omitempty"` + + // resource specifies the desired state of the resource. + // + // resource may not be specified if the management policy is `unmanaged`. + // + // resource must be specified if the management policy is `managed`. + // +optional + Resource *ShareResourceSpec `json:"resource,omitempty"` + + // managementPolicy defines how ORC will treat the object. Valid values are + // `managed`: ORC will create, update, and delete the resource; `unmanaged`: + // ORC will import an existing resource, and will not apply updates to it or + // delete it. + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="managementPolicy is immutable" + // +kubebuilder:default:=managed + // +optional + ManagementPolicy ManagementPolicy `json:"managementPolicy,omitempty"` + + // managedOptions specifies options which may be applied to managed objects. + // +optional + ManagedOptions *ManagedOptions `json:"managedOptions,omitempty"` + + // cloudCredentialsRef points to a secret containing OpenStack credentials + // +required + CloudCredentialsRef CloudCredentialsReference `json:"cloudCredentialsRef,omitzero"` +} + +// ShareStatus defines the observed state of an ORC resource. +type ShareStatus struct { + // conditions represents the observed status of the object. + // Known .status.conditions.type are: "Available", "Progressing" + // + // Available represents the availability of the OpenStack resource. If it is + // true then the resource is ready for use. + // + // Progressing indicates whether the controller is still attempting to + // reconcile the current state of the OpenStack resource to the desired + // state. Progressing will be False either because the desired state has + // been achieved, or because some terminal error prevents it from ever being + // achieved and the controller is no longer attempting to reconcile. If + // Progressing is True, an observer waiting on the resource should continue + // to wait. + // + // +kubebuilder:validation:MaxItems:=32 + // +patchMergeKey=type + // +patchStrategy=merge + // +listType=map + // +listMapKey=type + // +optional + Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` + + // id is the unique identifier of the OpenStack resource. + // +kubebuilder:validation:MaxLength:=1024 + // +optional + ID *string `json:"id,omitempty"` + + // resource contains the observed state of the OpenStack resource. + // +optional + Resource *ShareResourceStatus `json:"resource,omitempty"` +} + +var _ ObjectWithConditions = &Share{} + +func (i *Share) GetConditions() []metav1.Condition { + return i.Status.Conditions +} + +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:resource:categories=openstack +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="ID",type="string",JSONPath=".status.id",description="Resource ID" +// +kubebuilder:printcolumn:name="Available",type="string",JSONPath=".status.conditions[?(@.type=='Available')].status",description="Availability status of resource" +// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Progressing')].message",description="Message describing current progress status" + +// Share is the Schema for an ORC resource. +type Share struct { + metav1.TypeMeta `json:",inline"` + + // metadata contains the object metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // spec specifies the desired state of the resource. + // +required + Spec ShareSpec `json:"spec,omitzero"` + + // status defines the observed state of the resource. + // +optional + Status ShareStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// ShareList contains a list of Share. +type ShareList struct { + metav1.TypeMeta `json:",inline"` + + // metadata contains the list metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // items contains a list of Share. + // +required + Items []Share `json:"items"` +} + +func (l *ShareList) GetItems() []Share { + return l.Items +} + +func init() { + SchemeBuilder.Register(&Share{}, &ShareList{}) +} + +func (i *Share) GetCloudCredentialsRef() (*string, *CloudCredentialsReference) { + if i == nil { + return nil, nil + } + + return &i.Namespace, &i.Spec.CloudCredentialsRef +} + +var _ CloudCredentialsRefProvider = &Share{} diff --git a/cmd/manager/main.go b/cmd/manager/main.go index bb5b27c69..a7b3350a0 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -45,6 +45,7 @@ import ( "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/server" "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/servergroup" "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/service" + "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/share" "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/subnet" "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/trunk" "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/volume" @@ -122,6 +123,7 @@ func main() { securitygroup.New(scopeFactory), server.New(scopeFactory), servergroup.New(scopeFactory), + share.New(scopeFactory), project.New(scopeFactory), volume.New(scopeFactory), volumetype.New(scopeFactory), diff --git a/cmd/models-schema/zz_generated.openapi.go b/cmd/models-schema/zz_generated.openapi.go index d00ee16e4..9547bdab2 100644 --- a/cmd/models-schema/zz_generated.openapi.go +++ b/cmd/models-schema/zz_generated.openapi.go @@ -201,6 +201,17 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ServiceResourceStatus": schema_openstack_resource_controller_v2_api_v1alpha1_ServiceResourceStatus(ref), "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ServiceSpec": schema_openstack_resource_controller_v2_api_v1alpha1_ServiceSpec(ref), "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ServiceStatus": schema_openstack_resource_controller_v2_api_v1alpha1_ServiceStatus(ref), + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.Share": schema_openstack_resource_controller_v2_api_v1alpha1_Share(ref), + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareExportLocation": schema_openstack_resource_controller_v2_api_v1alpha1_ShareExportLocation(ref), + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareFilter": schema_openstack_resource_controller_v2_api_v1alpha1_ShareFilter(ref), + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareImport": schema_openstack_resource_controller_v2_api_v1alpha1_ShareImport(ref), + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareList": schema_openstack_resource_controller_v2_api_v1alpha1_ShareList(ref), + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareMetadata": schema_openstack_resource_controller_v2_api_v1alpha1_ShareMetadata(ref), + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareMetadataStatus": schema_openstack_resource_controller_v2_api_v1alpha1_ShareMetadataStatus(ref), + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareResourceSpec": schema_openstack_resource_controller_v2_api_v1alpha1_ShareResourceSpec(ref), + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareResourceStatus": schema_openstack_resource_controller_v2_api_v1alpha1_ShareResourceStatus(ref), + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareSpec": schema_openstack_resource_controller_v2_api_v1alpha1_ShareSpec(ref), + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareStatus": schema_openstack_resource_controller_v2_api_v1alpha1_ShareStatus(ref), "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.Subnet": schema_openstack_resource_controller_v2_api_v1alpha1_Subnet(ref), "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.SubnetFilter": schema_openstack_resource_controller_v2_api_v1alpha1_SubnetFilter(ref), "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.SubnetGateway": schema_openstack_resource_controller_v2_api_v1alpha1_SubnetGateway(ref), @@ -9393,6 +9404,557 @@ func schema_openstack_resource_controller_v2_api_v1alpha1_ServiceStatus(ref comm } } +func schema_openstack_resource_controller_v2_api_v1alpha1_Share(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Share is the Schema for an ORC resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + 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{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + 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{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "metadata contains the object metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "spec specifies the desired state of the resource.", + Default: map[string]interface{}{}, + Ref: ref("github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "status defines the observed state of the resource.", + Default: map[string]interface{}{}, + Ref: ref("github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareStatus"), + }, + }, + }, + Required: []string{"spec"}, + }, + }, + Dependencies: []string{ + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareSpec", "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_openstack_resource_controller_v2_api_v1alpha1_ShareExportLocation(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "path": { + SchemaProps: spec.SchemaProps{ + Description: "path is the export path for accessing the share", + Type: []string{"string"}, + Format: "", + }, + }, + "preferred": { + SchemaProps: spec.SchemaProps{ + Description: "preferred indicates if this is the preferred export location", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_openstack_resource_controller_v2_api_v1alpha1_ShareFilter(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ShareFilter defines an existing resource by its properties", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name of the existing resource", + Type: []string{"string"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Description: "description of the existing resource", + Type: []string{"string"}, + Format: "", + }, + }, + "shareProto": { + SchemaProps: spec.SchemaProps{ + Description: "shareProto is the file system protocol to filter by", + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "status is the share status to filter by", + Type: []string{"string"}, + Format: "", + }, + }, + "isPublic": { + SchemaProps: spec.SchemaProps{ + Description: "isPublic filters by public visibility", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_openstack_resource_controller_v2_api_v1alpha1_ShareImport(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ShareImport specifies an existing resource which will be imported instead of creating a new one", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "id": { + SchemaProps: spec.SchemaProps{ + Description: "id contains the unique identifier of an existing OpenStack resource. Note that when specifying an import by ID, the resource MUST already exist. The ORC object will enter an error state if the resource does not exist.", + Type: []string{"string"}, + Format: "", + }, + }, + "filter": { + SchemaProps: spec.SchemaProps{ + Description: "filter contains a resource query which is expected to return a single result. The controller will continue to retry if filter returns no results. If filter returns multiple results the controller will set an error state and will not continue to retry.", + Ref: ref("github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareFilter"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareFilter"}, + } +} + +func schema_openstack_resource_controller_v2_api_v1alpha1_ShareList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ShareList contains a list of Share.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + 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{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + 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{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "metadata contains the list metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "items contains a list of Share.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.Share"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.Share", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_openstack_resource_controller_v2_api_v1alpha1_ShareMetadata(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name is the name of the metadata", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Description: "value is the value of the metadata", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "value"}, + }, + }, + } +} + +func schema_openstack_resource_controller_v2_api_v1alpha1_ShareMetadataStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name is the name of the metadata", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Description: "value is the value of the metadata", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_openstack_resource_controller_v2_api_v1alpha1_ShareResourceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ShareResourceSpec contains the desired state of the resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name will be the name of the created resource. If not specified, the name of the ORC object will be used.", + Type: []string{"string"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Description: "description is a human-readable description for the resource.", + Type: []string{"string"}, + Format: "", + }, + }, + "size": { + SchemaProps: spec.SchemaProps{ + Description: "size is the size of the share, in gibibytes (GiB).", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "shareProto": { + SchemaProps: spec.SchemaProps{ + Description: "shareProto is the file system protocol for the share. Valid values are NFS, CIFS, GlusterFS, HDFS, CephFS, or MAPRFS.", + Type: []string{"string"}, + Format: "", + }, + }, + "availabilityZone": { + SchemaProps: spec.SchemaProps{ + Description: "availabilityZone is the availability zone in which to create the share.", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "metadata key and value pairs to be associated with the share.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareMetadata"), + }, + }, + }, + }, + }, + "isPublic": { + SchemaProps: spec.SchemaProps{ + Description: "isPublic defines whether the share is publicly visible.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"size", "shareProto"}, + }, + }, + Dependencies: []string{ + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareMetadata"}, + } +} + +func schema_openstack_resource_controller_v2_api_v1alpha1_ShareResourceStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ShareResourceStatus represents the observed state of the resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name is a Human-readable name for the resource. Might not be unique.", + Type: []string{"string"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Description: "description is a human-readable description for the resource.", + Type: []string{"string"}, + Format: "", + }, + }, + "size": { + SchemaProps: spec.SchemaProps{ + Description: "size is the size of the share in GiB.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "shareProto": { + SchemaProps: spec.SchemaProps{ + Description: "shareProto is the file system protocol.", + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "status represents the current status of the share.", + Type: []string{"string"}, + Format: "", + }, + }, + "availabilityZone": { + SchemaProps: spec.SchemaProps{ + Description: "availabilityZone is which availability zone the share is in.", + Type: []string{"string"}, + Format: "", + }, + }, + "exportLocations": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "exportLocations contains paths for accessing the share.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareExportLocation"), + }, + }, + }, + }, + }, + "metadata": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "metadata key and value pairs associated with the share.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareMetadataStatus"), + }, + }, + }, + }, + }, + "isPublic": { + SchemaProps: spec.SchemaProps{ + Description: "isPublic indicates whether the share is publicly visible.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "createdAt": { + SchemaProps: spec.SchemaProps{ + Description: "createdAt shows the date and time when the resource was created. The date and time stamp format is ISO 8601.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "projectID": { + SchemaProps: spec.SchemaProps{ + Description: "projectID is the ID of the project that owns the share.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareExportLocation", "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareMetadataStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_openstack_resource_controller_v2_api_v1alpha1_ShareSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ShareSpec defines the desired state of an ORC object.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "import": { + SchemaProps: spec.SchemaProps{ + Description: "import refers to an existing OpenStack resource which will be imported instead of creating a new one.", + Ref: ref("github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareImport"), + }, + }, + "resource": { + SchemaProps: spec.SchemaProps{ + Description: "resource specifies the desired state of the resource.\n\nresource may not be specified if the management policy is `unmanaged`.\n\nresource must be specified if the management policy is `managed`.", + Ref: ref("github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareResourceSpec"), + }, + }, + "managementPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "managementPolicy defines how ORC will treat the object. Valid values are `managed`: ORC will create, update, and delete the resource; `unmanaged`: ORC will import an existing resource, and will not apply updates to it or delete it.", + Type: []string{"string"}, + Format: "", + }, + }, + "managedOptions": { + SchemaProps: spec.SchemaProps{ + Description: "managedOptions specifies options which may be applied to managed objects.", + Ref: ref("github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ManagedOptions"), + }, + }, + "cloudCredentialsRef": { + SchemaProps: spec.SchemaProps{ + Description: "cloudCredentialsRef points to a secret containing OpenStack credentials", + Default: map[string]interface{}{}, + Ref: ref("github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.CloudCredentialsReference"), + }, + }, + }, + Required: []string{"cloudCredentialsRef"}, + }, + }, + Dependencies: []string{ + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.CloudCredentialsReference", "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ManagedOptions", "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareImport", "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareResourceSpec"}, + } +} + +func schema_openstack_resource_controller_v2_api_v1alpha1_ShareStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ShareStatus defines the observed state of an ORC resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "type", + }, + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "conditions represents the observed status of the object. Known .status.conditions.type are: \"Available\", \"Progressing\"\n\nAvailable represents the availability of the OpenStack resource. If it is true then the resource is ready for use.\n\nProgressing indicates whether the controller is still attempting to reconcile the current state of the OpenStack resource to the desired state. Progressing will be False either because the desired state has been achieved, or because some terminal error prevents it from ever being achieved and the controller is no longer attempting to reconcile. If Progressing is True, an observer waiting on the resource should continue to wait.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + }, + }, + }, + }, + }, + "id": { + SchemaProps: spec.SchemaProps{ + Description: "id is the unique identifier of the OpenStack resource.", + Type: []string{"string"}, + Format: "", + }, + }, + "resource": { + SchemaProps: spec.SchemaProps{ + Description: "resource contains the observed state of the OpenStack resource.", + Ref: ref("github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareResourceStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1.ShareResourceStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.Condition"}, + } +} + func schema_openstack_resource_controller_v2_api_v1alpha1_Subnet(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/cmd/resource-generator/main.go b/cmd/resource-generator/main.go index 0e7444cc1..b11d0e255 100644 --- a/cmd/resource-generator/main.go +++ b/cmd/resource-generator/main.go @@ -140,6 +140,9 @@ var resources []templateFields = []templateFields{ Name: "ServerGroup", ExistingOSClient: true, }, + { + Name: "Share", + }, { Name: "Subnet", ExistingOSClient: true, diff --git a/config/crd/bases/openstack.k-orc.cloud_shares.yaml b/config/crd/bases/openstack.k-orc.cloud_shares.yaml new file mode 100644 index 000000000..ca70b6be1 --- /dev/null +++ b/config/crd/bases/openstack.k-orc.cloud_shares.yaml @@ -0,0 +1,442 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.17.1 + name: shares.openstack.k-orc.cloud +spec: + group: openstack.k-orc.cloud + names: + categories: + - openstack + kind: Share + listKind: ShareList + plural: shares + singular: share + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: Resource ID + jsonPath: .status.id + name: ID + type: string + - description: Availability status of resource + jsonPath: .status.conditions[?(@.type=='Available')].status + name: Available + type: string + - description: Message describing current progress status + jsonPath: .status.conditions[?(@.type=='Progressing')].message + name: Message + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: Share is the Schema for an ORC resource. + 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: spec specifies the desired state of the resource. + properties: + cloudCredentialsRef: + description: cloudCredentialsRef points to a secret containing OpenStack + credentials + properties: + cloudName: + description: cloudName specifies the name of the entry in the + clouds.yaml file to use. + maxLength: 256 + minLength: 1 + type: string + secretName: + description: |- + secretName is the name of a secret in the same namespace as the resource being provisioned. + The secret must contain a key named `clouds.yaml` which contains an OpenStack clouds.yaml file. + The secret may optionally contain a key named `cacert` containing a PEM-encoded CA certificate. + maxLength: 253 + minLength: 1 + type: string + required: + - cloudName + - secretName + type: object + import: + description: |- + import refers to an existing OpenStack resource which will be imported instead of + creating a new one. + maxProperties: 1 + minProperties: 1 + properties: + filter: + description: |- + filter contains a resource query which is expected to return a single + result. The controller will continue to retry if filter returns no + results. If filter returns multiple results the controller will set an + error state and will not continue to retry. + minProperties: 1 + properties: + description: + description: description of the existing resource + maxLength: 255 + minLength: 1 + type: string + isPublic: + description: isPublic filters by public visibility + type: boolean + name: + description: name of the existing resource + maxLength: 255 + minLength: 1 + pattern: ^[^,]+$ + type: string + shareProto: + description: shareProto is the file system protocol to filter + by + enum: + - NFS + - CIFS + - GlusterFS + - HDFS + - CephFS + - MAPRFS + type: string + status: + description: status is the share status to filter by + enum: + - creating + - available + - deleting + - error + - error_deleting + - manage_starting + - manage_error + - unmanage_starting + - unmanage_error + - extending + - extending_error + - shrinking + - shrinking_error + type: string + type: object + id: + description: |- + id contains the unique identifier of an existing OpenStack resource. Note + that when specifying an import by ID, the resource MUST already exist. + The ORC object will enter an error state if the resource does not exist. + format: uuid + maxLength: 36 + type: string + type: object + managedOptions: + description: managedOptions specifies options which may be applied + to managed objects. + properties: + onDelete: + default: delete + description: |- + onDelete specifies the behaviour of the controller when the ORC + object is deleted. Options are `delete` - delete the OpenStack resource; + `detach` - do not delete the OpenStack resource. If not specified, the + default is `delete`. + enum: + - delete + - detach + type: string + type: object + managementPolicy: + default: managed + description: |- + managementPolicy defines how ORC will treat the object. Valid values are + `managed`: ORC will create, update, and delete the resource; `unmanaged`: + ORC will import an existing resource, and will not apply updates to it or + delete it. + enum: + - managed + - unmanaged + type: string + x-kubernetes-validations: + - message: managementPolicy is immutable + rule: self == oldSelf + resource: + description: |- + resource specifies the desired state of the resource. + + resource may not be specified if the management policy is `unmanaged`. + + resource must be specified if the management policy is `managed`. + properties: + availabilityZone: + description: availabilityZone is the availability zone in which + to create the share. + maxLength: 255 + type: string + x-kubernetes-validations: + - message: availabilityZone is immutable + rule: self == oldSelf + description: + description: description is a human-readable description for the + resource. + maxLength: 255 + minLength: 1 + type: string + isPublic: + description: isPublic defines whether the share is publicly visible. + type: boolean + metadata: + description: metadata key and value pairs to be associated with + the share. + items: + properties: + name: + description: name is the name of the metadata + maxLength: 255 + type: string + value: + description: value is the value of the metadata + maxLength: 255 + type: string + required: + - name + - value + type: object + maxItems: 64 + type: array + x-kubernetes-list-type: atomic + name: + description: |- + name will be the name of the created resource. If not specified, the + name of the ORC object will be used. + maxLength: 255 + minLength: 1 + pattern: ^[^,]+$ + type: string + shareProto: + description: |- + shareProto is the file system protocol for the share. + Valid values are NFS, CIFS, GlusterFS, HDFS, CephFS, or MAPRFS. + enum: + - NFS + - CIFS + - GlusterFS + - HDFS + - CephFS + - MAPRFS + type: string + x-kubernetes-validations: + - message: shareProto is immutable + rule: self == oldSelf + size: + description: size is the size of the share, in gibibytes (GiB). + format: int32 + minimum: 1 + type: integer + x-kubernetes-validations: + - message: size is immutable + rule: self == oldSelf + required: + - shareProto + - size + type: object + required: + - cloudCredentialsRef + type: object + x-kubernetes-validations: + - message: resource must be specified when policy is managed + rule: 'self.managementPolicy == ''managed'' ? has(self.resource) : true' + - message: import may not be specified when policy is managed + rule: 'self.managementPolicy == ''managed'' ? !has(self.__import__) + : true' + - message: resource may not be specified when policy is unmanaged + rule: 'self.managementPolicy == ''unmanaged'' ? !has(self.resource) + : true' + - message: import must be specified when policy is unmanaged + rule: 'self.managementPolicy == ''unmanaged'' ? has(self.__import__) + : true' + - message: managedOptions may only be provided when policy is managed + rule: 'has(self.managedOptions) ? self.managementPolicy == ''managed'' + : true' + status: + description: status defines the observed state of the resource. + properties: + conditions: + description: |- + conditions represents the observed status of the object. + Known .status.conditions.type are: "Available", "Progressing" + + Available represents the availability of the OpenStack resource. If it is + true then the resource is ready for use. + + Progressing indicates whether the controller is still attempting to + reconcile the current state of the OpenStack resource to the desired + state. Progressing will be False either because the desired state has + been achieved, or because some terminal error prevents it from ever being + achieved and the controller is no longer attempting to reconcile. If + Progressing is True, an observer waiting on the resource should continue + to wait. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + maxItems: 32 + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + id: + description: id is the unique identifier of the OpenStack resource. + maxLength: 1024 + type: string + resource: + description: resource contains the observed state of the OpenStack + resource. + properties: + availabilityZone: + description: availabilityZone is which availability zone the share + is in. + maxLength: 1024 + type: string + createdAt: + description: createdAt shows the date and time when the resource + was created. The date and time stamp format is ISO 8601. + format: date-time + type: string + description: + description: description is a human-readable description for the + resource. + maxLength: 1024 + type: string + exportLocations: + description: exportLocations contains paths for accessing the + share. + items: + properties: + path: + description: path is the export path for accessing the share + maxLength: 1024 + type: string + preferred: + description: preferred indicates if this is the preferred + export location + type: boolean + type: object + maxItems: 32 + type: array + x-kubernetes-list-type: atomic + isPublic: + description: isPublic indicates whether the share is publicly + visible. + type: boolean + metadata: + description: metadata key and value pairs associated with the + share. + items: + properties: + name: + description: name is the name of the metadata + maxLength: 255 + type: string + value: + description: value is the value of the metadata + maxLength: 255 + type: string + type: object + maxItems: 64 + type: array + x-kubernetes-list-type: atomic + name: + description: name is a Human-readable name for the resource. Might + not be unique. + maxLength: 1024 + type: string + projectID: + description: projectID is the ID of the project that owns the + share. + maxLength: 1024 + type: string + shareProto: + description: shareProto is the file system protocol. + maxLength: 1024 + type: string + size: + description: size is the size of the share in GiB. + format: int32 + type: integer + status: + description: status represents the current status of the share. + maxLength: 1024 + type: string + type: object + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 319e67e8a..26940f358 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -20,6 +20,7 @@ resources: - bases/openstack.k-orc.cloud_servers.yaml - bases/openstack.k-orc.cloud_servergroups.yaml - bases/openstack.k-orc.cloud_services.yaml +- bases/openstack.k-orc.cloud_shares.yaml - bases/openstack.k-orc.cloud_subnets.yaml - bases/openstack.k-orc.cloud_trunks.yaml - bases/openstack.k-orc.cloud_volumes.yaml diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 1bb68f2b9..03543dbc1 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -34,6 +34,7 @@ rules: - servergroups - servers - services + - shares - subnets - trunks - volumes @@ -66,6 +67,7 @@ rules: - servergroups/status - servers/status - services/status + - shares/status - subnets/status - trunks/status - volumes/status diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index 488fa1eb7..38b690434 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -18,6 +18,7 @@ resources: - openstack_v1alpha1_server.yaml - openstack_v1alpha1_servergroup.yaml - openstack_v1alpha1_service.yaml +- openstack_v1alpha1_share.yaml - openstack_v1alpha1_subnet.yaml - openstack_v1alpha1_trunk.yaml - openstack_v1alpha1_volume.yaml diff --git a/config/samples/openstack_v1alpha1_share.yaml b/config/samples/openstack_v1alpha1_share.yaml new file mode 100644 index 000000000..242b6a355 --- /dev/null +++ b/config/samples/openstack_v1alpha1_share.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-sample +spec: + cloudCredentialsRef: + # TODO(scaffolding): Use openstack-admin if the resource needs admin credentials to be created + cloudName: openstack + secretName: openstack-clouds + managementPolicy: managed + resource: + description: Sample Share + # TODO(scaffolding): Add all fields the resource supports diff --git a/internal/controllers/share/actuator.go b/internal/controllers/share/actuator.go new file mode 100644 index 000000000..6c112c819 --- /dev/null +++ b/internal/controllers/share/actuator.go @@ -0,0 +1,280 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package share + +import ( + "context" + "iter" + "time" + + "github.com/gophercloud/gophercloud/v2/openstack/sharedfilesystems/v2/shares" + corev1 "k8s.io/api/core/v1" + "k8s.io/utils/ptr" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + + orcv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1" + "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/generic/interfaces" + "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/generic/progress" + "github.com/k-orc/openstack-resource-controller/v2/internal/logging" + "github.com/k-orc/openstack-resource-controller/v2/internal/osclients" + orcerrors "github.com/k-orc/openstack-resource-controller/v2/internal/util/errors" +) + +// OpenStack resource types +type ( + osResourceT = shares.Share + + createResourceActuator = interfaces.CreateResourceActuator[orcObjectPT, orcObjectT, filterT, osResourceT] + deleteResourceActuator = interfaces.DeleteResourceActuator[orcObjectPT, orcObjectT, osResourceT] + resourceReconciler = interfaces.ResourceReconciler[orcObjectPT, osResourceT] + helperFactory = interfaces.ResourceHelperFactory[orcObjectPT, orcObjectT, resourceSpecT, filterT, osResourceT] +) + +// The frequency to poll when waiting for the resource to become available +const shareAvailablePollingPeriod = 15 * time.Second + +// The frequency to poll when waiting for the resource to be deleted +const shareDeletingPollingPeriod = 15 * time.Second + +type shareActuator struct { + osClient osclients.ShareClient + k8sClient client.Client +} + +var _ createResourceActuator = shareActuator{} +var _ deleteResourceActuator = shareActuator{} + +func (shareActuator) GetResourceID(osResource *osResourceT) string { + return osResource.ID +} + +func (actuator shareActuator) GetOSResourceByID(ctx context.Context, id string) (*osResourceT, progress.ReconcileStatus) { + resource, err := actuator.osClient.GetShare(ctx, id) + if err != nil { + return nil, progress.WrapError(err) + } + return resource, nil +} + +func (actuator shareActuator) ListOSResourcesForAdoption(ctx context.Context, orcObject orcObjectPT) (iter.Seq2[*osResourceT, error], bool) { + resourceSpec := orcObject.Spec.Resource + if resourceSpec == nil { + return nil, false + } + + listOpts := shares.ListOpts{ + Name: getResourceName(orcObject), + } + + return actuator.osClient.ListShares(ctx, listOpts), true +} + +func (actuator shareActuator) ListOSResourcesForImport(ctx context.Context, obj orcObjectPT, filter filterT) (iter.Seq2[*osResourceT, error], progress.ReconcileStatus) { + var filters []osclients.ResourceFilter[osResourceT] + + // NOTE: The API doesn't support filtering by description or shareProto + // we'll have to do it client-side. + if filter.Description != nil { + filters = append(filters, func(s *shares.Share) bool { + return s.Description == *filter.Description + }) + } + if filter.ShareProto != nil { + filters = append(filters, func(s *shares.Share) bool { + return s.ShareProto == *filter.ShareProto + }) + } + + listOpts := shares.ListOpts{ + Name: string(ptr.Deref(filter.Name, "")), + Status: ptr.Deref(filter.Status, ""), + } + + if filter.IsPublic != nil { + listOpts.IsPublic = filter.IsPublic + } + + return actuator.listOSResources(ctx, filters, listOpts), nil +} + +func (actuator shareActuator) listOSResources(ctx context.Context, filters []osclients.ResourceFilter[osResourceT], listOpts shares.ListOptsBuilder) iter.Seq2[*shares.Share, error] { + shares := actuator.osClient.ListShares(ctx, listOpts) + return osclients.Filter(shares, filters...) +} + +func (actuator shareActuator) CreateResource(ctx context.Context, obj orcObjectPT) (*osResourceT, progress.ReconcileStatus) { + resource := obj.Spec.Resource + + if resource == nil { + // Should have been caught by API validation + return nil, progress.WrapError( + orcerrors.Terminal(orcv1alpha1.ConditionReasonInvalidConfiguration, "Creation requested, but spec.resource is not set")) + } + + metadata := make(map[string]string) + for _, m := range resource.Metadata { + metadata[m.Name] = m.Value + } + + createOpts := shares.CreateOpts{ + Name: getResourceName(obj), + Description: ptr.Deref(resource.Description, ""), + Size: int(resource.Size), + ShareProto: resource.ShareProto, + AvailabilityZone: resource.AvailabilityZone, + Metadata: metadata, + IsPublic: resource.IsPublic, + } + + osResource, err := actuator.osClient.CreateShare(ctx, createOpts) + if err != nil { + // We should require the spec to be updated before retrying a create which returned a conflict + if !orcerrors.IsRetryable(err) { + err = orcerrors.Terminal(orcv1alpha1.ConditionReasonInvalidConfiguration, "invalid configuration creating resource: "+err.Error(), err) + } + return nil, progress.WrapError(err) + } + + return osResource, nil +} + +func (actuator shareActuator) DeleteResource(ctx context.Context, _ orcObjectPT, resource *osResourceT) progress.ReconcileStatus { + if resource.Status == ShareStatusDeleting { + return progress.WaitingOnOpenStack(progress.WaitingOnReady, shareDeletingPollingPeriod) + } + return progress.WrapError(actuator.osClient.DeleteShare(ctx, resource.ID)) +} + +func (actuator shareActuator) updateResource(ctx context.Context, obj orcObjectPT, osResource *osResourceT) progress.ReconcileStatus { + log := ctrl.LoggerFrom(ctx) + resource := obj.Spec.Resource + if resource == nil { + // Should have been caught by API validation + return progress.WrapError( + orcerrors.Terminal(orcv1alpha1.ConditionReasonInvalidConfiguration, "Update requested, but spec.resource is not set")) + } + + updateOpts := shares.UpdateOpts{} + + handleIsPublicUpdate(&updateOpts, resource, osResource) + + needsUpdate, err := needsUpdate(updateOpts) + if err != nil { + return progress.WrapError( + orcerrors.Terminal(orcv1alpha1.ConditionReasonInvalidConfiguration, "invalid configuration updating resource: "+err.Error(), err)) + } + if !needsUpdate { + log.V(logging.Debug).Info("No changes") + return nil + } + + _, err = actuator.osClient.UpdateShare(ctx, osResource.ID, updateOpts) + + // We should require the spec to be updated before retrying an update which returned a conflict + if orcerrors.IsConflict(err) { + err = orcerrors.Terminal(orcv1alpha1.ConditionReasonInvalidConfiguration, "invalid configuration updating resource: "+err.Error(), err) + } + + if err != nil { + return progress.WrapError(err) + } + + return progress.NeedsRefresh() +} + +func needsUpdate(updateOpts shares.UpdateOpts) (bool, error) { + updateOptsMap, err := updateOpts.ToShareUpdateMap() + if err != nil { + return false, err + } + + updateMap, ok := updateOptsMap["share"].(map[string]any) + if !ok { + updateMap = make(map[string]any) + } + + return len(updateMap) > 0, nil +} + +// NOTE: Manila API doesn't support updating name or description +// func handleNameUpdate(updateOpts *shares.UpdateOpts, obj orcObjectPT, osResource *osResourceT) { +// name := getResourceName(obj) +// if osResource.Name != name { +// updateOpts.Name = &name +// } +// } + +// func handleDescriptionUpdate(updateOpts *shares.UpdateOpts, resource *resourceSpecT, osResource *osResourceT) { +// description := ptr.Deref(resource.Description, "") +// if osResource.Description != description { +// updateOpts.Description = &description +// } +// } + +func handleIsPublicUpdate(updateOpts *shares.UpdateOpts, resource *resourceSpecT, osResource *osResourceT) { + isPublic := ptr.Deref(resource.IsPublic, false) + if osResource.IsPublic != isPublic { + updateOpts.IsPublic = &isPublic + } +} + +func (actuator shareActuator) GetResourceReconcilers(ctx context.Context, orcObject orcObjectPT, osResource *osResourceT, controller interfaces.ResourceController) ([]resourceReconciler, progress.ReconcileStatus) { + return []resourceReconciler{ + actuator.updateResource, + }, nil +} + +type shareHelperFactory struct{} + +var _ helperFactory = shareHelperFactory{} + +func newActuator(ctx context.Context, orcObject *orcv1alpha1.Share, controller interfaces.ResourceController) (shareActuator, progress.ReconcileStatus) { + log := ctrl.LoggerFrom(ctx) + + // Ensure credential secrets exist and have our finalizer + _, reconcileStatus := credentialsDependency.GetDependencies(ctx, controller.GetK8sClient(), orcObject, func(*corev1.Secret) bool { return true }) + if needsReschedule, _ := reconcileStatus.NeedsReschedule(); needsReschedule { + return shareActuator{}, reconcileStatus + } + + clientScope, err := controller.GetScopeFactory().NewClientScopeFromObject(ctx, controller.GetK8sClient(), log, orcObject) + if err != nil { + return shareActuator{}, progress.WrapError(err) + } + osClient, err := clientScope.NewShareClient() + if err != nil { + return shareActuator{}, progress.WrapError(err) + } + + return shareActuator{ + osClient: osClient, + k8sClient: controller.GetK8sClient(), + }, nil +} + +func (shareHelperFactory) NewAPIObjectAdapter(obj orcObjectPT) adapterI { + return shareAdapter{obj} +} + +func (shareHelperFactory) NewCreateActuator(ctx context.Context, orcObject orcObjectPT, controller interfaces.ResourceController) (createResourceActuator, progress.ReconcileStatus) { + return newActuator(ctx, orcObject, controller) +} + +func (shareHelperFactory) NewDeleteActuator(ctx context.Context, orcObject orcObjectPT, controller interfaces.ResourceController) (deleteResourceActuator, progress.ReconcileStatus) { + return newActuator(ctx, orcObject, controller) +} diff --git a/internal/controllers/share/actuator_test.go b/internal/controllers/share/actuator_test.go new file mode 100644 index 000000000..852ac922e --- /dev/null +++ b/internal/controllers/share/actuator_test.go @@ -0,0 +1,55 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package share + +import ( + "testing" + + "github.com/gophercloud/gophercloud/v2/openstack/sharedfilesystems/v2/shares" + "k8s.io/utils/ptr" +) + +func TestNeedsUpdate(t *testing.T) { + testCases := []struct { + name string + updateOpts shares.UpdateOpts + expectChange bool + }{ + { + name: "Empty base opts", + updateOpts: shares.UpdateOpts{}, + expectChange: false, + }, + { + name: "Updated opts with IsPublic", + updateOpts: shares.UpdateOpts{IsPublic: ptr.To(true)}, + expectChange: true, + }, + } + + for _, tt := range testCases { + t.Run(tt.name, func(t *testing.T) { + got, _ := needsUpdate(tt.updateOpts) + if got != tt.expectChange { + t.Errorf("Expected change: %v, got: %v", tt.expectChange, got) + } + }) + } +} + +// NOTE: Tests for handleNameUpdate and handleDescriptionUpdate removed +// because Manila API doesn't support updating name or description diff --git a/internal/controllers/share/controller.go b/internal/controllers/share/controller.go new file mode 100644 index 000000000..ed111c0aa --- /dev/null +++ b/internal/controllers/share/controller.go @@ -0,0 +1,68 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package share + +import ( + "context" + "errors" + + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/controller" + + orcv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1" + + "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/generic/interfaces" + "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/generic/reconciler" + "github.com/k-orc/openstack-resource-controller/v2/internal/scope" + "github.com/k-orc/openstack-resource-controller/v2/internal/util/credentials" +) + +const controllerName = "share" + +// +kubebuilder:rbac:groups=openstack.k-orc.cloud,resources=shares,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=openstack.k-orc.cloud,resources=shares/status,verbs=get;update;patch + +type shareReconcilerConstructor struct { + scopeFactory scope.Factory +} + +func New(scopeFactory scope.Factory) interfaces.Controller { + return shareReconcilerConstructor{scopeFactory: scopeFactory} +} + +func (shareReconcilerConstructor) GetName() string { + return controllerName +} + +// SetupWithManager sets up the controller with the Manager. +func (c shareReconcilerConstructor) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { + log := ctrl.LoggerFrom(ctx) + + builder := ctrl.NewControllerManagedBy(mgr). + WithOptions(options). + For(&orcv1alpha1.Share{}) + + if err := errors.Join( + credentialsDependency.AddToManager(ctx, mgr), + credentials.AddCredentialsWatch(log, mgr.GetClient(), builder, credentialsDependency), + ); err != nil { + return err + } + + r := reconciler.NewController(controllerName, mgr.GetClient(), c.scopeFactory, shareHelperFactory{}, shareStatusWriter{}) + return builder.Complete(&r) +} diff --git a/internal/controllers/share/status.go b/internal/controllers/share/status.go new file mode 100644 index 000000000..229eff439 --- /dev/null +++ b/internal/controllers/share/status.go @@ -0,0 +1,96 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package share + +import ( + "github.com/go-logr/logr" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + orcv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1" + "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/generic/interfaces" + "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/generic/progress" + orcapplyconfigv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/pkg/clients/applyconfiguration/api/v1alpha1" +) + +const ( + ShareStatusCreating = "creating" + ShareStatusAvailable = "available" + ShareStatusDeleting = "deleting" + ShareStatusError = "error" + ShareStatusErrorDeleting = "error_deleting" + ShareStatusManageStarting = "manage_starting" + ShareStatusManageError = "manage_error" + ShareStatusUnmanageStarting = "unmanage_starting" + ShareStatusUnmanageError = "unmanage_error" + ShareStatusExtending = "extending" + ShareStatusExtendingError = "extending_error" + ShareStatusShrinking = "shrinking" + ShareStatusShrinkingError = "shrinking_error" +) + +type shareStatusWriter struct{} + +type objectApplyT = orcapplyconfigv1alpha1.ShareApplyConfiguration +type statusApplyT = orcapplyconfigv1alpha1.ShareStatusApplyConfiguration + +var _ interfaces.ResourceStatusWriter[*orcv1alpha1.Share, *osResourceT, *objectApplyT, *statusApplyT] = shareStatusWriter{} + +func (shareStatusWriter) GetApplyConfig(name, namespace string) *objectApplyT { + return orcapplyconfigv1alpha1.Share(name, namespace) +} + +func (shareStatusWriter) ResourceAvailableStatus(orcObject *orcv1alpha1.Share, osResource *osResourceT) (metav1.ConditionStatus, progress.ReconcileStatus) { + if osResource == nil { + if orcObject.Status.ID == nil { + return metav1.ConditionFalse, nil + } else { + return metav1.ConditionUnknown, nil + } + } + + if osResource.Status == ShareStatusAvailable { + return metav1.ConditionTrue, nil + } + + // Terminal error states - don't poll + if osResource.Status == ShareStatusError || + osResource.Status == ShareStatusErrorDeleting || + osResource.Status == ShareStatusManageError || + osResource.Status == ShareStatusUnmanageError || + osResource.Status == ShareStatusExtendingError || + osResource.Status == ShareStatusShrinkingError { + return metav1.ConditionFalse, nil + } + + // Otherwise we should continue to poll + return metav1.ConditionFalse, progress.WaitingOnOpenStack(progress.WaitingOnReady, shareAvailablePollingPeriod) +} + +func (shareStatusWriter) ApplyResourceStatus(log logr.Logger, osResource *osResourceT, statusApply *statusApplyT) { + resourceStatus := orcapplyconfigv1alpha1.ShareResourceStatus(). + WithName(osResource.Name) + + if osResource.Description != "" { + resourceStatus.WithDescription(osResource.Description) + } + + // TODO: Add more fields after running make generate to create apply configurations + // Fields to add: ShareProto, Status, Size, AvailabilityZone, IsPublic, + // ExportLocations, Metadata, CreatedAt, ProjectID + + statusApply.WithResource(resourceStatus) +} diff --git a/internal/controllers/share/tests/share-create-full/00-assert.yaml b/internal/controllers/share/tests/share-create-full/00-assert.yaml new file mode 100644 index 000000000..3e71ac467 --- /dev/null +++ b/internal/controllers/share/tests/share-create-full/00-assert.yaml @@ -0,0 +1,39 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-create-full +status: + resource: + name: share-create-full-override + description: Share from "create full" test + size: 2 + shareProto: NFS + status: available + isPublic: false + metadata: + - name: test-key + value: test-value + - name: environment + value: e2e-test + conditions: + - type: Available + status: "True" + reason: Success + - type: Progressing + status: "False" + reason: Success +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +resourceRefs: + - apiVersion: openstack.k-orc.cloud/v1alpha1 + kind: Share + name: share-create-full + ref: share +assertAll: + - celExpr: "share.status.id != ''" + - celExpr: "share.status.resource.projectID != ''" + - celExpr: "share.status.resource.createdAt != ''" + - celExpr: "share.status.resource.exportLocations.size() > 0" + - celExpr: "share.status.resource.metadata.size() == 2" diff --git a/internal/controllers/share/tests/share-create-full/00-create-resource.yaml b/internal/controllers/share/tests/share-create-full/00-create-resource.yaml new file mode 100644 index 000000000..6ee9342fb --- /dev/null +++ b/internal/controllers/share/tests/share-create-full/00-create-resource.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-create-full +spec: + cloudCredentialsRef: + cloudName: openstack + secretName: openstack-clouds + managementPolicy: managed + resource: + name: share-create-full-override + description: Share from "create full" test + size: 2 + shareProto: NFS + metadata: + - name: test-key + value: test-value + - name: environment + value: e2e-test + isPublic: false diff --git a/internal/controllers/share/tests/share-create-full/00-secret.yaml b/internal/controllers/share/tests/share-create-full/00-secret.yaml new file mode 100644 index 000000000..045711ee7 --- /dev/null +++ b/internal/controllers/share/tests/share-create-full/00-secret.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT} + namespaced: true diff --git a/internal/controllers/share/tests/share-create-full/README.md b/internal/controllers/share/tests/share-create-full/README.md new file mode 100644 index 000000000..0a4de00eb --- /dev/null +++ b/internal/controllers/share/tests/share-create-full/README.md @@ -0,0 +1,11 @@ +# Create a Share with all the options + +## Step 00 + +Create a Share using all available fields, and verify that the observed state corresponds to the spec. + +Also validate that the OpenStack resource uses the name from the spec when it is specified. + +## Reference + +https://k-orc.cloud/development/writing-tests/#create-full diff --git a/internal/controllers/share/tests/share-create-minimal/00-assert.yaml b/internal/controllers/share/tests/share-create-minimal/00-assert.yaml new file mode 100644 index 000000000..9aacafcbd --- /dev/null +++ b/internal/controllers/share/tests/share-create-minimal/00-assert.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-create-minimal +status: + resource: + name: share-create-minimal + # TODO(scaffolding): Add all fields the resource supports + conditions: + - type: Available + status: "True" + reason: Success + - type: Progressing + status: "False" + reason: Success +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +resourceRefs: + - apiVersion: openstack.k-orc.cloud/v1alpha1 + kind: Share + name: share-create-minimal + ref: share +assertAll: + - celExpr: "share.status.id != ''" + # TODO(scaffolding): Add more checks diff --git a/internal/controllers/share/tests/share-create-minimal/00-create-resource.yaml b/internal/controllers/share/tests/share-create-minimal/00-create-resource.yaml new file mode 100644 index 000000000..1bd1091b0 --- /dev/null +++ b/internal/controllers/share/tests/share-create-minimal/00-create-resource.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-create-minimal +spec: + cloudCredentialsRef: + cloudName: openstack + secretName: openstack-clouds + managementPolicy: managed + resource: + size: 1 + shareProto: NFS diff --git a/internal/controllers/share/tests/share-create-minimal/00-secret.yaml b/internal/controllers/share/tests/share-create-minimal/00-secret.yaml new file mode 100644 index 000000000..045711ee7 --- /dev/null +++ b/internal/controllers/share/tests/share-create-minimal/00-secret.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT} + namespaced: true diff --git a/internal/controllers/share/tests/share-create-minimal/01-assert.yaml b/internal/controllers/share/tests/share-create-minimal/01-assert.yaml new file mode 100644 index 000000000..25276c933 --- /dev/null +++ b/internal/controllers/share/tests/share-create-minimal/01-assert.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +resourceRefs: + - apiVersion: v1 + kind: Secret + name: openstack-clouds + ref: secret +assertAll: + - celExpr: "secret.metadata.deletionTimestamp != 0" + - celExpr: "'openstack.k-orc.cloud/share' in secret.metadata.finalizers" diff --git a/internal/controllers/share/tests/share-create-minimal/01-delete-secret.yaml b/internal/controllers/share/tests/share-create-minimal/01-delete-secret.yaml new file mode 100644 index 000000000..1620791b9 --- /dev/null +++ b/internal/controllers/share/tests/share-create-minimal/01-delete-secret.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + # We expect the deletion to hang due to the finalizer, so use --wait=false + - command: kubectl delete secret openstack-clouds --wait=false + namespaced: true diff --git a/internal/controllers/share/tests/share-create-minimal/README.md b/internal/controllers/share/tests/share-create-minimal/README.md new file mode 100644 index 000000000..30c5ed6b7 --- /dev/null +++ b/internal/controllers/share/tests/share-create-minimal/README.md @@ -0,0 +1,15 @@ +# Create a Share with the minimum options + +## Step 00 + +Create a minimal Share, that sets only the required fields, and verify that the observed state corresponds to the spec. + +Also validate that the OpenStack resource uses the name of the ORC object when no name is explicitly specified. + +## Step 01 + +Try deleting the secret and ensure that it is not deleted thanks to the finalizer. + +## Reference + +https://k-orc.cloud/development/writing-tests/#create-minimal diff --git a/internal/controllers/share/tests/share-import-error/00-assert.yaml b/internal/controllers/share/tests/share-import-error/00-assert.yaml new file mode 100644 index 000000000..2b1f34e3a --- /dev/null +++ b/internal/controllers/share/tests/share-import-error/00-assert.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import-error-external-1 +status: + conditions: + - type: Available + message: OpenStack resource is available + status: "True" + reason: Success + - type: Progressing + message: OpenStack resource is up to date + status: "False" + reason: Success +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import-error-external-2 +status: + conditions: + - type: Available + message: OpenStack resource is available + status: "True" + reason: Success + - type: Progressing + message: OpenStack resource is up to date + status: "False" + reason: Success diff --git a/internal/controllers/share/tests/share-import-error/00-create-resources.yaml b/internal/controllers/share/tests/share-import-error/00-create-resources.yaml new file mode 100644 index 000000000..c63c9b538 --- /dev/null +++ b/internal/controllers/share/tests/share-import-error/00-create-resources.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import-error-external-1 +spec: + cloudCredentialsRef: + cloudName: openstack + secretName: openstack-clouds + managementPolicy: managed + resource: + description: Share from "import error" test + size: 1 + shareProto: NFS +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import-error-external-2 +spec: + cloudCredentialsRef: + cloudName: openstack + secretName: openstack-clouds + managementPolicy: managed + resource: + description: Share from "import error" test + size: 1 + shareProto: NFS diff --git a/internal/controllers/share/tests/share-import-error/00-secret.yaml b/internal/controllers/share/tests/share-import-error/00-secret.yaml new file mode 100644 index 000000000..045711ee7 --- /dev/null +++ b/internal/controllers/share/tests/share-import-error/00-secret.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT} + namespaced: true diff --git a/internal/controllers/share/tests/share-import-error/01-assert.yaml b/internal/controllers/share/tests/share-import-error/01-assert.yaml new file mode 100644 index 000000000..eb12e844a --- /dev/null +++ b/internal/controllers/share/tests/share-import-error/01-assert.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import-error +status: + conditions: + - type: Available + message: found more than one matching OpenStack resource during import + status: "False" + reason: InvalidConfiguration + - type: Progressing + message: found more than one matching OpenStack resource during import + status: "False" + reason: InvalidConfiguration diff --git a/internal/controllers/share/tests/share-import-error/01-import-resource.yaml b/internal/controllers/share/tests/share-import-error/01-import-resource.yaml new file mode 100644 index 000000000..b018dc7ab --- /dev/null +++ b/internal/controllers/share/tests/share-import-error/01-import-resource.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import-error +spec: + cloudCredentialsRef: + cloudName: openstack + secretName: openstack-clouds + managementPolicy: unmanaged + import: + filter: + description: Share from "import error" test diff --git a/internal/controllers/share/tests/share-import-error/README.md b/internal/controllers/share/tests/share-import-error/README.md new file mode 100644 index 000000000..648698d54 --- /dev/null +++ b/internal/controllers/share/tests/share-import-error/README.md @@ -0,0 +1,13 @@ +# Import Share with more than one matching resources + +## Step 00 + +Create two Shares with identical specs. + +## Step 01 + +Ensure that an imported Share with a filter matching the resources returns an error. + +## Reference + +https://k-orc.cloud/development/writing-tests/#import-error diff --git a/internal/controllers/share/tests/share-import/00-assert.yaml b/internal/controllers/share/tests/share-import/00-assert.yaml new file mode 100644 index 000000000..a6c6dabc7 --- /dev/null +++ b/internal/controllers/share/tests/share-import/00-assert.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import +status: + conditions: + - type: Available + message: Waiting for OpenStack resource to be created externally + status: "False" + reason: Progressing + - type: Progressing + message: Waiting for OpenStack resource to be created externally + status: "True" + reason: Progressing diff --git a/internal/controllers/share/tests/share-import/00-import-resource.yaml b/internal/controllers/share/tests/share-import/00-import-resource.yaml new file mode 100644 index 000000000..813b59542 --- /dev/null +++ b/internal/controllers/share/tests/share-import/00-import-resource.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import +spec: + cloudCredentialsRef: + cloudName: openstack + secretName: openstack-clouds + managementPolicy: unmanaged + import: + filter: + name: share-import-external + description: Share share-import-external from "share-import" test + shareProto: NFS diff --git a/internal/controllers/share/tests/share-import/00-secret.yaml b/internal/controllers/share/tests/share-import/00-secret.yaml new file mode 100644 index 000000000..045711ee7 --- /dev/null +++ b/internal/controllers/share/tests/share-import/00-secret.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT} + namespaced: true diff --git a/internal/controllers/share/tests/share-import/01-assert.yaml b/internal/controllers/share/tests/share-import/01-assert.yaml new file mode 100644 index 000000000..916080e32 --- /dev/null +++ b/internal/controllers/share/tests/share-import/01-assert.yaml @@ -0,0 +1,34 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import-external-not-this-one +status: + conditions: + - type: Available + message: OpenStack resource is available + status: "True" + reason: Success + - type: Progressing + message: OpenStack resource is up to date + status: "False" + reason: Success + resource: + name: share-import-external-not-this-one + description: Share share-import-external from "share-import" test + # TODO(scaffolding): Add fields necessary to match filter +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import +status: + conditions: + - type: Available + message: Waiting for OpenStack resource to be created externally + status: "False" + reason: Progressing + - type: Progressing + message: Waiting for OpenStack resource to be created externally + status: "True" + reason: Progressing diff --git a/internal/controllers/share/tests/share-import/01-create-trap-resource.yaml b/internal/controllers/share/tests/share-import/01-create-trap-resource.yaml new file mode 100644 index 000000000..0ad980499 --- /dev/null +++ b/internal/controllers/share/tests/share-import/01-create-trap-resource.yaml @@ -0,0 +1,17 @@ +--- +# This `share-import-external-not-this-one` resource serves two purposes: +# - ensure that we can successfully create another resource which name is a substring of it (i.e. it's not being adopted) +# - ensure that importing a resource which name is a substring of it will not pick this one. +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import-external-not-this-one +spec: + cloudCredentialsRef: + cloudName: openstack + secretName: openstack-clouds + managementPolicy: managed + resource: + description: Share share-import-external from "share-import" test + size: 1 + shareProto: CIFS diff --git a/internal/controllers/share/tests/share-import/02-assert.yaml b/internal/controllers/share/tests/share-import/02-assert.yaml new file mode 100644 index 000000000..972640bda --- /dev/null +++ b/internal/controllers/share/tests/share-import/02-assert.yaml @@ -0,0 +1,33 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +resourceRefs: + - apiVersion: openstack.k-orc.cloud/v1alpha1 + kind: Share + name: share-import-external + ref: share1 + - apiVersion: openstack.k-orc.cloud/v1alpha1 + kind: Share + name: share-import-external-not-this-one + ref: share2 +assertAll: + - celExpr: "share1.status.id != share2.status.id" +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import +status: + conditions: + - type: Available + message: OpenStack resource is available + status: "True" + reason: Success + - type: Progressing + message: OpenStack resource is up to date + status: "False" + reason: Success + resource: + name: share-import-external + description: Share share-import-external from "share-import" test + # TODO(scaffolding): Add all fields the resource supports diff --git a/internal/controllers/share/tests/share-import/02-create-resource.yaml b/internal/controllers/share/tests/share-import/02-create-resource.yaml new file mode 100644 index 000000000..23c0dabb8 --- /dev/null +++ b/internal/controllers/share/tests/share-import/02-create-resource.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-import-external +spec: + cloudCredentialsRef: + cloudName: openstack + secretName: openstack-clouds + managementPolicy: managed + resource: + description: Share share-import-external from "share-import" test + size: 1 + shareProto: NFS diff --git a/internal/controllers/share/tests/share-import/README.md b/internal/controllers/share/tests/share-import/README.md new file mode 100644 index 000000000..9a95b7094 --- /dev/null +++ b/internal/controllers/share/tests/share-import/README.md @@ -0,0 +1,18 @@ +# Import Share + +## Step 00 + +Import a share that matches all fields in the filter, and verify it is waiting for the external resource to be created. + +## Step 01 + +Create a share whose name is a superstring of the one specified in the import filter, otherwise matching the filter, and verify that it's not being imported. + +## Step 02 + +Create a share matching the filter and verify that the observed status on the imported share corresponds to the spec of the created share. +Also, confirm that it does not adopt any share whose name is a superstring of its own. + +## Reference + +https://k-orc.cloud/development/writing-tests/#import diff --git a/internal/controllers/share/tests/share-update/00-assert.yaml b/internal/controllers/share/tests/share-update/00-assert.yaml new file mode 100644 index 000000000..d41d0642c --- /dev/null +++ b/internal/controllers/share/tests/share-update/00-assert.yaml @@ -0,0 +1,26 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +resourceRefs: + - apiVersion: openstack.k-orc.cloud/v1alpha1 + kind: Share + name: share-update + ref: share +assertAll: + - celExpr: "!has(share.status.resource.description)" +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-update +status: + resource: + name: share-update + # TODO(scaffolding): Add matches for more fields + conditions: + - type: Available + status: "True" + reason: Success + - type: Progressing + status: "False" + reason: Success diff --git a/internal/controllers/share/tests/share-update/00-minimal-resource.yaml b/internal/controllers/share/tests/share-update/00-minimal-resource.yaml new file mode 100644 index 000000000..c5de1bd63 --- /dev/null +++ b/internal/controllers/share/tests/share-update/00-minimal-resource.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-update +spec: + cloudCredentialsRef: + cloudName: openstack + secretName: openstack-clouds + managementPolicy: managed + resource: + size: 1 + shareProto: NFS + isPublic: false diff --git a/internal/controllers/share/tests/share-update/00-secret.yaml b/internal/controllers/share/tests/share-update/00-secret.yaml new file mode 100644 index 000000000..045711ee7 --- /dev/null +++ b/internal/controllers/share/tests/share-update/00-secret.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT} + namespaced: true diff --git a/internal/controllers/share/tests/share-update/01-assert.yaml b/internal/controllers/share/tests/share-update/01-assert.yaml new file mode 100644 index 000000000..d16c08f26 --- /dev/null +++ b/internal/controllers/share/tests/share-update/01-assert.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-update +status: + resource: + name: share-update-updated + description: share-update-updated + # TODO(scaffolding): match all fields that were modified + conditions: + - type: Available + status: "True" + reason: Success + - type: Progressing + status: "False" + reason: Success diff --git a/internal/controllers/share/tests/share-update/01-updated-resource.yaml b/internal/controllers/share/tests/share-update/01-updated-resource.yaml new file mode 100644 index 000000000..8ea6d5732 --- /dev/null +++ b/internal/controllers/share/tests/share-update/01-updated-resource.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-update +spec: + resource: + size: 1 + shareProto: NFS + isPublic: true diff --git a/internal/controllers/share/tests/share-update/02-assert.yaml b/internal/controllers/share/tests/share-update/02-assert.yaml new file mode 100644 index 000000000..33e68a401 --- /dev/null +++ b/internal/controllers/share/tests/share-update/02-assert.yaml @@ -0,0 +1,26 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +resourceRefs: + - apiVersion: openstack.k-orc.cloud/v1alpha1 + kind: Share + name: share-update + ref: share +assertAll: + - celExpr: "!has(share.status.resource.description)" +--- +apiVersion: openstack.k-orc.cloud/v1alpha1 +kind: Share +metadata: + name: share-update +status: + resource: + name: share-update + # TODO(scaffolding): validate that updated fields were all reverted to their original value + conditions: + - type: Available + status: "True" + reason: Success + - type: Progressing + status: "False" + reason: Success diff --git a/internal/controllers/share/tests/share-update/02-reverted-resource.yaml b/internal/controllers/share/tests/share-update/02-reverted-resource.yaml new file mode 100644 index 000000000..2c6c253ff --- /dev/null +++ b/internal/controllers/share/tests/share-update/02-reverted-resource.yaml @@ -0,0 +1,7 @@ +# NOTE: kuttl only does patch updates, which means we can't delete a field. +# We have to use a kubectl apply command instead. +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - command: kubectl replace -f 00-minimal-resource.yaml + namespaced: true diff --git a/internal/controllers/share/tests/share-update/README.md b/internal/controllers/share/tests/share-update/README.md new file mode 100644 index 000000000..eed647c82 --- /dev/null +++ b/internal/controllers/share/tests/share-update/README.md @@ -0,0 +1,17 @@ +# Update Share + +## Step 00 + +Create a Share using only mandatory fields. + +## Step 01 + +Update all mutable fields. + +## Step 02 + +Revert the resource to its original value and verify that the resulting object matches its state when first created. + +## Reference + +https://k-orc.cloud/development/writing-tests/#update diff --git a/internal/controllers/share/zz_generated.adapter.go b/internal/controllers/share/zz_generated.adapter.go new file mode 100644 index 000000000..7632d2212 --- /dev/null +++ b/internal/controllers/share/zz_generated.adapter.go @@ -0,0 +1,88 @@ +// Code generated by resource-generator. DO NOT EDIT. +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package share + +import ( + orcv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1" + "github.com/k-orc/openstack-resource-controller/v2/internal/controllers/generic/interfaces" +) + +// Fundamental types +type ( + orcObjectT = orcv1alpha1.Share + orcObjectListT = orcv1alpha1.ShareList + resourceSpecT = orcv1alpha1.ShareResourceSpec + filterT = orcv1alpha1.ShareFilter +) + +// Derived types +type ( + orcObjectPT = *orcObjectT + adapterI = interfaces.APIObjectAdapter[orcObjectPT, resourceSpecT, filterT] + adapterT = shareAdapter +) + +type shareAdapter struct { + *orcv1alpha1.Share +} + +var _ adapterI = &adapterT{} + +func (f adapterT) GetObject() orcObjectPT { + return f.Share +} + +func (f adapterT) GetManagementPolicy() orcv1alpha1.ManagementPolicy { + return f.Spec.ManagementPolicy +} + +func (f adapterT) GetManagedOptions() *orcv1alpha1.ManagedOptions { + return f.Spec.ManagedOptions +} + +func (f adapterT) GetStatusID() *string { + return f.Status.ID +} + +func (f adapterT) GetResourceSpec() *resourceSpecT { + return f.Spec.Resource +} + +func (f adapterT) GetImportID() *string { + if f.Spec.Import == nil { + return nil + } + return f.Spec.Import.ID +} + +func (f adapterT) GetImportFilter() *filterT { + if f.Spec.Import == nil { + return nil + } + return f.Spec.Import.Filter +} + +// getResourceName returns the name of the OpenStack resource we should use. +// This method is not implemented as part of APIObjectAdapter as it is intended +// to be used by resource actuators, which don't use the adapter. +func getResourceName(orcObject orcObjectPT) string { + if orcObject.Spec.Resource.Name != nil { + return string(*orcObject.Spec.Resource.Name) + } + return orcObject.Name +} diff --git a/internal/controllers/share/zz_generated.controller.go b/internal/controllers/share/zz_generated.controller.go new file mode 100644 index 000000000..a36eeb8ef --- /dev/null +++ b/internal/controllers/share/zz_generated.controller.go @@ -0,0 +1,45 @@ +// Code generated by resource-generator. DO NOT EDIT. +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package share + +import ( + corev1 "k8s.io/api/core/v1" + + "github.com/k-orc/openstack-resource-controller/v2/internal/util/dependency" + orcstrings "github.com/k-orc/openstack-resource-controller/v2/internal/util/strings" +) + +var ( + // NOTE: controllerName must be defined in any controller using this template + + // finalizer is the string this controller adds to an object's Finalizers + finalizer = orcstrings.GetFinalizerName(controllerName) + + // externalObjectFieldOwner is the field owner we use when using + // server-side-apply on objects we don't control + externalObjectFieldOwner = orcstrings.GetSSAFieldOwner(controllerName) + + credentialsDependency = dependency.NewDeletionGuardDependency[*orcObjectListT, *corev1.Secret]( + "spec.cloudCredentialsRef.secretName", + func(obj orcObjectPT) []string { + return []string{obj.Spec.CloudCredentialsRef.SecretName} + }, + finalizer, externalObjectFieldOwner, + dependency.OverrideDependencyName("credentials"), + ) +) diff --git a/internal/osclients/mock/doc.go b/internal/osclients/mock/doc.go index 176f3bc93..3c2239e18 100644 --- a/internal/osclients/mock/doc.go +++ b/internal/osclients/mock/doc.go @@ -53,6 +53,9 @@ import ( //go:generate mockgen -package mock -destination=service.go -source=../service.go github.com/k-orc/openstack-resource-controller/internal/osclients/mock ServiceClient //go:generate /usr/bin/env bash -c "cat ../../../hack/boilerplate.go.txt service.go > _service.go && mv _service.go service.go" +//go:generate mockgen -package mock -destination=share.go -source=../share.go github.com/k-orc/openstack-resource-controller/internal/osclients/mock ShareClient +//go:generate /usr/bin/env bash -c "cat ../../../hack/boilerplate.go.txt share.go > _share.go && mv _share.go share.go" + //go:generate mockgen -package mock -destination=volume.go -source=../volume.go github.com/k-orc/openstack-resource-controller/internal/osclients/mock VolumeClient //go:generate /usr/bin/env bash -c "cat ../../../hack/boilerplate.go.txt volume.go > _volume.go && mv _volume.go volume.go" diff --git a/internal/osclients/mock/share.go b/internal/osclients/mock/share.go new file mode 100644 index 000000000..756d39919 --- /dev/null +++ b/internal/osclients/mock/share.go @@ -0,0 +1,131 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by MockGen. DO NOT EDIT. +// Source: ../share.go +// +// Generated by this command: +// +// mockgen -package mock -destination=share.go -source=../share.go github.com/k-orc/openstack-resource-controller/internal/osclients/mock ShareClient +// + +// Package mock is a generated GoMock package. +package mock + +import ( + context "context" + iter "iter" + reflect "reflect" + + shares "github.com/gophercloud/gophercloud/v2/openstack/sharedfilesystems/v2/shares" + gomock "go.uber.org/mock/gomock" +) + +// MockShareClient is a mock of ShareClient interface. +type MockShareClient struct { + ctrl *gomock.Controller + recorder *MockShareClientMockRecorder + isgomock struct{} +} + +// MockShareClientMockRecorder is the mock recorder for MockShareClient. +type MockShareClientMockRecorder struct { + mock *MockShareClient +} + +// NewMockShareClient creates a new mock instance. +func NewMockShareClient(ctrl *gomock.Controller) *MockShareClient { + mock := &MockShareClient{ctrl: ctrl} + mock.recorder = &MockShareClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockShareClient) EXPECT() *MockShareClientMockRecorder { + return m.recorder +} + +// CreateShare mocks base method. +func (m *MockShareClient) CreateShare(ctx context.Context, opts shares.CreateOptsBuilder) (*shares.Share, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateShare", ctx, opts) + ret0, _ := ret[0].(*shares.Share) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateShare indicates an expected call of CreateShare. +func (mr *MockShareClientMockRecorder) CreateShare(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateShare", reflect.TypeOf((*MockShareClient)(nil).CreateShare), ctx, opts) +} + +// DeleteShare mocks base method. +func (m *MockShareClient) DeleteShare(ctx context.Context, resourceID string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteShare", ctx, resourceID) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteShare indicates an expected call of DeleteShare. +func (mr *MockShareClientMockRecorder) DeleteShare(ctx, resourceID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteShare", reflect.TypeOf((*MockShareClient)(nil).DeleteShare), ctx, resourceID) +} + +// GetShare mocks base method. +func (m *MockShareClient) GetShare(ctx context.Context, resourceID string) (*shares.Share, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetShare", ctx, resourceID) + ret0, _ := ret[0].(*shares.Share) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetShare indicates an expected call of GetShare. +func (mr *MockShareClientMockRecorder) GetShare(ctx, resourceID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetShare", reflect.TypeOf((*MockShareClient)(nil).GetShare), ctx, resourceID) +} + +// ListShares mocks base method. +func (m *MockShareClient) ListShares(ctx context.Context, listOpts shares.ListOptsBuilder) iter.Seq2[*shares.Share, error] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListShares", ctx, listOpts) + ret0, _ := ret[0].(iter.Seq2[*shares.Share, error]) + return ret0 +} + +// ListShares indicates an expected call of ListShares. +func (mr *MockShareClientMockRecorder) ListShares(ctx, listOpts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListShares", reflect.TypeOf((*MockShareClient)(nil).ListShares), ctx, listOpts) +} + +// UpdateShare mocks base method. +func (m *MockShareClient) UpdateShare(ctx context.Context, id string, opts shares.UpdateOptsBuilder) (*shares.Share, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateShare", ctx, id, opts) + ret0, _ := ret[0].(*shares.Share) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateShare indicates an expected call of UpdateShare. +func (mr *MockShareClientMockRecorder) UpdateShare(ctx, id, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateShare", reflect.TypeOf((*MockShareClient)(nil).UpdateShare), ctx, id, opts) +} diff --git a/internal/osclients/share.go b/internal/osclients/share.go new file mode 100644 index 000000000..cf7428457 --- /dev/null +++ b/internal/osclients/share.go @@ -0,0 +1,104 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package osclients + +import ( + "context" + "fmt" + "iter" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack" + "github.com/gophercloud/gophercloud/v2/openstack/sharedfilesystems/v2/shares" + "github.com/gophercloud/utils/v2/openstack/clientconfig" +) + +type ShareClient interface { + ListShares(ctx context.Context, listOpts shares.ListOptsBuilder) iter.Seq2[*shares.Share, error] + CreateShare(ctx context.Context, opts shares.CreateOptsBuilder) (*shares.Share, error) + DeleteShare(ctx context.Context, resourceID string) error + GetShare(ctx context.Context, resourceID string) (*shares.Share, error) + UpdateShare(ctx context.Context, id string, opts shares.UpdateOptsBuilder) (*shares.Share, error) +} + +type shareClient struct{ client *gophercloud.ServiceClient } + +// NewShareClient returns a new OpenStack client. +func NewShareClient(providerClient *gophercloud.ProviderClient, providerClientOpts *clientconfig.ClientOpts) (ShareClient, error) { + client, err := openstack.NewSharedFileSystemV2(providerClient, gophercloud.EndpointOpts{ + Region: providerClientOpts.RegionName, + Availability: clientconfig.GetEndpointType(providerClientOpts.EndpointType), + }) + + if err != nil { + return nil, fmt.Errorf("failed to create share service client: %v", err) + } + + return &shareClient{client}, nil +} + +func (c shareClient) ListShares(ctx context.Context, listOpts shares.ListOptsBuilder) iter.Seq2[*shares.Share, error] { + pager := shares.ListDetail(c.client, listOpts) + return func(yield func(*shares.Share, error) bool) { + _ = pager.EachPage(ctx, yieldPage(shares.ExtractShares, yield)) + } +} + +func (c shareClient) CreateShare(ctx context.Context, opts shares.CreateOptsBuilder) (*shares.Share, error) { + return shares.Create(ctx, c.client, opts).Extract() +} + +func (c shareClient) DeleteShare(ctx context.Context, resourceID string) error { + return shares.Delete(ctx, c.client, resourceID).ExtractErr() +} + +func (c shareClient) GetShare(ctx context.Context, resourceID string) (*shares.Share, error) { + return shares.Get(ctx, c.client, resourceID).Extract() +} + +func (c shareClient) UpdateShare(ctx context.Context, id string, opts shares.UpdateOptsBuilder) (*shares.Share, error) { + return shares.Update(ctx, c.client, id, opts).Extract() +} + +type shareErrorClient struct{ error } + +// NewShareErrorClient returns a ShareClient in which every method returns the given error. +func NewShareErrorClient(e error) ShareClient { + return shareErrorClient{e} +} + +func (e shareErrorClient) ListShares(_ context.Context, _ shares.ListOptsBuilder) iter.Seq2[*shares.Share, error] { + return func(yield func(*shares.Share, error) bool) { + yield(nil, e.error) + } +} + +func (e shareErrorClient) CreateShare(_ context.Context, _ shares.CreateOptsBuilder) (*shares.Share, error) { + return nil, e.error +} + +func (e shareErrorClient) DeleteShare(_ context.Context, _ string) error { + return e.error +} + +func (e shareErrorClient) GetShare(_ context.Context, _ string) (*shares.Share, error) { + return nil, e.error +} + +func (e shareErrorClient) UpdateShare(_ context.Context, _ string, _ shares.UpdateOptsBuilder) (*shares.Share, error) { + return nil, e.error +} diff --git a/internal/scope/mock.go b/internal/scope/mock.go index 9cc49cd03..7a5093b61 100644 --- a/internal/scope/mock.go +++ b/internal/scope/mock.go @@ -44,6 +44,7 @@ type MockScopeFactory struct { NetworkClient *mock.MockNetworkClient RoleClient *mock.MockRoleClient ServiceClient *mock.MockServiceClient + ShareClient *mock.MockShareClient VolumeClient *mock.MockVolumeClient VolumeTypeClient *mock.MockVolumeTypeClient @@ -61,6 +62,7 @@ func NewMockScopeFactory(mockCtrl *gomock.Controller) *MockScopeFactory { networkClient := mock.NewMockNetworkClient(mockCtrl) roleClient := mock.NewMockRoleClient(mockCtrl) serviceClient := mock.NewMockServiceClient(mockCtrl) + shareClient := mock.NewMockShareClient(mockCtrl) volumeClient := mock.NewMockVolumeClient(mockCtrl) volumetypeClient := mock.NewMockVolumeTypeClient(mockCtrl) @@ -75,6 +77,7 @@ func NewMockScopeFactory(mockCtrl *gomock.Controller) *MockScopeFactory { NetworkClient: networkClient, RoleClient: roleClient, ServiceClient: serviceClient, + ShareClient: shareClient, VolumeClient: volumeClient, VolumeTypeClient: volumetypeClient, } @@ -123,6 +126,10 @@ func (f *MockScopeFactory) NewServiceClient() (osclients.ServiceClient, error) { return f.ServiceClient, nil } +func (f *MockScopeFactory) NewShareClient() (osclients.ShareClient, error) { + return f.ShareClient, nil +} + func (f *MockScopeFactory) NewKeyPairClient() (osclients.KeyPairClient, error) { return f.KeyPairClient, nil } diff --git a/internal/scope/provider.go b/internal/scope/provider.go index d9853e381..c8f16c5e3 100644 --- a/internal/scope/provider.go +++ b/internal/scope/provider.go @@ -169,6 +169,10 @@ func (s *providerScope) NewServiceClient() (clients.ServiceClient, error) { return clients.NewServiceClient(s.providerClient, s.providerClientOpts) } +func (s *providerScope) NewShareClient() (clients.ShareClient, error) { + return clients.NewShareClient(s.providerClient, s.providerClientOpts) +} + func (s *providerScope) NewEndpointClient() (clients.EndpointClient, error) { return clients.NewEndpointClient(s.providerClient, s.providerClientOpts) } diff --git a/internal/scope/scope.go b/internal/scope/scope.go index 8baa7f404..acb833887 100644 --- a/internal/scope/scope.go +++ b/internal/scope/scope.go @@ -58,6 +58,7 @@ type Scope interface { NewNetworkClient() (osclients.NetworkClient, error) NewRoleClient() (osclients.RoleClient, error) NewServiceClient() (osclients.ServiceClient, error) + NewShareClient() (osclients.ShareClient, error) NewVolumeClient() (osclients.VolumeClient, error) NewVolumeTypeClient() (osclients.VolumeTypeClient, error) ExtractToken() (*tokens.Token, error) diff --git a/kuttl-test.yaml b/kuttl-test.yaml index 10cedb065..bf87a183c 100644 --- a/kuttl-test.yaml +++ b/kuttl-test.yaml @@ -19,8 +19,9 @@ testDirs: - ./internal/controllers/server/tests/ - ./internal/controllers/servergroup/tests/ - ./internal/controllers/service/tests/ +- ./internal/controllers/share/tests/ - ./internal/controllers/subnet/tests/ - ./internal/controllers/trunk/tests/ - ./internal/controllers/volume/tests/ - ./internal/controllers/volumetype/tests/ -timeout: 240 +timeout: 60 diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/share.go b/pkg/clients/applyconfiguration/api/v1alpha1/share.go new file mode 100644 index 000000000..06af5d9eb --- /dev/null +++ b/pkg/clients/applyconfiguration/api/v1alpha1/share.go @@ -0,0 +1,281 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1" + internal "github.com/k-orc/openstack-resource-controller/v2/pkg/clients/applyconfiguration/internal" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// ShareApplyConfiguration represents a declarative configuration of the Share type for use +// with apply. +type ShareApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *ShareSpecApplyConfiguration `json:"spec,omitempty"` + Status *ShareStatusApplyConfiguration `json:"status,omitempty"` +} + +// Share constructs a declarative configuration of the Share type for use with +// apply. +func Share(name, namespace string) *ShareApplyConfiguration { + b := &ShareApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Share") + b.WithAPIVersion("openstack.k-orc.cloud/v1alpha1") + return b +} + +// ExtractShare extracts the applied configuration owned by fieldManager from +// share. If no managedFields are found in share for fieldManager, a +// ShareApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// share must be a unmodified Share API object that was retrieved from the Kubernetes API. +// ExtractShare provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractShare(share *apiv1alpha1.Share, fieldManager string) (*ShareApplyConfiguration, error) { + return extractShare(share, fieldManager, "") +} + +// ExtractShareStatus is the same as ExtractShare except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractShareStatus(share *apiv1alpha1.Share, fieldManager string) (*ShareApplyConfiguration, error) { + return extractShare(share, fieldManager, "status") +} + +func extractShare(share *apiv1alpha1.Share, fieldManager string, subresource string) (*ShareApplyConfiguration, error) { + b := &ShareApplyConfiguration{} + err := managedfields.ExtractInto(share, internal.Parser().Type("com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.Share"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(share.Name) + b.WithNamespace(share.Namespace) + + b.WithKind("Share") + b.WithAPIVersion("openstack.k-orc.cloud/v1alpha1") + return b, nil +} +func (b ShareApplyConfiguration) IsApplyConfiguration() {} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithKind(value string) *ShareApplyConfiguration { + b.TypeMetaApplyConfiguration.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithAPIVersion(value string) *ShareApplyConfiguration { + b.TypeMetaApplyConfiguration.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithName(value string) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithGenerateName(value string) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithNamespace(value string) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithUID(value types.UID) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithResourceVersion(value string) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithGeneration(value int64) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *ShareApplyConfiguration) WithLabels(entries map[string]string) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.ObjectMetaApplyConfiguration.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *ShareApplyConfiguration) WithAnnotations(entries map[string]string) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.ObjectMetaApplyConfiguration.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *ShareApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *ShareApplyConfiguration) WithFinalizers(values ...string) *ShareApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) + } + return b +} + +func (b *ShareApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithSpec(value *ShareSpecApplyConfiguration) *ShareApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *ShareApplyConfiguration) WithStatus(value *ShareStatusApplyConfiguration) *ShareApplyConfiguration { + b.Status = value + return b +} + +// GetKind retrieves the value of the Kind field in the declarative configuration. +func (b *ShareApplyConfiguration) GetKind() *string { + return b.TypeMetaApplyConfiguration.Kind +} + +// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration. +func (b *ShareApplyConfiguration) GetAPIVersion() *string { + return b.TypeMetaApplyConfiguration.APIVersion +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *ShareApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} + +// GetNamespace retrieves the value of the Namespace field in the declarative configuration. +func (b *ShareApplyConfiguration) GetNamespace() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Namespace +} diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/shareexportlocation.go b/pkg/clients/applyconfiguration/api/v1alpha1/shareexportlocation.go new file mode 100644 index 000000000..be2f53e8c --- /dev/null +++ b/pkg/clients/applyconfiguration/api/v1alpha1/shareexportlocation.go @@ -0,0 +1,48 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// ShareExportLocationApplyConfiguration represents a declarative configuration of the ShareExportLocation type for use +// with apply. +type ShareExportLocationApplyConfiguration struct { + Path *string `json:"path,omitempty"` + Preferred *bool `json:"preferred,omitempty"` +} + +// ShareExportLocationApplyConfiguration constructs a declarative configuration of the ShareExportLocation type for use with +// apply. +func ShareExportLocation() *ShareExportLocationApplyConfiguration { + return &ShareExportLocationApplyConfiguration{} +} + +// WithPath sets the Path field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Path field is set to the value of the last call. +func (b *ShareExportLocationApplyConfiguration) WithPath(value string) *ShareExportLocationApplyConfiguration { + b.Path = &value + return b +} + +// WithPreferred sets the Preferred field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Preferred field is set to the value of the last call. +func (b *ShareExportLocationApplyConfiguration) WithPreferred(value bool) *ShareExportLocationApplyConfiguration { + b.Preferred = &value + return b +} diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/sharefilter.go b/pkg/clients/applyconfiguration/api/v1alpha1/sharefilter.go new file mode 100644 index 000000000..532d16dc1 --- /dev/null +++ b/pkg/clients/applyconfiguration/api/v1alpha1/sharefilter.go @@ -0,0 +1,79 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1" +) + +// ShareFilterApplyConfiguration represents a declarative configuration of the ShareFilter type for use +// with apply. +type ShareFilterApplyConfiguration struct { + Name *apiv1alpha1.OpenStackName `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + ShareProto *string `json:"shareProto,omitempty"` + Status *string `json:"status,omitempty"` + IsPublic *bool `json:"isPublic,omitempty"` +} + +// ShareFilterApplyConfiguration constructs a declarative configuration of the ShareFilter type for use with +// apply. +func ShareFilter() *ShareFilterApplyConfiguration { + return &ShareFilterApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *ShareFilterApplyConfiguration) WithName(value apiv1alpha1.OpenStackName) *ShareFilterApplyConfiguration { + b.Name = &value + return b +} + +// WithDescription sets the Description field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Description field is set to the value of the last call. +func (b *ShareFilterApplyConfiguration) WithDescription(value string) *ShareFilterApplyConfiguration { + b.Description = &value + return b +} + +// WithShareProto sets the ShareProto field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ShareProto field is set to the value of the last call. +func (b *ShareFilterApplyConfiguration) WithShareProto(value string) *ShareFilterApplyConfiguration { + b.ShareProto = &value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *ShareFilterApplyConfiguration) WithStatus(value string) *ShareFilterApplyConfiguration { + b.Status = &value + return b +} + +// WithIsPublic sets the IsPublic field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IsPublic field is set to the value of the last call. +func (b *ShareFilterApplyConfiguration) WithIsPublic(value bool) *ShareFilterApplyConfiguration { + b.IsPublic = &value + return b +} diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/shareimport.go b/pkg/clients/applyconfiguration/api/v1alpha1/shareimport.go new file mode 100644 index 000000000..c7552627d --- /dev/null +++ b/pkg/clients/applyconfiguration/api/v1alpha1/shareimport.go @@ -0,0 +1,48 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// ShareImportApplyConfiguration represents a declarative configuration of the ShareImport type for use +// with apply. +type ShareImportApplyConfiguration struct { + ID *string `json:"id,omitempty"` + Filter *ShareFilterApplyConfiguration `json:"filter,omitempty"` +} + +// ShareImportApplyConfiguration constructs a declarative configuration of the ShareImport type for use with +// apply. +func ShareImport() *ShareImportApplyConfiguration { + return &ShareImportApplyConfiguration{} +} + +// WithID sets the ID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ID field is set to the value of the last call. +func (b *ShareImportApplyConfiguration) WithID(value string) *ShareImportApplyConfiguration { + b.ID = &value + return b +} + +// WithFilter sets the Filter field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Filter field is set to the value of the last call. +func (b *ShareImportApplyConfiguration) WithFilter(value *ShareFilterApplyConfiguration) *ShareImportApplyConfiguration { + b.Filter = value + return b +} diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/sharemetadata.go b/pkg/clients/applyconfiguration/api/v1alpha1/sharemetadata.go new file mode 100644 index 000000000..71a72d244 --- /dev/null +++ b/pkg/clients/applyconfiguration/api/v1alpha1/sharemetadata.go @@ -0,0 +1,48 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// ShareMetadataApplyConfiguration represents a declarative configuration of the ShareMetadata type for use +// with apply. +type ShareMetadataApplyConfiguration struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +// ShareMetadataApplyConfiguration constructs a declarative configuration of the ShareMetadata type for use with +// apply. +func ShareMetadata() *ShareMetadataApplyConfiguration { + return &ShareMetadataApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *ShareMetadataApplyConfiguration) WithName(value string) *ShareMetadataApplyConfiguration { + b.Name = &value + return b +} + +// WithValue sets the Value field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Value field is set to the value of the last call. +func (b *ShareMetadataApplyConfiguration) WithValue(value string) *ShareMetadataApplyConfiguration { + b.Value = &value + return b +} diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/sharemetadatastatus.go b/pkg/clients/applyconfiguration/api/v1alpha1/sharemetadatastatus.go new file mode 100644 index 000000000..80860cf30 --- /dev/null +++ b/pkg/clients/applyconfiguration/api/v1alpha1/sharemetadatastatus.go @@ -0,0 +1,48 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// ShareMetadataStatusApplyConfiguration represents a declarative configuration of the ShareMetadataStatus type for use +// with apply. +type ShareMetadataStatusApplyConfiguration struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +// ShareMetadataStatusApplyConfiguration constructs a declarative configuration of the ShareMetadataStatus type for use with +// apply. +func ShareMetadataStatus() *ShareMetadataStatusApplyConfiguration { + return &ShareMetadataStatusApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *ShareMetadataStatusApplyConfiguration) WithName(value string) *ShareMetadataStatusApplyConfiguration { + b.Name = &value + return b +} + +// WithValue sets the Value field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Value field is set to the value of the last call. +func (b *ShareMetadataStatusApplyConfiguration) WithValue(value string) *ShareMetadataStatusApplyConfiguration { + b.Value = &value + return b +} diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/shareresourcespec.go b/pkg/clients/applyconfiguration/api/v1alpha1/shareresourcespec.go new file mode 100644 index 000000000..a5e945e83 --- /dev/null +++ b/pkg/clients/applyconfiguration/api/v1alpha1/shareresourcespec.go @@ -0,0 +1,102 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1" +) + +// ShareResourceSpecApplyConfiguration represents a declarative configuration of the ShareResourceSpec type for use +// with apply. +type ShareResourceSpecApplyConfiguration struct { + Name *apiv1alpha1.OpenStackName `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + Size *int32 `json:"size,omitempty"` + ShareProto *string `json:"shareProto,omitempty"` + AvailabilityZone *string `json:"availabilityZone,omitempty"` + Metadata []ShareMetadataApplyConfiguration `json:"metadata,omitempty"` + IsPublic *bool `json:"isPublic,omitempty"` +} + +// ShareResourceSpecApplyConfiguration constructs a declarative configuration of the ShareResourceSpec type for use with +// apply. +func ShareResourceSpec() *ShareResourceSpecApplyConfiguration { + return &ShareResourceSpecApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *ShareResourceSpecApplyConfiguration) WithName(value apiv1alpha1.OpenStackName) *ShareResourceSpecApplyConfiguration { + b.Name = &value + return b +} + +// WithDescription sets the Description field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Description field is set to the value of the last call. +func (b *ShareResourceSpecApplyConfiguration) WithDescription(value string) *ShareResourceSpecApplyConfiguration { + b.Description = &value + return b +} + +// WithSize sets the Size field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Size field is set to the value of the last call. +func (b *ShareResourceSpecApplyConfiguration) WithSize(value int32) *ShareResourceSpecApplyConfiguration { + b.Size = &value + return b +} + +// WithShareProto sets the ShareProto field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ShareProto field is set to the value of the last call. +func (b *ShareResourceSpecApplyConfiguration) WithShareProto(value string) *ShareResourceSpecApplyConfiguration { + b.ShareProto = &value + return b +} + +// WithAvailabilityZone sets the AvailabilityZone field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AvailabilityZone field is set to the value of the last call. +func (b *ShareResourceSpecApplyConfiguration) WithAvailabilityZone(value string) *ShareResourceSpecApplyConfiguration { + b.AvailabilityZone = &value + return b +} + +// WithMetadata adds the given value to the Metadata field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Metadata field. +func (b *ShareResourceSpecApplyConfiguration) WithMetadata(values ...*ShareMetadataApplyConfiguration) *ShareResourceSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithMetadata") + } + b.Metadata = append(b.Metadata, *values[i]) + } + return b +} + +// WithIsPublic sets the IsPublic field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IsPublic field is set to the value of the last call. +func (b *ShareResourceSpecApplyConfiguration) WithIsPublic(value bool) *ShareResourceSpecApplyConfiguration { + b.IsPublic = &value + return b +} diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/shareresourcestatus.go b/pkg/clients/applyconfiguration/api/v1alpha1/shareresourcestatus.go new file mode 100644 index 000000000..1c117771a --- /dev/null +++ b/pkg/clients/applyconfiguration/api/v1alpha1/shareresourcestatus.go @@ -0,0 +1,143 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ShareResourceStatusApplyConfiguration represents a declarative configuration of the ShareResourceStatus type for use +// with apply. +type ShareResourceStatusApplyConfiguration struct { + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + Size *int32 `json:"size,omitempty"` + ShareProto *string `json:"shareProto,omitempty"` + Status *string `json:"status,omitempty"` + AvailabilityZone *string `json:"availabilityZone,omitempty"` + ExportLocations []ShareExportLocationApplyConfiguration `json:"exportLocations,omitempty"` + Metadata []ShareMetadataStatusApplyConfiguration `json:"metadata,omitempty"` + IsPublic *bool `json:"isPublic,omitempty"` + CreatedAt *v1.Time `json:"createdAt,omitempty"` + ProjectID *string `json:"projectID,omitempty"` +} + +// ShareResourceStatusApplyConfiguration constructs a declarative configuration of the ShareResourceStatus type for use with +// apply. +func ShareResourceStatus() *ShareResourceStatusApplyConfiguration { + return &ShareResourceStatusApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *ShareResourceStatusApplyConfiguration) WithName(value string) *ShareResourceStatusApplyConfiguration { + b.Name = &value + return b +} + +// WithDescription sets the Description field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Description field is set to the value of the last call. +func (b *ShareResourceStatusApplyConfiguration) WithDescription(value string) *ShareResourceStatusApplyConfiguration { + b.Description = &value + return b +} + +// WithSize sets the Size field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Size field is set to the value of the last call. +func (b *ShareResourceStatusApplyConfiguration) WithSize(value int32) *ShareResourceStatusApplyConfiguration { + b.Size = &value + return b +} + +// WithShareProto sets the ShareProto field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ShareProto field is set to the value of the last call. +func (b *ShareResourceStatusApplyConfiguration) WithShareProto(value string) *ShareResourceStatusApplyConfiguration { + b.ShareProto = &value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *ShareResourceStatusApplyConfiguration) WithStatus(value string) *ShareResourceStatusApplyConfiguration { + b.Status = &value + return b +} + +// WithAvailabilityZone sets the AvailabilityZone field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AvailabilityZone field is set to the value of the last call. +func (b *ShareResourceStatusApplyConfiguration) WithAvailabilityZone(value string) *ShareResourceStatusApplyConfiguration { + b.AvailabilityZone = &value + return b +} + +// WithExportLocations adds the given value to the ExportLocations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the ExportLocations field. +func (b *ShareResourceStatusApplyConfiguration) WithExportLocations(values ...*ShareExportLocationApplyConfiguration) *ShareResourceStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithExportLocations") + } + b.ExportLocations = append(b.ExportLocations, *values[i]) + } + return b +} + +// WithMetadata adds the given value to the Metadata field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Metadata field. +func (b *ShareResourceStatusApplyConfiguration) WithMetadata(values ...*ShareMetadataStatusApplyConfiguration) *ShareResourceStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithMetadata") + } + b.Metadata = append(b.Metadata, *values[i]) + } + return b +} + +// WithIsPublic sets the IsPublic field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IsPublic field is set to the value of the last call. +func (b *ShareResourceStatusApplyConfiguration) WithIsPublic(value bool) *ShareResourceStatusApplyConfiguration { + b.IsPublic = &value + return b +} + +// WithCreatedAt sets the CreatedAt field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreatedAt field is set to the value of the last call. +func (b *ShareResourceStatusApplyConfiguration) WithCreatedAt(value v1.Time) *ShareResourceStatusApplyConfiguration { + b.CreatedAt = &value + return b +} + +// WithProjectID sets the ProjectID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ProjectID field is set to the value of the last call. +func (b *ShareResourceStatusApplyConfiguration) WithProjectID(value string) *ShareResourceStatusApplyConfiguration { + b.ProjectID = &value + return b +} diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/sharespec.go b/pkg/clients/applyconfiguration/api/v1alpha1/sharespec.go new file mode 100644 index 000000000..7c471af78 --- /dev/null +++ b/pkg/clients/applyconfiguration/api/v1alpha1/sharespec.go @@ -0,0 +1,79 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1" +) + +// ShareSpecApplyConfiguration represents a declarative configuration of the ShareSpec type for use +// with apply. +type ShareSpecApplyConfiguration struct { + Import *ShareImportApplyConfiguration `json:"import,omitempty"` + Resource *ShareResourceSpecApplyConfiguration `json:"resource,omitempty"` + ManagementPolicy *apiv1alpha1.ManagementPolicy `json:"managementPolicy,omitempty"` + ManagedOptions *ManagedOptionsApplyConfiguration `json:"managedOptions,omitempty"` + CloudCredentialsRef *CloudCredentialsReferenceApplyConfiguration `json:"cloudCredentialsRef,omitempty"` +} + +// ShareSpecApplyConfiguration constructs a declarative configuration of the ShareSpec type for use with +// apply. +func ShareSpec() *ShareSpecApplyConfiguration { + return &ShareSpecApplyConfiguration{} +} + +// WithImport sets the Import field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Import field is set to the value of the last call. +func (b *ShareSpecApplyConfiguration) WithImport(value *ShareImportApplyConfiguration) *ShareSpecApplyConfiguration { + b.Import = value + return b +} + +// WithResource sets the Resource field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Resource field is set to the value of the last call. +func (b *ShareSpecApplyConfiguration) WithResource(value *ShareResourceSpecApplyConfiguration) *ShareSpecApplyConfiguration { + b.Resource = value + return b +} + +// WithManagementPolicy sets the ManagementPolicy field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ManagementPolicy field is set to the value of the last call. +func (b *ShareSpecApplyConfiguration) WithManagementPolicy(value apiv1alpha1.ManagementPolicy) *ShareSpecApplyConfiguration { + b.ManagementPolicy = &value + return b +} + +// WithManagedOptions sets the ManagedOptions field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ManagedOptions field is set to the value of the last call. +func (b *ShareSpecApplyConfiguration) WithManagedOptions(value *ManagedOptionsApplyConfiguration) *ShareSpecApplyConfiguration { + b.ManagedOptions = value + return b +} + +// WithCloudCredentialsRef sets the CloudCredentialsRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CloudCredentialsRef field is set to the value of the last call. +func (b *ShareSpecApplyConfiguration) WithCloudCredentialsRef(value *CloudCredentialsReferenceApplyConfiguration) *ShareSpecApplyConfiguration { + b.CloudCredentialsRef = value + return b +} diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/sharestatus.go b/pkg/clients/applyconfiguration/api/v1alpha1/sharestatus.go new file mode 100644 index 000000000..638a60902 --- /dev/null +++ b/pkg/clients/applyconfiguration/api/v1alpha1/sharestatus.go @@ -0,0 +1,66 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// ShareStatusApplyConfiguration represents a declarative configuration of the ShareStatus type for use +// with apply. +type ShareStatusApplyConfiguration struct { + Conditions []v1.ConditionApplyConfiguration `json:"conditions,omitempty"` + ID *string `json:"id,omitempty"` + Resource *ShareResourceStatusApplyConfiguration `json:"resource,omitempty"` +} + +// ShareStatusApplyConfiguration constructs a declarative configuration of the ShareStatus type for use with +// apply. +func ShareStatus() *ShareStatusApplyConfiguration { + return &ShareStatusApplyConfiguration{} +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *ShareStatusApplyConfiguration) WithConditions(values ...*v1.ConditionApplyConfiguration) *ShareStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.Conditions = append(b.Conditions, *values[i]) + } + return b +} + +// WithID sets the ID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ID field is set to the value of the last call. +func (b *ShareStatusApplyConfiguration) WithID(value string) *ShareStatusApplyConfiguration { + b.ID = &value + return b +} + +// WithResource sets the Resource field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Resource field is set to the value of the last call. +func (b *ShareStatusApplyConfiguration) WithResource(value *ShareResourceStatusApplyConfiguration) *ShareStatusApplyConfiguration { + b.Resource = value + return b +} diff --git a/pkg/clients/applyconfiguration/internal/internal.go b/pkg/clients/applyconfiguration/internal/internal.go index 87e4f6e86..91f074629 100644 --- a/pkg/clients/applyconfiguration/internal/internal.go +++ b/pkg/clients/applyconfiguration/internal/internal.go @@ -2767,6 +2767,188 @@ var schemaYAML = typed.YAMLObject(`types: - name: resource type: namedType: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ServiceResourceStatus +- name: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.Share + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareSpec + default: {} + - name: status + type: + namedType: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareStatus + default: {} +- name: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareExportLocation + map: + fields: + - name: path + type: + scalar: string + - name: preferred + type: + scalar: boolean +- name: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareFilter + map: + fields: + - name: description + type: + scalar: string + - name: isPublic + type: + scalar: boolean + - name: name + type: + scalar: string + - name: shareProto + type: + scalar: string + - name: status + type: + scalar: string +- name: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareImport + map: + fields: + - name: filter + type: + namedType: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareFilter + - name: id + type: + scalar: string +- name: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareMetadata + map: + fields: + - name: name + type: + scalar: string + default: "" + - name: value + type: + scalar: string + default: "" +- name: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareMetadataStatus + map: + fields: + - name: name + type: + scalar: string + - name: value + type: + scalar: string +- name: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareResourceSpec + map: + fields: + - name: availabilityZone + type: + scalar: string + - name: description + type: + scalar: string + - name: isPublic + type: + scalar: boolean + - name: metadata + type: + list: + elementType: + namedType: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareMetadata + elementRelationship: atomic + - name: name + type: + scalar: string + - name: shareProto + type: + scalar: string + - name: size + type: + scalar: numeric +- name: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareResourceStatus + map: + fields: + - name: availabilityZone + type: + scalar: string + - name: createdAt + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: description + type: + scalar: string + - name: exportLocations + type: + list: + elementType: + namedType: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareExportLocation + elementRelationship: atomic + - name: isPublic + type: + scalar: boolean + - name: metadata + type: + list: + elementType: + namedType: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareMetadataStatus + elementRelationship: atomic + - name: name + type: + scalar: string + - name: projectID + type: + scalar: string + - name: shareProto + type: + scalar: string + - name: size + type: + scalar: numeric + - name: status + type: + scalar: string +- name: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareSpec + map: + fields: + - name: cloudCredentialsRef + type: + namedType: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.CloudCredentialsReference + default: {} + - name: import + type: + namedType: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareImport + - name: managedOptions + type: + namedType: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ManagedOptions + - name: managementPolicy + type: + scalar: string + - name: resource + type: + namedType: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareResourceSpec +- name: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareStatus + map: + fields: + - name: conditions + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Condition + elementRelationship: associative + keys: + - type + - name: id + type: + scalar: string + - name: resource + type: + namedType: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.ShareResourceStatus - name: com.github.k-orc.openstack-resource-controller.v2.api.v1alpha1.Subnet map: fields: diff --git a/pkg/clients/applyconfiguration/utils.go b/pkg/clients/applyconfiguration/utils.go index 1b58223cf..432860ac9 100644 --- a/pkg/clients/applyconfiguration/utils.go +++ b/pkg/clients/applyconfiguration/utils.go @@ -340,6 +340,26 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &apiv1alpha1.ServiceSpecApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("ServiceStatus"): return &apiv1alpha1.ServiceStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Share"): + return &apiv1alpha1.ShareApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ShareExportLocation"): + return &apiv1alpha1.ShareExportLocationApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ShareFilter"): + return &apiv1alpha1.ShareFilterApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ShareImport"): + return &apiv1alpha1.ShareImportApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ShareMetadata"): + return &apiv1alpha1.ShareMetadataApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ShareMetadataStatus"): + return &apiv1alpha1.ShareMetadataStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ShareResourceSpec"): + return &apiv1alpha1.ShareResourceSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ShareResourceStatus"): + return &apiv1alpha1.ShareResourceStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ShareSpec"): + return &apiv1alpha1.ShareSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ShareStatus"): + return &apiv1alpha1.ShareStatusApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("Subnet"): return &apiv1alpha1.SubnetApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("SubnetFilter"): diff --git a/pkg/clients/clientset/clientset/typed/api/v1alpha1/api_client.go b/pkg/clients/clientset/clientset/typed/api/v1alpha1/api_client.go index 7c2e4e67d..f9f0cf12c 100644 --- a/pkg/clients/clientset/clientset/typed/api/v1alpha1/api_client.go +++ b/pkg/clients/clientset/clientset/typed/api/v1alpha1/api_client.go @@ -45,6 +45,7 @@ type OpenstackV1alpha1Interface interface { ServersGetter ServerGroupsGetter ServicesGetter + SharesGetter SubnetsGetter TrunksGetter VolumesGetter @@ -124,6 +125,10 @@ func (c *OpenstackV1alpha1Client) Services(namespace string) ServiceInterface { return newServices(c, namespace) } +func (c *OpenstackV1alpha1Client) Shares(namespace string) ShareInterface { + return newShares(c, namespace) +} + func (c *OpenstackV1alpha1Client) Subnets(namespace string) SubnetInterface { return newSubnets(c, namespace) } diff --git a/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_api_client.go b/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_api_client.go index 2b7ba89cc..c853b26a7 100644 --- a/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_api_client.go +++ b/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_api_client.go @@ -96,6 +96,10 @@ func (c *FakeOpenstackV1alpha1) Services(namespace string) v1alpha1.ServiceInter return newFakeServices(c, namespace) } +func (c *FakeOpenstackV1alpha1) Shares(namespace string) v1alpha1.ShareInterface { + return newFakeShares(c, namespace) +} + func (c *FakeOpenstackV1alpha1) Subnets(namespace string) v1alpha1.SubnetInterface { return newFakeSubnets(c, namespace) } diff --git a/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_share.go b/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_share.go new file mode 100644 index 000000000..ed44a326a --- /dev/null +++ b/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_share.go @@ -0,0 +1,49 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1" + apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/pkg/clients/applyconfiguration/api/v1alpha1" + typedapiv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/pkg/clients/clientset/clientset/typed/api/v1alpha1" + gentype "k8s.io/client-go/gentype" +) + +// fakeShares implements ShareInterface +type fakeShares struct { + *gentype.FakeClientWithListAndApply[*v1alpha1.Share, *v1alpha1.ShareList, *apiv1alpha1.ShareApplyConfiguration] + Fake *FakeOpenstackV1alpha1 +} + +func newFakeShares(fake *FakeOpenstackV1alpha1, namespace string) typedapiv1alpha1.ShareInterface { + return &fakeShares{ + gentype.NewFakeClientWithListAndApply[*v1alpha1.Share, *v1alpha1.ShareList, *apiv1alpha1.ShareApplyConfiguration]( + fake.Fake, + namespace, + v1alpha1.SchemeGroupVersion.WithResource("shares"), + v1alpha1.SchemeGroupVersion.WithKind("Share"), + func() *v1alpha1.Share { return &v1alpha1.Share{} }, + func() *v1alpha1.ShareList { return &v1alpha1.ShareList{} }, + func(dst, src *v1alpha1.ShareList) { dst.ListMeta = src.ListMeta }, + func(list *v1alpha1.ShareList) []*v1alpha1.Share { return gentype.ToPointerSlice(list.Items) }, + func(list *v1alpha1.ShareList, items []*v1alpha1.Share) { list.Items = gentype.FromPointerSlice(items) }, + ), + fake, + } +} diff --git a/pkg/clients/clientset/clientset/typed/api/v1alpha1/generated_expansion.go b/pkg/clients/clientset/clientset/typed/api/v1alpha1/generated_expansion.go index e34607a4b..3d87cddfd 100644 --- a/pkg/clients/clientset/clientset/typed/api/v1alpha1/generated_expansion.go +++ b/pkg/clients/clientset/clientset/typed/api/v1alpha1/generated_expansion.go @@ -52,6 +52,8 @@ type ServerGroupExpansion interface{} type ServiceExpansion interface{} +type ShareExpansion interface{} + type SubnetExpansion interface{} type TrunkExpansion interface{} diff --git a/pkg/clients/clientset/clientset/typed/api/v1alpha1/share.go b/pkg/clients/clientset/clientset/typed/api/v1alpha1/share.go new file mode 100644 index 000000000..e79cde3d9 --- /dev/null +++ b/pkg/clients/clientset/clientset/typed/api/v1alpha1/share.go @@ -0,0 +1,74 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + context "context" + + apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1" + applyconfigurationapiv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/pkg/clients/applyconfiguration/api/v1alpha1" + scheme "github.com/k-orc/openstack-resource-controller/v2/pkg/clients/clientset/clientset/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// SharesGetter has a method to return a ShareInterface. +// A group's client should implement this interface. +type SharesGetter interface { + Shares(namespace string) ShareInterface +} + +// ShareInterface has methods to work with Share resources. +type ShareInterface interface { + Create(ctx context.Context, share *apiv1alpha1.Share, opts v1.CreateOptions) (*apiv1alpha1.Share, error) + Update(ctx context.Context, share *apiv1alpha1.Share, opts v1.UpdateOptions) (*apiv1alpha1.Share, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, share *apiv1alpha1.Share, opts v1.UpdateOptions) (*apiv1alpha1.Share, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*apiv1alpha1.Share, error) + List(ctx context.Context, opts v1.ListOptions) (*apiv1alpha1.ShareList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *apiv1alpha1.Share, err error) + Apply(ctx context.Context, share *applyconfigurationapiv1alpha1.ShareApplyConfiguration, opts v1.ApplyOptions) (result *apiv1alpha1.Share, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, share *applyconfigurationapiv1alpha1.ShareApplyConfiguration, opts v1.ApplyOptions) (result *apiv1alpha1.Share, err error) + ShareExpansion +} + +// shares implements ShareInterface +type shares struct { + *gentype.ClientWithListAndApply[*apiv1alpha1.Share, *apiv1alpha1.ShareList, *applyconfigurationapiv1alpha1.ShareApplyConfiguration] +} + +// newShares returns a Shares +func newShares(c *OpenstackV1alpha1Client, namespace string) *shares { + return &shares{ + gentype.NewClientWithListAndApply[*apiv1alpha1.Share, *apiv1alpha1.ShareList, *applyconfigurationapiv1alpha1.ShareApplyConfiguration]( + "shares", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *apiv1alpha1.Share { return &apiv1alpha1.Share{} }, + func() *apiv1alpha1.ShareList { return &apiv1alpha1.ShareList{} }, + ), + } +} diff --git a/pkg/clients/informers/externalversions/api/v1alpha1/interface.go b/pkg/clients/informers/externalversions/api/v1alpha1/interface.go index c9f62ae9c..1e6d83378 100644 --- a/pkg/clients/informers/externalversions/api/v1alpha1/interface.go +++ b/pkg/clients/informers/externalversions/api/v1alpha1/interface.go @@ -58,6 +58,8 @@ type Interface interface { ServerGroups() ServerGroupInformer // Services returns a ServiceInformer. Services() ServiceInformer + // Shares returns a ShareInformer. + Shares() ShareInformer // Subnets returns a SubnetInformer. Subnets() SubnetInformer // Trunks returns a TrunkInformer. @@ -164,6 +166,11 @@ func (v *version) Services() ServiceInformer { return &serviceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// Shares returns a ShareInformer. +func (v *version) Shares() ShareInformer { + return &shareInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // Subnets returns a SubnetInformer. func (v *version) Subnets() SubnetInformer { return &subnetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/clients/informers/externalversions/api/v1alpha1/share.go b/pkg/clients/informers/externalversions/api/v1alpha1/share.go new file mode 100644 index 000000000..ad703d511 --- /dev/null +++ b/pkg/clients/informers/externalversions/api/v1alpha1/share.go @@ -0,0 +1,102 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + context "context" + time "time" + + v2apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1" + clientset "github.com/k-orc/openstack-resource-controller/v2/pkg/clients/clientset/clientset" + internalinterfaces "github.com/k-orc/openstack-resource-controller/v2/pkg/clients/informers/externalversions/internalinterfaces" + apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/pkg/clients/listers/api/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ShareInformer provides access to a shared informer and lister for +// Shares. +type ShareInformer interface { + Informer() cache.SharedIndexInformer + Lister() apiv1alpha1.ShareLister +} + +type shareInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewShareInformer constructs a new informer for Share type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewShareInformer(client clientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredShareInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredShareInformer constructs a new informer for Share type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredShareInformer(client clientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OpenstackV1alpha1().Shares(namespace).List(context.Background(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OpenstackV1alpha1().Shares(namespace).Watch(context.Background(), options) + }, + ListWithContextFunc: func(ctx context.Context, options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OpenstackV1alpha1().Shares(namespace).List(ctx, options) + }, + WatchFuncWithContext: func(ctx context.Context, options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OpenstackV1alpha1().Shares(namespace).Watch(ctx, options) + }, + }, + &v2apiv1alpha1.Share{}, + resyncPeriod, + indexers, + ) +} + +func (f *shareInformer) defaultInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredShareInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *shareInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&v2apiv1alpha1.Share{}, f.defaultInformer) +} + +func (f *shareInformer) Lister() apiv1alpha1.ShareLister { + return apiv1alpha1.NewShareLister(f.Informer().GetIndexer()) +} diff --git a/pkg/clients/informers/externalversions/generic.go b/pkg/clients/informers/externalversions/generic.go index a2cd276ae..8c2cb661a 100644 --- a/pkg/clients/informers/externalversions/generic.go +++ b/pkg/clients/informers/externalversions/generic.go @@ -87,6 +87,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Openstack().V1alpha1().ServerGroups().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("services"): return &genericInformer{resource: resource.GroupResource(), informer: f.Openstack().V1alpha1().Services().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("shares"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Openstack().V1alpha1().Shares().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("subnets"): return &genericInformer{resource: resource.GroupResource(), informer: f.Openstack().V1alpha1().Subnets().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("trunks"): diff --git a/pkg/clients/listers/api/v1alpha1/expansion_generated.go b/pkg/clients/listers/api/v1alpha1/expansion_generated.go index e2fc3b2d2..46fbd78e6 100644 --- a/pkg/clients/listers/api/v1alpha1/expansion_generated.go +++ b/pkg/clients/listers/api/v1alpha1/expansion_generated.go @@ -154,6 +154,14 @@ type ServiceListerExpansion interface{} // ServiceNamespaceLister. type ServiceNamespaceListerExpansion interface{} +// ShareListerExpansion allows custom methods to be added to +// ShareLister. +type ShareListerExpansion interface{} + +// ShareNamespaceListerExpansion allows custom methods to be added to +// ShareNamespaceLister. +type ShareNamespaceListerExpansion interface{} + // SubnetListerExpansion allows custom methods to be added to // SubnetLister. type SubnetListerExpansion interface{} diff --git a/pkg/clients/listers/api/v1alpha1/share.go b/pkg/clients/listers/api/v1alpha1/share.go new file mode 100644 index 000000000..53fe71da2 --- /dev/null +++ b/pkg/clients/listers/api/v1alpha1/share.go @@ -0,0 +1,70 @@ +/* +Copyright The ORC Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1" + labels "k8s.io/apimachinery/pkg/labels" + listers "k8s.io/client-go/listers" + cache "k8s.io/client-go/tools/cache" +) + +// ShareLister helps list Shares. +// All objects returned here must be treated as read-only. +type ShareLister interface { + // List lists all Shares in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*apiv1alpha1.Share, err error) + // Shares returns an object that can list and get Shares. + Shares(namespace string) ShareNamespaceLister + ShareListerExpansion +} + +// shareLister implements the ShareLister interface. +type shareLister struct { + listers.ResourceIndexer[*apiv1alpha1.Share] +} + +// NewShareLister returns a new ShareLister. +func NewShareLister(indexer cache.Indexer) ShareLister { + return &shareLister{listers.New[*apiv1alpha1.Share](indexer, apiv1alpha1.Resource("share"))} +} + +// Shares returns an object that can list and get Shares. +func (s *shareLister) Shares(namespace string) ShareNamespaceLister { + return shareNamespaceLister{listers.NewNamespaced[*apiv1alpha1.Share](s.ResourceIndexer, namespace)} +} + +// ShareNamespaceLister helps list and get Shares. +// All objects returned here must be treated as read-only. +type ShareNamespaceLister interface { + // List lists all Shares in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*apiv1alpha1.Share, err error) + // Get retrieves the Share from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*apiv1alpha1.Share, error) + ShareNamespaceListerExpansion +} + +// shareNamespaceLister implements the ShareNamespaceLister +// interface. +type shareNamespaceLister struct { + listers.ResourceIndexer[*apiv1alpha1.Share] +} diff --git a/website/docs/crd-reference.md b/website/docs/crd-reference.md index 18bf9bf9e..22b2f20d7 100644 --- a/website/docs/crd-reference.md +++ b/website/docs/crd-reference.md @@ -27,6 +27,7 @@ Package v1alpha1 contains API Schema definitions for the openstack v1alpha1 API - [Server](#server) - [ServerGroup](#servergroup) - [Service](#service) +- [Share](#share) - [Subnet](#subnet) - [Trunk](#trunk) - [Volume](#volume) @@ -181,6 +182,7 @@ _Appears in:_ - [ServerGroupSpec](#servergroupspec) - [ServerSpec](#serverspec) - [ServiceSpec](#servicespec) +- [ShareSpec](#sharespec) - [SubnetSpec](#subnetspec) - [TrunkSpec](#trunkspec) - [VolumeSpec](#volumespec) @@ -1859,6 +1861,7 @@ _Appears in:_ - [ServerGroupSpec](#servergroupspec) - [ServerSpec](#serverspec) - [ServiceSpec](#servicespec) +- [ShareSpec](#sharespec) - [SubnetSpec](#subnetspec) - [TrunkSpec](#trunkspec) - [VolumeSpec](#volumespec) @@ -1895,6 +1898,7 @@ _Appears in:_ - [ServerGroupSpec](#servergroupspec) - [ServerSpec](#serverspec) - [ServiceSpec](#servicespec) +- [ShareSpec](#sharespec) - [SubnetSpec](#subnetspec) - [TrunkSpec](#trunkspec) - [VolumeSpec](#volumespec) @@ -2199,6 +2203,8 @@ _Appears in:_ - [ServerResourceSpec](#serverresourcespec) - [ServiceFilter](#servicefilter) - [ServiceResourceSpec](#serviceresourcespec) +- [ShareFilter](#sharefilter) +- [ShareResourceSpec](#shareresourcespec) - [SubnetFilter](#subnetfilter) - [SubnetResourceSpec](#subnetresourcespec) - [TrunkFilter](#trunkfilter) @@ -3800,6 +3806,203 @@ _Appears in:_ | `resource` _[ServiceResourceStatus](#serviceresourcestatus)_ | resource contains the observed state of the OpenStack resource. | | | +#### Share + + + +Share is the Schema for an ORC resource. + + + + + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `apiVersion` _string_ | `openstack.k-orc.cloud/v1alpha1` | | | +| `kind` _string_ | `Share` | | | +| `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | | +| `spec` _[ShareSpec](#sharespec)_ | spec specifies the desired state of the resource. | | | +| `status` _[ShareStatus](#sharestatus)_ | status defines the observed state of the resource. | | | + + +#### ShareExportLocation + + + + + + + +_Appears in:_ +- [ShareResourceStatus](#shareresourcestatus) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `path` _string_ | path is the export path for accessing the share | | MaxLength: 1024
| +| `preferred` _boolean_ | preferred indicates if this is the preferred export location | | | + + +#### ShareFilter + + + +ShareFilter defines an existing resource by its properties + +_Validation:_ +- MinProperties: 1 + +_Appears in:_ +- [ShareImport](#shareimport) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `name` _[OpenStackName](#openstackname)_ | name of the existing resource | | MaxLength: 255
MinLength: 1
Pattern: `^[^,]+$`
| +| `description` _string_ | description of the existing resource | | MaxLength: 255
MinLength: 1
| +| `shareProto` _string_ | shareProto is the file system protocol to filter by | | Enum: [NFS CIFS GlusterFS HDFS CephFS MAPRFS]
| +| `status` _string_ | status is the share status to filter by | | Enum: [creating available deleting error error_deleting manage_starting manage_error unmanage_starting unmanage_error extending extending_error shrinking shrinking_error]
| +| `isPublic` _boolean_ | isPublic filters by public visibility | | | + + +#### ShareImport + + + +ShareImport specifies an existing resource which will be imported instead of +creating a new one + +_Validation:_ +- MaxProperties: 1 +- MinProperties: 1 + +_Appears in:_ +- [ShareSpec](#sharespec) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `id` _string_ | id contains the unique identifier of an existing OpenStack resource. Note
that when specifying an import by ID, the resource MUST already exist.
The ORC object will enter an error state if the resource does not exist. | | Format: uuid
MaxLength: 36
| +| `filter` _[ShareFilter](#sharefilter)_ | filter contains a resource query which is expected to return a single
result. The controller will continue to retry if filter returns no
results. If filter returns multiple results the controller will set an
error state and will not continue to retry. | | MinProperties: 1
| + + +#### ShareMetadata + + + + + + + +_Appears in:_ +- [ShareResourceSpec](#shareresourcespec) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `name` _string_ | name is the name of the metadata | | MaxLength: 255
| +| `value` _string_ | value is the value of the metadata | | MaxLength: 255
| + + +#### ShareMetadataStatus + + + + + + + +_Appears in:_ +- [ShareResourceStatus](#shareresourcestatus) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `name` _string_ | name is the name of the metadata | | MaxLength: 255
| +| `value` _string_ | value is the value of the metadata | | MaxLength: 255
| + + +#### ShareResourceSpec + + + +ShareResourceSpec contains the desired state of the resource. + + + +_Appears in:_ +- [ShareSpec](#sharespec) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `name` _[OpenStackName](#openstackname)_ | name will be the name of the created resource. If not specified, the
name of the ORC object will be used. | | MaxLength: 255
MinLength: 1
Pattern: `^[^,]+$`
| +| `description` _string_ | description is a human-readable description for the resource. | | MaxLength: 255
MinLength: 1
| +| `size` _integer_ | size is the size of the share, in gibibytes (GiB). | | Minimum: 1
| +| `shareProto` _string_ | shareProto is the file system protocol for the share.
Valid values are NFS, CIFS, GlusterFS, HDFS, CephFS, or MAPRFS. | | Enum: [NFS CIFS GlusterFS HDFS CephFS MAPRFS]
| +| `availabilityZone` _string_ | availabilityZone is the availability zone in which to create the share. | | MaxLength: 255
| +| `metadata` _[ShareMetadata](#sharemetadata) array_ | Refer to Kubernetes API documentation for fields of `metadata`. | | MaxItems: 64
| +| `isPublic` _boolean_ | isPublic defines whether the share is publicly visible. | | | + + +#### ShareResourceStatus + + + +ShareResourceStatus represents the observed state of the resource. + + + +_Appears in:_ +- [ShareStatus](#sharestatus) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `name` _string_ | name is a Human-readable name for the resource. Might not be unique. | | MaxLength: 1024
| +| `description` _string_ | description is a human-readable description for the resource. | | MaxLength: 1024
| +| `size` _integer_ | size is the size of the share in GiB. | | | +| `shareProto` _string_ | shareProto is the file system protocol. | | MaxLength: 1024
| +| `status` _string_ | status represents the current status of the share. | | MaxLength: 1024
| +| `availabilityZone` _string_ | availabilityZone is which availability zone the share is in. | | MaxLength: 1024
| +| `exportLocations` _[ShareExportLocation](#shareexportlocation) array_ | exportLocations contains paths for accessing the share. | | MaxItems: 32
| +| `metadata` _[ShareMetadataStatus](#sharemetadatastatus) array_ | Refer to Kubernetes API documentation for fields of `metadata`. | | MaxItems: 64
| +| `isPublic` _boolean_ | isPublic indicates whether the share is publicly visible. | | | +| `createdAt` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#time-v1-meta)_ | createdAt shows the date and time when the resource was created. The date and time stamp format is ISO 8601. | | | +| `projectID` _string_ | projectID is the ID of the project that owns the share. | | MaxLength: 1024
| + + +#### ShareSpec + + + +ShareSpec defines the desired state of an ORC object. + + + +_Appears in:_ +- [Share](#share) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `import` _[ShareImport](#shareimport)_ | import refers to an existing OpenStack resource which will be imported instead of
creating a new one. | | MaxProperties: 1
MinProperties: 1
| +| `resource` _[ShareResourceSpec](#shareresourcespec)_ | resource specifies the desired state of the resource.
resource may not be specified if the management policy is `unmanaged`.
resource must be specified if the management policy is `managed`. | | | +| `managementPolicy` _[ManagementPolicy](#managementpolicy)_ | managementPolicy defines how ORC will treat the object. Valid values are
`managed`: ORC will create, update, and delete the resource; `unmanaged`:
ORC will import an existing resource, and will not apply updates to it or
delete it. | managed | Enum: [managed unmanaged]
| +| `managedOptions` _[ManagedOptions](#managedoptions)_ | managedOptions specifies options which may be applied to managed objects. | | | +| `cloudCredentialsRef` _[CloudCredentialsReference](#cloudcredentialsreference)_ | cloudCredentialsRef points to a secret containing OpenStack credentials | | | + + +#### ShareStatus + + + +ShareStatus defines the observed state of an ORC resource. + + + +_Appears in:_ +- [Share](#share) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#condition-v1-meta) array_ | conditions represents the observed status of the object.
Known .status.conditions.type are: "Available", "Progressing"
Available represents the availability of the OpenStack resource. If it is
true then the resource is ready for use.
Progressing indicates whether the controller is still attempting to
reconcile the current state of the OpenStack resource to the desired
state. Progressing will be False either because the desired state has
been achieved, or because some terminal error prevents it from ever being
achieved and the controller is no longer attempting to reconcile. If
Progressing is True, an observer waiting on the resource should continue
to wait. | | MaxItems: 32
| +| `id` _string_ | id is the unique identifier of the OpenStack resource. | | MaxLength: 1024
| +| `resource` _[ShareResourceStatus](#shareresourcestatus)_ | resource contains the observed state of the OpenStack resource. | | | + + #### Subnet