diff --git a/CHANGELOG.md b/CHANGELOG.md index 5205823..fc2a34f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ Release notes are generated from [Conventional Commits](https://www.conventional - **observe:** Move YAMLs to examples/, update grpc, refresh changelog [6a9b19f](https://github.com/platformrelay/provider-gridscale/commit/6a9b19fc67c57cb2e0a01b096733f04e8633d525) +- **backuplist:** Fix deprecated API, goimports, regenerate managed/deepcopy files [5d9a3a4](https://github.com/platformrelay/provider-gridscale/commit/5d9a3a445d759c791d41727f48f8847bf88b257f) + +- **backuplist:** Gofmt, README count 33, API docs, grpc v1.82.1, changelog [d2ff5a3](https://github.com/platformrelay/provider-gridscale/commit/d2ff5a3e09cc95a4227d64e2af7ed3cfee3ed593) + ### Documentation @@ -23,6 +27,11 @@ Release notes are generated from [Conventional Commits](https://www.conventional - **coordination:** Mark E5 sonar-security batch Integrated ([#28](https://github.com/platformrelay/provider-gridscale/pull/28))[3378a81](https://github.com/platformrelay/provider-gridscale/commit/3378a8124ec06c9b327358c0e904e10460c1a025) + +### Features + +- **backuplist:** Add BackupList CRD and observe-only controller E8-S02 [73d9201](https://github.com/platformrelay/provider-gridscale/commit/73d9201b756ca3cf81888311a6661017b743ac0d) + ## [0.2.2](https://github.com/platformrelay/provider-gridscale/compare/v0.2.1..v0.2.2) - 2026-07-25 ### Bug Fixes diff --git a/README.md b/README.md index 899817b..762414c 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ clusters in YAML — Crossplane reconciles them against - **Cluster *and* namespaced APIs** — `gridscale.platformrelay.io` (cluster) and `gridscale.m.platformrelay.io` (namespaced) so multi-tenant teams can own their own `ProviderConfig`. -- **32 managed resources / 8 API groups** — servers, storage, networking, PaaS +- **33 managed resources / 8 API groups** — servers, storage, networking, PaaS databases, K8s, object storage, marketplace apps, and more. - **Signed packages** — GHCR + Upbound Marketplace publishes are keyless-cosign signed with an SBOM (from `v0.2.0` onward). @@ -113,7 +113,7 @@ Namespaced `ProviderConfig` / `ClusterProviderConfig` live under ## Supported resources -32 managed resources across 8 API groups, each served under both the +33 managed resources across 8 API groups, each served under both the cluster-scoped and namespaced families. Kind names below are the exact API server values (Upjet casing) — copy straight into `kind:`. diff --git a/apis/cluster/storage/v1alpha1/backuplist_types.go b/apis/cluster/storage/v1alpha1/backuplist_types.go new file mode 100644 index 0000000..ad770c1 --- /dev/null +++ b/apis/cluster/storage/v1alpha1/backuplist_types.go @@ -0,0 +1,83 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + v1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1" +) + +// StorageBackupEntry describes a single backup entry returned by the gridscale +// storage backups API. +type StorageBackupEntry struct { + ObjectUUID string `json:"objectUuid,omitempty"` + Name string `json:"name,omitempty"` + Capacity float64 `json:"capacity,omitempty"` + CreateTime string `json:"createTime,omitempty"` +} + +// BackupListParameters are the configurable fields of a BackupList. +type BackupListParameters struct { + // StorageUUID is the UUID of the storage whose backups to list. + // +kubebuilder:validation:Required + StorageUUID string `json:"storageUUID"` +} + +// BackupListObservation are the observable fields of a BackupList. +type BackupListObservation struct { + // StorageBackups is the list of backups for the storage. + StorageBackups []StorageBackupEntry `json:"storageBackups,omitempty"` +} + +// BackupListSpec defines the desired state of BackupList. +type BackupListSpec struct { + v1.ResourceSpec `json:",inline"` + ForProvider BackupListParameters `json:"forProvider"` +} + +// BackupListStatus defines the observed state of BackupList. +type BackupListStatus struct { + v1.ResourceStatus `json:",inline"` + AtProvider BackupListObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,gridscale} + +// BackupList is the Schema for the BackupLists API. Lists storage backups for a given storage UUID. +type BackupList struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec BackupListSpec `json:"spec"` + Status BackupListStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// BackupListList contains a list of BackupList. +type BackupListList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []BackupList `json:"items"` +} + +// Repository type metadata. +var ( + BackupList_Kind = "BackupList" + BackupList_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: BackupList_Kind}.String() + BackupList_KindAPIVersion = BackupList_Kind + "." + CRDGroupVersion.String() + BackupList_GroupVersionKind = CRDGroupVersion.WithKind(BackupList_Kind) +) + +func init() { + SchemeBuilder.Register(&BackupList{}, &BackupListList{}) +} diff --git a/apis/cluster/storage/v1alpha1/zz_generated.deepcopy.go b/apis/cluster/storage/v1alpha1/zz_generated.deepcopy.go index 40ed369..1c2f84e 100644 --- a/apis/cluster/storage/v1alpha1/zz_generated.deepcopy.go +++ b/apis/cluster/storage/v1alpha1/zz_generated.deepcopy.go @@ -13,6 +13,134 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackupList) DeepCopyInto(out *BackupList) { + *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 BackupList. +func (in *BackupList) DeepCopy() *BackupList { + if in == nil { + return nil + } + out := new(BackupList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BackupList) 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 *BackupListList) DeepCopyInto(out *BackupListList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]BackupList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupListList. +func (in *BackupListList) DeepCopy() *BackupListList { + if in == nil { + return nil + } + out := new(BackupListList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BackupListList) 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 *BackupListObservation) DeepCopyInto(out *BackupListObservation) { + *out = *in + if in.StorageBackups != nil { + in, out := &in.StorageBackups, &out.StorageBackups + *out = make([]StorageBackupEntry, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupListObservation. +func (in *BackupListObservation) DeepCopy() *BackupListObservation { + if in == nil { + return nil + } + out := new(BackupListObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackupListParameters) DeepCopyInto(out *BackupListParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupListParameters. +func (in *BackupListParameters) DeepCopy() *BackupListParameters { + if in == nil { + return nil + } + out := new(BackupListParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackupListSpec) DeepCopyInto(out *BackupListSpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + out.ForProvider = in.ForProvider +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupListSpec. +func (in *BackupListSpec) DeepCopy() *BackupListSpec { + if in == nil { + return nil + } + out := new(BackupListSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackupListStatus) DeepCopyInto(out *BackupListStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupListStatus. +func (in *BackupListStatus) DeepCopy() *BackupListStatus { + if in == nil { + return nil + } + out := new(BackupListStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Clone) DeepCopyInto(out *Clone) { *out = *in @@ -330,6 +458,21 @@ func (in *CloneStatus) DeepCopy() *CloneStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageBackupEntry) DeepCopyInto(out *StorageBackupEntry) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageBackupEntry. +func (in *StorageBackupEntry) DeepCopy() *StorageBackupEntry { + if in == nil { + return nil + } + out := new(StorageBackupEntry) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StorageImport) DeepCopyInto(out *StorageImport) { *out = *in diff --git a/apis/cluster/storage/v1alpha1/zz_generated.managed.go b/apis/cluster/storage/v1alpha1/zz_generated.managed.go index 4cb0bc8..8616f7d 100644 --- a/apis/cluster/storage/v1alpha1/zz_generated.managed.go +++ b/apis/cluster/storage/v1alpha1/zz_generated.managed.go @@ -8,6 +8,56 @@ package v1alpha1 import xpv1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1" +// GetCondition of this BackupList. +func (mg *BackupList) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this BackupList. +func (mg *BackupList) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this BackupList. +func (mg *BackupList) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this BackupList. +func (mg *BackupList) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +// GetWriteConnectionSecretToReference of this BackupList. +func (mg *BackupList) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this BackupList. +func (mg *BackupList) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this BackupList. +func (mg *BackupList) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this BackupList. +func (mg *BackupList) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this BackupList. +func (mg *BackupList) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +// SetWriteConnectionSecretToReference of this BackupList. +func (mg *BackupList) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} + // GetCondition of this Clone. func (mg *Clone) GetCondition(ct xpv1.ConditionType) xpv1.Condition { return mg.Status.GetCondition(ct) diff --git a/apis/cluster/storage/v1alpha1/zz_generated.managedlist.go b/apis/cluster/storage/v1alpha1/zz_generated.managedlist.go index 83708de..d3d1552 100644 --- a/apis/cluster/storage/v1alpha1/zz_generated.managedlist.go +++ b/apis/cluster/storage/v1alpha1/zz_generated.managedlist.go @@ -8,6 +8,15 @@ package v1alpha1 import resource "github.com/crossplane/crossplane-runtime/v2/pkg/resource" +// GetItems of this BackupListList. +func (l *BackupListList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} + // GetItems of this CloneList. func (l *CloneList) GetItems() []resource.Managed { items := make([]resource.Managed, len(l.Items)) diff --git a/apis/namespaced/storage/v1alpha1/backuplist_types.go b/apis/namespaced/storage/v1alpha1/backuplist_types.go new file mode 100644 index 0000000..d879078 --- /dev/null +++ b/apis/namespaced/storage/v1alpha1/backuplist_types.go @@ -0,0 +1,84 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + v1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1" + v2 "github.com/crossplane/crossplane-runtime/v2/apis/common/v2" +) + +// StorageBackupEntry describes a single backup entry returned by the gridscale +// storage backups API. +type StorageBackupEntry struct { + ObjectUUID string `json:"objectUuid,omitempty"` + Name string `json:"name,omitempty"` + Capacity float64 `json:"capacity,omitempty"` + CreateTime string `json:"createTime,omitempty"` +} + +// BackupListParameters are the configurable fields of a BackupList. +type BackupListParameters struct { + // StorageUUID is the UUID of the storage whose backups to list. + // +kubebuilder:validation:Required + StorageUUID string `json:"storageUUID"` +} + +// BackupListObservation are the observable fields of a BackupList. +type BackupListObservation struct { + // StorageBackups is the list of backups for the storage. + StorageBackups []StorageBackupEntry `json:"storageBackups,omitempty"` +} + +// BackupListSpec defines the desired state of BackupList. +type BackupListSpec struct { + v2.ManagedResourceSpec `json:",inline"` + ForProvider BackupListParameters `json:"forProvider"` +} + +// BackupListStatus defines the observed state of BackupList. +type BackupListStatus struct { + v1.ResourceStatus `json:",inline"` + AtProvider BackupListObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:resource:scope=Namespaced,categories={crossplane,managed,gridscale} + +// BackupList is the Schema for the BackupLists API. Lists storage backups for a given storage UUID. +type BackupList struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec BackupListSpec `json:"spec"` + Status BackupListStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// BackupListList contains a list of BackupList. +type BackupListList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []BackupList `json:"items"` +} + +// Repository type metadata. +var ( + BackupList_Kind = "BackupList" + BackupList_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: BackupList_Kind}.String() + BackupList_KindAPIVersion = BackupList_Kind + "." + CRDGroupVersion.String() + BackupList_GroupVersionKind = CRDGroupVersion.WithKind(BackupList_Kind) +) + +func init() { + SchemeBuilder.Register(&BackupList{}, &BackupListList{}) +} diff --git a/apis/namespaced/storage/v1alpha1/zz_generated.deepcopy.go b/apis/namespaced/storage/v1alpha1/zz_generated.deepcopy.go index 0a2fc95..45b51c9 100644 --- a/apis/namespaced/storage/v1alpha1/zz_generated.deepcopy.go +++ b/apis/namespaced/storage/v1alpha1/zz_generated.deepcopy.go @@ -13,6 +13,134 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackupList) DeepCopyInto(out *BackupList) { + *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 BackupList. +func (in *BackupList) DeepCopy() *BackupList { + if in == nil { + return nil + } + out := new(BackupList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BackupList) 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 *BackupListList) DeepCopyInto(out *BackupListList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]BackupList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupListList. +func (in *BackupListList) DeepCopy() *BackupListList { + if in == nil { + return nil + } + out := new(BackupListList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BackupListList) 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 *BackupListObservation) DeepCopyInto(out *BackupListObservation) { + *out = *in + if in.StorageBackups != nil { + in, out := &in.StorageBackups, &out.StorageBackups + *out = make([]StorageBackupEntry, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupListObservation. +func (in *BackupListObservation) DeepCopy() *BackupListObservation { + if in == nil { + return nil + } + out := new(BackupListObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackupListParameters) DeepCopyInto(out *BackupListParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupListParameters. +func (in *BackupListParameters) DeepCopy() *BackupListParameters { + if in == nil { + return nil + } + out := new(BackupListParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackupListSpec) DeepCopyInto(out *BackupListSpec) { + *out = *in + in.ManagedResourceSpec.DeepCopyInto(&out.ManagedResourceSpec) + out.ForProvider = in.ForProvider +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupListSpec. +func (in *BackupListSpec) DeepCopy() *BackupListSpec { + if in == nil { + return nil + } + out := new(BackupListSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackupListStatus) DeepCopyInto(out *BackupListStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupListStatus. +func (in *BackupListStatus) DeepCopy() *BackupListStatus { + if in == nil { + return nil + } + out := new(BackupListStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Clone) DeepCopyInto(out *Clone) { *out = *in @@ -330,6 +458,21 @@ func (in *CloneStatus) DeepCopy() *CloneStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageBackupEntry) DeepCopyInto(out *StorageBackupEntry) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageBackupEntry. +func (in *StorageBackupEntry) DeepCopy() *StorageBackupEntry { + if in == nil { + return nil + } + out := new(StorageBackupEntry) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StorageImport) DeepCopyInto(out *StorageImport) { *out = *in diff --git a/apis/namespaced/storage/v1alpha1/zz_generated.managed.go b/apis/namespaced/storage/v1alpha1/zz_generated.managed.go index c990654..fd687ca 100644 --- a/apis/namespaced/storage/v1alpha1/zz_generated.managed.go +++ b/apis/namespaced/storage/v1alpha1/zz_generated.managed.go @@ -8,6 +8,46 @@ package v1alpha1 import xpv1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1" +// GetCondition of this BackupList. +func (mg *BackupList) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetManagementPolicies of this BackupList. +func (mg *BackupList) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this BackupList. +func (mg *BackupList) GetProviderConfigReference() *xpv1.ProviderConfigReference { + return mg.Spec.ProviderConfigReference +} + +// GetWriteConnectionSecretToReference of this BackupList. +func (mg *BackupList) GetWriteConnectionSecretToReference() *xpv1.LocalSecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this BackupList. +func (mg *BackupList) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetManagementPolicies of this BackupList. +func (mg *BackupList) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this BackupList. +func (mg *BackupList) SetProviderConfigReference(r *xpv1.ProviderConfigReference) { + mg.Spec.ProviderConfigReference = r +} + +// SetWriteConnectionSecretToReference of this BackupList. +func (mg *BackupList) SetWriteConnectionSecretToReference(r *xpv1.LocalSecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} + // GetCondition of this Clone. func (mg *Clone) GetCondition(ct xpv1.ConditionType) xpv1.Condition { return mg.Status.GetCondition(ct) diff --git a/apis/namespaced/storage/v1alpha1/zz_generated.managedlist.go b/apis/namespaced/storage/v1alpha1/zz_generated.managedlist.go index 83708de..d3d1552 100644 --- a/apis/namespaced/storage/v1alpha1/zz_generated.managedlist.go +++ b/apis/namespaced/storage/v1alpha1/zz_generated.managedlist.go @@ -8,6 +8,15 @@ package v1alpha1 import resource "github.com/crossplane/crossplane-runtime/v2/pkg/resource" +// GetItems of this BackupListList. +func (l *BackupListList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} + // GetItems of this CloneList. func (l *CloneList) GetItems() []resource.Managed { items := make([]resource.Managed, len(l.Items)) diff --git a/docs/api/out.md b/docs/api/out.md index 04b1186..41a3429 100644 --- a/docs/api/out.md +++ b/docs/api/out.md @@ -13621,6 +13621,8 @@ _Appears in:_ ### Resource Types +- [BackupList](#backuplist) +- [BackupListList](#backuplistlist) - [Clone](#clone) - [CloneList](#clonelist) - [StorageImport](#storageimport) @@ -13628,6 +13630,111 @@ _Appears in:_ +#### BackupList + + + +BackupList is the Schema for the BackupLists API. Lists storage backups for a given storage UUID. + + + +_Appears in:_ +- [BackupListList](#backuplistlist) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `apiVersion` _string_ | `storage.gridscale.m.platformrelay.io/v1alpha1` | | | +| `kind` _string_ | `BackupList` | | | +| `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | | +| `spec` _[BackupListSpec](#backuplistspec)_ | | | | +| `status` _[BackupListStatus](#backupliststatus)_ | | | | + + +#### BackupListList + + + +BackupListList contains a list of BackupList. + + + + + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `apiVersion` _string_ | `storage.gridscale.m.platformrelay.io/v1alpha1` | | | +| `kind` _string_ | `BackupListList` | | | +| `metadata` _[ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#listmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | | +| `items` _[BackupList](#backuplist) array_ | | | | + + +#### BackupListObservation + + + +BackupListObservation are the observable fields of a BackupList. + + + +_Appears in:_ +- [BackupListStatus](#backupliststatus) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `storageBackups` _[StorageBackupEntry](#storagebackupentry) array_ | StorageBackups is the list of backups for the storage. | | | + + +#### BackupListParameters + + + +BackupListParameters are the configurable fields of a BackupList. + + + +_Appears in:_ +- [BackupListSpec](#backuplistspec) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `storageUUID` _string_ | StorageUUID is the UUID of the storage whose backups to list. | | Required: \{\}
| + + +#### BackupListSpec + + + +BackupListSpec defines the desired state of BackupList. + + + +_Appears in:_ +- [BackupList](#backuplist) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `writeConnectionSecretToRef` _[LocalSecretReference](#localsecretreference)_ | WriteConnectionSecretToReference specifies the namespace and name of a
Secret to which any connection details for this managed resource should
be written. Connection details frequently include the endpoint, username,
and password required to connect to the managed resource. | | | +| `providerConfigRef` _[ProviderConfigReference](#providerconfigreference)_ | ProviderConfigReference specifies how the provider that will be used to
create, observe, update, and delete this managed resource should be
configured. | \{ kind:ClusterProviderConfig name:default \} | | +| `managementPolicies` _[ManagementPolicies](#managementpolicies)_ | THIS IS A BETA FIELD. It is on by default but can be opted out
through a Crossplane feature flag.
ManagementPolicies specify the array of actions Crossplane is allowed to
take on the managed and external resources.
See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223
and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md | [*] | Enum: [Observe Create Update Delete LateInitialize *]
| +| `forProvider` _[BackupListParameters](#backuplistparameters)_ | | | | + + +#### BackupListStatus + + + +BackupListStatus defines the observed state of BackupList. + + + +_Appears in:_ +- [BackupList](#backuplist) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `atProvider` _[BackupListObservation](#backuplistobservation)_ | | | | + + #### Clone @@ -13779,6 +13886,26 @@ _Appears in:_ | `atProvider` _[CloneObservation](#cloneobservation)_ | | | | +#### StorageBackupEntry + + + +StorageBackupEntry describes a single backup entry returned by the gridscale +storage backups API. + + + +_Appears in:_ +- [BackupListObservation](#backuplistobservation) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `objectUuid` _string_ | | | | +| `name` _string_ | | | | +| `capacity` _float_ | | | | +| `createTime` _string_ | | | | + + #### StorageImport @@ -13931,6 +14058,8 @@ _Appears in:_ ### Resource Types +- [BackupList](#backuplist) +- [BackupListList](#backuplistlist) - [Clone](#clone) - [CloneList](#clonelist) - [StorageImport](#storageimport) @@ -13938,6 +14067,112 @@ _Appears in:_ +#### BackupList + + + +BackupList is the Schema for the BackupLists API. Lists storage backups for a given storage UUID. + + + +_Appears in:_ +- [BackupListList](#backuplistlist) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `apiVersion` _string_ | `storage.gridscale.platformrelay.io/v1alpha1` | | | +| `kind` _string_ | `BackupList` | | | +| `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | | +| `spec` _[BackupListSpec](#backuplistspec)_ | | | | +| `status` _[BackupListStatus](#backupliststatus)_ | | | | + + +#### BackupListList + + + +BackupListList contains a list of BackupList. + + + + + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `apiVersion` _string_ | `storage.gridscale.platformrelay.io/v1alpha1` | | | +| `kind` _string_ | `BackupListList` | | | +| `metadata` _[ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#listmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | | +| `items` _[BackupList](#backuplist) array_ | | | | + + +#### BackupListObservation + + + +BackupListObservation are the observable fields of a BackupList. + + + +_Appears in:_ +- [BackupListStatus](#backupliststatus) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `storageBackups` _[StorageBackupEntry](#storagebackupentry) array_ | StorageBackups is the list of backups for the storage. | | | + + +#### BackupListParameters + + + +BackupListParameters are the configurable fields of a BackupList. + + + +_Appears in:_ +- [BackupListSpec](#backuplistspec) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `storageUUID` _string_ | StorageUUID is the UUID of the storage whose backups to list. | | Required: \{\}
| + + +#### BackupListSpec + + + +BackupListSpec defines the desired state of BackupList. + + + +_Appears in:_ +- [BackupList](#backuplist) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `writeConnectionSecretToRef` _[SecretReference](#secretreference)_ | WriteConnectionSecretToReference specifies the namespace and name of a
Secret to which any connection details for this managed resource should
be written. Connection details frequently include the endpoint, username,
and password required to connect to the managed resource. | | | +| `providerConfigRef` _[Reference](#reference)_ | ProviderConfigReference specifies how the provider that will be used to
create, observe, update, and delete this managed resource should be
configured. | \{ name:default \} | | +| `managementPolicies` _[ManagementPolicies](#managementpolicies)_ | THIS IS A BETA FIELD. It is on by default but can be opted out
through a Crossplane feature flag.
ManagementPolicies specify the array of actions Crossplane is allowed to
take on the managed and external resources.
This field is planned to replace the DeletionPolicy field in a future
release. Currently, both could be set independently and non-default
values would be honored if the feature flag is enabled. If both are
custom, the DeletionPolicy field will be ignored.
See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223
and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md | [*] | | +| `deletionPolicy` _[DeletionPolicy](#deletionpolicy)_ | DeletionPolicy specifies what will happen to the underlying external
when this managed resource is deleted - either "Delete" or "Orphan" the
external resource.
This field is planned to be deprecated in favor of the ManagementPolicies
field in a future release. Currently, both could be set independently and
non-default values would be honored if the feature flag is enabled.
See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 | Delete | Enum: [Orphan Delete]
| +| `forProvider` _[BackupListParameters](#backuplistparameters)_ | | | | + + +#### BackupListStatus + + + +BackupListStatus defines the observed state of BackupList. + + + +_Appears in:_ +- [BackupList](#backuplist) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `atProvider` _[BackupListObservation](#backuplistobservation)_ | | | | + + #### Clone @@ -14090,6 +14325,26 @@ _Appears in:_ | `atProvider` _[CloneObservation](#cloneobservation)_ | | | | +#### StorageBackupEntry + + + +StorageBackupEntry describes a single backup entry returned by the gridscale +storage backups API. + + + +_Appears in:_ +- [BackupListObservation](#backuplistobservation) + +| Field | Description | Default | Validation | +| --- | --- | --- | --- | +| `objectUuid` _string_ | | | | +| `name` _string_ | | | | +| `capacity` _float_ | | | | +| `createTime` _string_ | | | | + + #### StorageImport diff --git a/hack/test/e8_s02_backuplist_crd_exists_test.sh b/hack/test/e8_s02_backuplist_crd_exists_test.sh new file mode 100755 index 0000000..df1ef8d --- /dev/null +++ b/hack/test/e8_s02_backuplist_crd_exists_test.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -euo pipefail +CLUSTER=package/crds/storage.gridscale.platformrelay.io_backuplists.yaml +NAMESPACED=package/crds/storage.gridscale.m.platformrelay.io_backuplists.yaml +[ -f "$CLUSTER" ] || { echo "FAIL: missing $CLUSTER"; exit 1; } +[ -f "$NAMESPACED" ] || { echo "FAIL: missing $NAMESPACED"; exit 1; } +grep -q "kind: CustomResourceDefinition" "$CLUSTER" || { echo "FAIL: not a CRD: $CLUSTER"; exit 1; } +grep -q "kind: CustomResourceDefinition" "$NAMESPACED" || { echo "FAIL: not a CRD: $NAMESPACED"; exit 1; } +echo "PASS: BackupList CRD YAMLs exist" diff --git a/internal/clients/gridscale_http.go b/internal/clients/gridscale_http.go new file mode 100644 index 0000000..5b2b304 --- /dev/null +++ b/internal/clients/gridscale_http.go @@ -0,0 +1,60 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +package clients + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "time" +) + +const defaultAPIURL = "https://api.gridscale.io" + +// GridscaleClient is a thin REST client for the gridscale API. +type GridscaleClient struct { + baseURL string + userUUID string + token string + httpClient *http.Client +} + +// NewGridscaleClient creates a new GridscaleClient. If baseURL is empty, the +// default gridscale API URL is used. +func NewGridscaleClient(userUUID, token, baseURL string) *GridscaleClient { + if baseURL == "" { + baseURL = defaultAPIURL + } + return &GridscaleClient{ + baseURL: baseURL, + userUUID: userUUID, + token: token, + httpClient: &http.Client{Timeout: 30 * time.Second}, + } +} + +// Get performs an authenticated GET request to the given path and decodes the +// JSON response body into out. +func (c *GridscaleClient) Get(ctx context.Context, path string, out any) error { + req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.baseURL+path, nil) + if err != nil { + return fmt.Errorf("build request: %w", err) + } + req.Header.Set("X-Auth-UserID", c.userUUID) + req.Header.Set("X-Auth-Token", c.token) + req.Header.Set("Content-Type", "application/json") + + resp, err := c.httpClient.Do(req) + if err != nil { + return fmt.Errorf("do request: %w", err) + } + defer resp.Body.Close() //nolint:errcheck + + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return fmt.Errorf("unexpected status %d for %s", resp.StatusCode, path) + } + return json.NewDecoder(resp.Body).Decode(out) +} diff --git a/internal/clients/gridscale_http_test.go b/internal/clients/gridscale_http_test.go new file mode 100644 index 0000000..77879d1 --- /dev/null +++ b/internal/clients/gridscale_http_test.go @@ -0,0 +1,66 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +package clients_test + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + + "github.com/PlatformRelay/provider-gridscale/internal/clients" +) + +func TestGridscaleClientGet_Success(t *testing.T) { + type payload struct { + Foo string `json:"foo"` + } + want := payload{Foo: "bar"} + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Header.Get("X-Auth-UserID") == "" { + t.Error("missing X-Auth-UserID header") + } + if r.Header.Get("X-Auth-Token") == "" { + t.Error("missing X-Auth-Token header") + } + if r.URL.Path != "/objects/test" { + t.Errorf("unexpected path: %s", r.URL.Path) + } + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(want) //nolint:errcheck + })) + defer srv.Close() + + c := clients.NewGridscaleClient("test-uuid", "test-token", srv.URL) + var got payload + if err := c.Get(context.Background(), "/objects/test", &got); err != nil { + t.Fatalf("unexpected error: %v", err) + } + if got.Foo != want.Foo { + t.Errorf("got %q, want %q", got.Foo, want.Foo) + } +} + +func TestGridscaleClientGet_HTTPError(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.Error(w, "forbidden", http.StatusForbidden) + })) + defer srv.Close() + + c := clients.NewGridscaleClient("u", "t", srv.URL) + var out any + err := c.Get(context.Background(), "/x", &out) + if err == nil { + t.Fatal("expected non-nil error for 403 response") + } +} + +func TestGridscaleClientGet_DefaultBaseURL(t *testing.T) { + // NewGridscaleClient with empty baseURL should use the default gridscale URL + // (we cannot call it without a real server, just verify no panic and error wraps) + c := clients.NewGridscaleClient("u", "t", "") + _ = c // just verify construction doesn't panic +} diff --git a/internal/controller/cluster/setup_custom.go b/internal/controller/cluster/setup_custom.go new file mode 100644 index 0000000..b596089 --- /dev/null +++ b/internal/controller/cluster/setup_custom.go @@ -0,0 +1,36 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +package controller + +import ( + tjcontroller "github.com/crossplane/upjet/v2/pkg/controller" + ctrl "sigs.k8s.io/controller-runtime" + + backuplist "github.com/PlatformRelay/provider-gridscale/internal/controller/cluster/storage/backuplist" +) + +// SetupCustom adds non-upjet controllers. +func SetupCustom(mgr ctrl.Manager, o tjcontroller.Options) error { + for _, setup := range []func(ctrl.Manager, tjcontroller.Options) error{ + backuplist.Setup, + } { + if err := setup(mgr, o); err != nil { + return err + } + } + return nil +} + +// SetupCustomGated adds non-upjet controllers with CRD gating. +func SetupCustomGated(mgr ctrl.Manager, o tjcontroller.Options) error { + for _, setup := range []func(ctrl.Manager, tjcontroller.Options) error{ + backuplist.SetupGated, + } { + if err := setup(mgr, o); err != nil { + return err + } + } + return nil +} diff --git a/internal/controller/cluster/storage/backuplist/controller.go b/internal/controller/cluster/storage/backuplist/controller.go new file mode 100644 index 0000000..cab94e3 --- /dev/null +++ b/internal/controller/cluster/storage/backuplist/controller.go @@ -0,0 +1,151 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +package backuplist + +import ( + "context" + "fmt" + "time" + + "github.com/pkg/errors" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + + xpv1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1" + "github.com/crossplane/crossplane-runtime/v2/pkg/event" + "github.com/crossplane/crossplane-runtime/v2/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/v2/pkg/reconciler/managed" + xpresource "github.com/crossplane/crossplane-runtime/v2/pkg/resource" + tjcontroller "github.com/crossplane/upjet/v2/pkg/controller" + "github.com/crossplane/upjet/v2/pkg/terraform" + + v1alpha1 "github.com/PlatformRelay/provider-gridscale/apis/cluster/storage/v1alpha1" + "github.com/PlatformRelay/provider-gridscale/internal/clients" +) + +const ( + errNotBackupList = "managed resource is not a BackupList" + errList = "cannot list storage backups" +) + +type connector struct { + kube client.Client + setupFn terraform.SetupFn +} + +func (c *connector) Connect(ctx context.Context, mg xpresource.Managed) (managed.ExternalClient, error) { + bl, ok := mg.(*v1alpha1.BackupList) + if !ok { + return nil, errors.New(errNotBackupList) + } + setup, err := c.setupFn(ctx, c.kube, bl) + if err != nil { + return nil, errors.Wrap(err, "cannot get provider setup") + } + userUUID, _ := setup.Configuration["uuid"].(string) + token, _ := setup.Configuration["token"].(string) + apiURL, _ := setup.Configuration["api_url"].(string) + return &external{ + client: clients.NewGridscaleClient(userUUID, token, apiURL), + }, nil +} + +type external struct { + client *clients.GridscaleClient +} + +// backupListResponse models the gridscale API response for storage backups. +type backupListResponse struct { + StorageBackups []struct { + ObjectUUID string `json:"object_uuid"` + Name string `json:"name"` + Capacity float64 `json:"capacity"` + CreateTime string `json:"create_time"` + } `json:"storage_backups"` +} + +func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed.ExternalObservation, error) { + bl, ok := mg.(*v1alpha1.BackupList) + if !ok { + return managed.ExternalObservation{}, errors.New(errNotBackupList) + } + + var resp backupListResponse + path := fmt.Sprintf("/objects/storages/%s/backups", bl.Spec.ForProvider.StorageUUID) + if err := e.client.Get(ctx, path, &resp); err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, errList) + } + + entries := make([]v1alpha1.StorageBackupEntry, 0, len(resp.StorageBackups)) + for _, b := range resp.StorageBackups { + entries = append(entries, v1alpha1.StorageBackupEntry{ + ObjectUUID: b.ObjectUUID, + Name: b.Name, + Capacity: b.Capacity, + CreateTime: b.CreateTime, + }) + } + bl.Status.AtProvider.StorageBackups = entries + bl.SetConditions(xpv1.Available()) + + return managed.ExternalObservation{ + ResourceExists: true, + ResourceUpToDate: true, + }, nil +} + +func (e *external) Create(_ context.Context, _ xpresource.Managed) (managed.ExternalCreation, error) { + return managed.ExternalCreation{}, errors.New("BackupList is observe-only and does not support Create") +} + +func (e *external) Update(_ context.Context, _ xpresource.Managed) (managed.ExternalUpdate, error) { + return managed.ExternalUpdate{}, errors.New("BackupList is observe-only and does not support Update") +} + +func (e *external) Delete(_ context.Context, _ xpresource.Managed) (managed.ExternalDelete, error) { + // observe-only: nothing to delete remotely. + return managed.ExternalDelete{}, nil +} + +func (e *external) Disconnect(_ context.Context) error { + return nil +} + +// Setup adds a controller that reconciles BackupList resources. +func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { + name := managed.ControllerName(v1alpha1.BackupList_GroupVersionKind.String()) + opts := []managed.ReconcilerOption{ + managed.WithExternalConnector(&connector{ + kube: mgr.GetClient(), + setupFn: o.SetupFn, + }), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), //nolint:staticcheck // suppress until crossplane-runtime offers the new recorder api + managed.WithTimeout(1 * time.Minute), + managed.WithPollInterval(o.PollInterval), + managed.WithManagementPolicies(), + } + if o.PollJitter != 0 { + opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) + } + + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1alpha1.BackupList_GroupVersionKind), opts...) + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(xpresource.DesiredStateChanged()). + For(&v1alpha1.BackupList{}). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} + +// SetupGated registers the controller behind a CRD-existence gate. +func SetupGated(mgr ctrl.Manager, o tjcontroller.Options) error { + o.Gate.Register(func() { + if err := Setup(mgr, o); err != nil { + mgr.GetLogger().Error(err, "unable to setup reconciler", "gvk", v1alpha1.BackupList_GroupVersionKind.String()) + } + }, v1alpha1.BackupList_GroupVersionKind) + return nil +} diff --git a/internal/controller/cluster/storage/backuplist/controller_test.go b/internal/controller/cluster/storage/backuplist/controller_test.go new file mode 100644 index 0000000..913a29a --- /dev/null +++ b/internal/controller/cluster/storage/backuplist/controller_test.go @@ -0,0 +1,107 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +package backuplist + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + v1alpha1 "github.com/PlatformRelay/provider-gridscale/apis/cluster/storage/v1alpha1" + "github.com/PlatformRelay/provider-gridscale/internal/clients" +) + +func newTestClient(t *testing.T, handler http.HandlerFunc) (*clients.GridscaleClient, func()) { + t.Helper() + srv := httptest.NewServer(handler) + c := clients.NewGridscaleClient("uuid", "token", srv.URL) + return c, srv.Close +} + +func TestObserve_PopulatesBackups(t *testing.T) { + respBody := backupListResponse{ + StorageBackups: []struct { + ObjectUUID string `json:"object_uuid"` + Name string `json:"name"` + Capacity float64 `json:"capacity"` + CreateTime string `json:"create_time"` + }{ + {ObjectUUID: "abc", Name: "backup-1", Capacity: 10, CreateTime: "2024-01-01"}, + }, + } + c, cleanup := newTestClient(t, func(w http.ResponseWriter, r *http.Request) { + json.NewEncoder(w).Encode(respBody) //nolint:errcheck + }) + defer cleanup() + + ext := &external{client: c} + bl := &v1alpha1.BackupList{ + ObjectMeta: metav1.ObjectMeta{Name: "test"}, + Spec: v1alpha1.BackupListSpec{ + ForProvider: v1alpha1.BackupListParameters{StorageUUID: "storage-uuid"}, + }, + } + + obs, err := ext.Observe(context.Background(), bl) + if err != nil { + t.Fatalf("Observe error: %v", err) + } + if !obs.ResourceExists { + t.Error("ResourceExists should be true") + } + if len(bl.Status.AtProvider.StorageBackups) != 1 { + t.Fatalf("expected 1 backup, got %d", len(bl.Status.AtProvider.StorageBackups)) + } + if bl.Status.AtProvider.StorageBackups[0].ObjectUUID != "abc" { + t.Errorf("unexpected uuid: %s", bl.Status.AtProvider.StorageBackups[0].ObjectUUID) + } +} + +func TestObserve_EmptyList(t *testing.T) { + respBody := backupListResponse{} + c, cleanup := newTestClient(t, func(w http.ResponseWriter, r *http.Request) { + json.NewEncoder(w).Encode(respBody) //nolint:errcheck + }) + defer cleanup() + + ext := &external{client: c} + bl := &v1alpha1.BackupList{ + ObjectMeta: metav1.ObjectMeta{Name: "test"}, + Spec: v1alpha1.BackupListSpec{ + ForProvider: v1alpha1.BackupListParameters{StorageUUID: "storage-uuid"}, + }, + } + + obs, err := ext.Observe(context.Background(), bl) + if err != nil { + t.Fatalf("Observe error: %v", err) + } + if !obs.ResourceExists { + t.Error("ResourceExists should be true even with empty backup list") + } + if len(bl.Status.AtProvider.StorageBackups) != 0 { + t.Errorf("expected 0 backups, got %d", len(bl.Status.AtProvider.StorageBackups)) + } +} + +func TestCreate_ReturnsObserveOnlyError(t *testing.T) { + ext := &external{client: clients.NewGridscaleClient("u", "t", "http://localhost:1")} + _, err := ext.Create(context.Background(), &v1alpha1.BackupList{}) + if err == nil { + t.Fatal("Create should return observe-only error") + } +} + +func TestUpdate_ReturnsObserveOnlyError(t *testing.T) { + ext := &external{client: clients.NewGridscaleClient("u", "t", "http://localhost:1")} + _, err := ext.Update(context.Background(), &v1alpha1.BackupList{}) + if err == nil { + t.Fatal("Update should return observe-only error") + } +} diff --git a/internal/controller/namespaced/setup_custom.go b/internal/controller/namespaced/setup_custom.go new file mode 100644 index 0000000..fdad9d0 --- /dev/null +++ b/internal/controller/namespaced/setup_custom.go @@ -0,0 +1,36 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +package controller + +import ( + tjcontroller "github.com/crossplane/upjet/v2/pkg/controller" + ctrl "sigs.k8s.io/controller-runtime" + + backuplist "github.com/PlatformRelay/provider-gridscale/internal/controller/namespaced/storage/backuplist" +) + +// SetupCustom adds non-upjet controllers. +func SetupCustom(mgr ctrl.Manager, o tjcontroller.Options) error { + for _, setup := range []func(ctrl.Manager, tjcontroller.Options) error{ + backuplist.Setup, + } { + if err := setup(mgr, o); err != nil { + return err + } + } + return nil +} + +// SetupCustomGated adds non-upjet controllers with CRD gating. +func SetupCustomGated(mgr ctrl.Manager, o tjcontroller.Options) error { + for _, setup := range []func(ctrl.Manager, tjcontroller.Options) error{ + backuplist.SetupGated, + } { + if err := setup(mgr, o); err != nil { + return err + } + } + return nil +} diff --git a/internal/controller/namespaced/storage/backuplist/controller.go b/internal/controller/namespaced/storage/backuplist/controller.go new file mode 100644 index 0000000..babf2ea --- /dev/null +++ b/internal/controller/namespaced/storage/backuplist/controller.go @@ -0,0 +1,151 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +package backuplist + +import ( + "context" + "fmt" + "time" + + "github.com/pkg/errors" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + + xpv1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1" + "github.com/crossplane/crossplane-runtime/v2/pkg/event" + "github.com/crossplane/crossplane-runtime/v2/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/v2/pkg/reconciler/managed" + xpresource "github.com/crossplane/crossplane-runtime/v2/pkg/resource" + tjcontroller "github.com/crossplane/upjet/v2/pkg/controller" + "github.com/crossplane/upjet/v2/pkg/terraform" + + v1alpha1 "github.com/PlatformRelay/provider-gridscale/apis/namespaced/storage/v1alpha1" + "github.com/PlatformRelay/provider-gridscale/internal/clients" +) + +const ( + errNotBackupList = "managed resource is not a BackupList" + errList = "cannot list storage backups" +) + +type connector struct { + kube client.Client + setupFn terraform.SetupFn +} + +func (c *connector) Connect(ctx context.Context, mg xpresource.Managed) (managed.ExternalClient, error) { + bl, ok := mg.(*v1alpha1.BackupList) + if !ok { + return nil, errors.New(errNotBackupList) + } + setup, err := c.setupFn(ctx, c.kube, bl) + if err != nil { + return nil, errors.Wrap(err, "cannot get provider setup") + } + userUUID, _ := setup.Configuration["uuid"].(string) + token, _ := setup.Configuration["token"].(string) + apiURL, _ := setup.Configuration["api_url"].(string) + return &external{ + client: clients.NewGridscaleClient(userUUID, token, apiURL), + }, nil +} + +type external struct { + client *clients.GridscaleClient +} + +// backupListResponse models the gridscale API response for storage backups. +type backupListResponse struct { + StorageBackups []struct { + ObjectUUID string `json:"object_uuid"` + Name string `json:"name"` + Capacity float64 `json:"capacity"` + CreateTime string `json:"create_time"` + } `json:"storage_backups"` +} + +func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed.ExternalObservation, error) { + bl, ok := mg.(*v1alpha1.BackupList) + if !ok { + return managed.ExternalObservation{}, errors.New(errNotBackupList) + } + + var resp backupListResponse + path := fmt.Sprintf("/objects/storages/%s/backups", bl.Spec.ForProvider.StorageUUID) + if err := e.client.Get(ctx, path, &resp); err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, errList) + } + + entries := make([]v1alpha1.StorageBackupEntry, 0, len(resp.StorageBackups)) + for _, b := range resp.StorageBackups { + entries = append(entries, v1alpha1.StorageBackupEntry{ + ObjectUUID: b.ObjectUUID, + Name: b.Name, + Capacity: b.Capacity, + CreateTime: b.CreateTime, + }) + } + bl.Status.AtProvider.StorageBackups = entries + bl.SetConditions(xpv1.Available()) + + return managed.ExternalObservation{ + ResourceExists: true, + ResourceUpToDate: true, + }, nil +} + +func (e *external) Create(_ context.Context, _ xpresource.Managed) (managed.ExternalCreation, error) { + return managed.ExternalCreation{}, errors.New("BackupList is observe-only and does not support Create") +} + +func (e *external) Update(_ context.Context, _ xpresource.Managed) (managed.ExternalUpdate, error) { + return managed.ExternalUpdate{}, errors.New("BackupList is observe-only and does not support Update") +} + +func (e *external) Delete(_ context.Context, _ xpresource.Managed) (managed.ExternalDelete, error) { + // observe-only: nothing to delete remotely. + return managed.ExternalDelete{}, nil +} + +func (e *external) Disconnect(_ context.Context) error { + return nil +} + +// Setup adds a controller that reconciles BackupList resources. +func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { + name := managed.ControllerName(v1alpha1.BackupList_GroupVersionKind.String()) + opts := []managed.ReconcilerOption{ + managed.WithExternalConnector(&connector{ + kube: mgr.GetClient(), + setupFn: o.SetupFn, + }), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), //nolint:staticcheck // suppress until crossplane-runtime offers the new recorder api + managed.WithTimeout(1 * time.Minute), + managed.WithPollInterval(o.PollInterval), + managed.WithManagementPolicies(), + } + if o.PollJitter != 0 { + opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) + } + + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1alpha1.BackupList_GroupVersionKind), opts...) + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(xpresource.DesiredStateChanged()). + For(&v1alpha1.BackupList{}). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} + +// SetupGated registers the controller behind a CRD-existence gate. +func SetupGated(mgr ctrl.Manager, o tjcontroller.Options) error { + o.Gate.Register(func() { + if err := Setup(mgr, o); err != nil { + mgr.GetLogger().Error(err, "unable to setup reconciler", "gvk", v1alpha1.BackupList_GroupVersionKind.String()) + } + }, v1alpha1.BackupList_GroupVersionKind) + return nil +} diff --git a/package/crds/storage.gridscale.m.platformrelay.io_backuplists.yaml b/package/crds/storage.gridscale.m.platformrelay.io_backuplists.yaml new file mode 100644 index 0000000..47e493e --- /dev/null +++ b/package/crds/storage.gridscale.m.platformrelay.io_backuplists.yaml @@ -0,0 +1,211 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.20.1 + name: backuplists.storage.gridscale.m.platformrelay.io +spec: + group: storage.gridscale.m.platformrelay.io + names: + categories: + - crossplane + - managed + - gridscale + kind: BackupList + listKind: BackupListList + plural: backuplists + singular: backuplist + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: BackupList is the Schema for the BackupLists API. Lists storage + backups for a given storage UUID. + 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: BackupListSpec defines the desired state of BackupList. + properties: + forProvider: + description: BackupListParameters are the configurable fields of a + BackupList. + properties: + storageUUID: + description: StorageUUID is the UUID of the storage whose backups + to list. + type: string + required: + - storageUUID + type: object + managementPolicies: + default: + - '*' + description: |- + THIS IS A BETA FIELD. It is on by default but can be opted out + through a Crossplane feature flag. + ManagementPolicies specify the array of actions Crossplane is allowed to + take on the managed and external resources. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md + items: + description: |- + A ManagementAction represents an action that the Crossplane controllers + can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + providerConfigRef: + default: + kind: ClusterProviderConfig + name: default + description: |- + ProviderConfigReference specifies how the provider that will be used to + create, observe, update, and delete this managed resource should be + configured. + properties: + kind: + description: Kind of the referenced object. + type: string + name: + description: Name of the referenced object. + type: string + required: + - kind + - name + type: object + writeConnectionSecretToRef: + description: |- + WriteConnectionSecretToReference specifies the namespace and name of a + Secret to which any connection details for this managed resource should + be written. Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + properties: + name: + description: Name of the secret. + type: string + required: + - name + type: object + required: + - forProvider + type: object + status: + description: BackupListStatus defines the observed state of BackupList. + properties: + atProvider: + description: BackupListObservation are the observable fields of a + BackupList. + properties: + storageBackups: + description: StorageBackups is the list of backups for the storage. + items: + description: |- + StorageBackupEntry describes a single backup entry returned by the gridscale + storage backups API. + properties: + capacity: + type: number + createTime: + type: string + name: + type: string + objectUuid: + type: string + type: object + type: array + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: |- + LastTransitionTime is the last time this condition transitioned from one + status to another. + format: date-time + type: string + message: + description: |- + A Message containing details about this condition's last transition from + one status to another, if any. + type: string + 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 + type: integer + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: |- + Type of this condition. At most one of each condition type may apply to + a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + observedGeneration: + description: |- + ObservedGeneration is the latest metadata.generation + which resulted in either a ready state, or stalled due to error + it can not recover from without human intervention. + format: int64 + type: integer + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/package/crds/storage.gridscale.platformrelay.io_backuplists.yaml b/package/crds/storage.gridscale.platformrelay.io_backuplists.yaml new file mode 100644 index 0000000..ab9bc11 --- /dev/null +++ b/package/crds/storage.gridscale.platformrelay.io_backuplists.yaml @@ -0,0 +1,253 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.20.1 + name: backuplists.storage.gridscale.platformrelay.io +spec: + group: storage.gridscale.platformrelay.io + names: + categories: + - crossplane + - managed + - gridscale + kind: BackupList + listKind: BackupListList + plural: backuplists + singular: backuplist + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: BackupList is the Schema for the BackupLists API. Lists storage + backups for a given storage UUID. + 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: BackupListSpec defines the desired state of BackupList. + properties: + deletionPolicy: + default: Delete + description: |- + DeletionPolicy specifies what will happen to the underlying external + when this managed resource is deleted - either "Delete" or "Orphan" the + external resource. + This field is planned to be deprecated in favor of the ManagementPolicies + field in a future release. Currently, both could be set independently and + non-default values would be honored if the feature flag is enabled. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + enum: + - Orphan + - Delete + type: string + forProvider: + description: BackupListParameters are the configurable fields of a + BackupList. + properties: + storageUUID: + description: StorageUUID is the UUID of the storage whose backups + to list. + type: string + required: + - storageUUID + type: object + managementPolicies: + default: + - '*' + description: |- + THIS IS A BETA FIELD. It is on by default but can be opted out + through a Crossplane feature flag. + ManagementPolicies specify the array of actions Crossplane is allowed to + take on the managed and external resources. + This field is planned to replace the DeletionPolicy field in a future + release. Currently, both could be set independently and non-default + values would be honored if the feature flag is enabled. If both are + custom, the DeletionPolicy field will be ignored. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md + items: + description: |- + A ManagementAction represents an action that the Crossplane controllers + can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + providerConfigRef: + default: + name: default + description: |- + ProviderConfigReference specifies how the provider that will be used to + create, observe, update, and delete this managed resource should be + configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + writeConnectionSecretToRef: + description: |- + WriteConnectionSecretToReference specifies the namespace and name of a + Secret to which any connection details for this managed resource should + be written. Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + status: + description: BackupListStatus defines the observed state of BackupList. + properties: + atProvider: + description: BackupListObservation are the observable fields of a + BackupList. + properties: + storageBackups: + description: StorageBackups is the list of backups for the storage. + items: + description: |- + StorageBackupEntry describes a single backup entry returned by the gridscale + storage backups API. + properties: + capacity: + type: number + createTime: + type: string + name: + type: string + objectUuid: + type: string + type: object + type: array + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: |- + LastTransitionTime is the last time this condition transitioned from one + status to another. + format: date-time + type: string + message: + description: |- + A Message containing details about this condition's last transition from + one status to another, if any. + type: string + 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 + type: integer + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: |- + Type of this condition. At most one of each condition type may apply to + a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + observedGeneration: + description: |- + ObservedGeneration is the latest metadata.generation + which resulted in either a ready state, or stalled due to error + it can not recover from without human intervention. + format: int64 + type: integer + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {}