Skip to content

Commit

Permalink
Support versioning (#268)
Browse files Browse the repository at this point in the history
* Add VersioningConfiguration APIs

* Add subresource versioning

* Add versioning configuration subresource unit tests

* Add chainsaw tests cases

* Additional unit tests for updated subresources
  • Loading branch information
nolancon authored Jun 28, 2024
1 parent a6bfca7 commit 8bfc09c
Show file tree
Hide file tree
Showing 18 changed files with 1,924 additions and 34 deletions.
12 changes: 12 additions & 0 deletions apis/provider-ceph/v1alpha1/bucket_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ type BucketParameters struct {
// +optional
LifecycleConfiguration *BucketLifecycleConfiguration `json:"lifecycleConfiguration,omitempty"`

// VersioningConfiguration describes the desired versioning state of an S3 bucket.
// See the API reference guide for PutBucketVersioning for usage and error information.
// See also, https://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/PutBucketVersioning
// +optional
VersioningConfiguration *VersioningConfiguration `json:"versioningConfiguration,omitempty"`

// AssumeRoleTags may be used to add custom values to an AssumeRole request.
// +optional
AssumeRoleTags []Tag `json:"assumeRoleTags,omitempty"`
Expand All @@ -98,10 +104,16 @@ type BucketParameters struct {
type BackendInfo struct {
// BucketCondition is the condition of the Bucket on the S3 backend.
BucketCondition xpv1.Condition `json:"bucketCondition,omitempty"`
// +optional
// LifecycleConfigurationCondition is the condition of the bucket lifecycle
// configuration on the S3 backend. Use a pointer to allow nil value when
// there is no lifecycle configuration.
LifecycleConfigurationCondition *xpv1.Condition `json:"lifecycleConfigurationCondition,omitempty"`
// +optional
// VersioningConfigurationCondition is the condition of the versioning
// configuration on the S3 backend. Use a pointer to allow nil value when
// there is no versioning configuration.
VersioningConfigurationCondition *xpv1.Condition `json:"versioningConfigurationCondition,omitempty"`
}

// Backends is a map of the names of the S3 backends to BackendInfo.
Expand Down
28 changes: 28 additions & 0 deletions apis/provider-ceph/v1alpha1/versioningconfiguration_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package v1alpha1

type VersioningStatus string

const (
VersioningStatusEnabled VersioningStatus = "Enabled"
VersioningStatusSuspended VersioningStatus = "Suspended"
)

type MFADelete string

const (
MFADeleteEnabled MFADelete = "Enabled"
MFADeleteDisabled MFADelete = "Disabled"
)

// VersioningConfiguration describes the versioning state of an S3 bucket.
type VersioningConfiguration struct {
// MFADelete specifies whether MFA delete is enabled in the bucket versioning configuration.
// This element is only returned if the bucket has been configured with MFA
// delete. If the bucket has never been so configured, this element is not returned.
// +kubebuilder:validation:Enum=Enabled;Disabled
MFADelete *MFADelete `json:"mfaDelete,omitempty"`

// Status is the desired versioning state of the bucket.
// +kubebuilder:validation:Enum=Enabled;Suspended
Status *VersioningStatus `json:"status,omitempty"`
}
35 changes: 35 additions & 0 deletions apis/provider-ceph/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions e2e/tests/ceph/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ spec:
- $CEPH_ADDRESS
entrypoint: ../../../hack/expect_bucket.sh

- name: Apply lifecycle configuration to test-bucket.
- name: Apply lifecycle configuration and versioning configuration to test-bucket.
try:
- apply:
resource:
Expand All @@ -147,6 +147,8 @@ spec:
providers:
- ceph-cluster
forProvider:
versioningConfiguration:
status: "Enabled"
lifecycleConfiguration:
# Example rules from https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-configuration-examples.html
rules:
Expand Down Expand Up @@ -195,6 +197,10 @@ spec:
reason: Available
status: "True"
type: Ready
versioningConfigurationCondition:
reason: Available
status: "True"
type: Ready
conditions:
- reason: Available
status: "True"
Expand All @@ -203,7 +209,7 @@ spec:
status: "True"
type: Synced

- name: Disable lifecycle configuration on test-bucket.
- name: Disable lifecycle configuration and remove versioning configuration on test-bucket.
try:
- apply:
resource:
Expand All @@ -218,6 +224,7 @@ spec:
- ceph-cluster
lifecycleConfigurationDisabled: true
forProvider:
versioningConfiguration:
lifecycleConfiguration:
# Example rules https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-configuration-examples.html
rules:
Expand Down Expand Up @@ -262,6 +269,10 @@ spec:
reason: Available
status: "True"
type: Ready
versioningConfigurationCondition:
reason: Available
status: "True"
type: Ready
conditions:
- reason: Available
status: "True"
Expand Down
Loading

0 comments on commit 8bfc09c

Please sign in to comment.