-
Notifications
You must be signed in to change notification settings - Fork 4
Add generic objectbucket implementation #642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| //go:build generate | ||
|
|
||
| // Remove existing manifests | ||
|
|
||
| // Generate deepcopy methodsets and CRD manifests | ||
|
|
||
| // Generate crossplane-runtime methodsets (resource.Claim, etc) | ||
| //go:generate go run -tags generate github.com/crossplane/crossplane-tools/cmd/angryjet generate-methodsets --header-file=../../.github/boilerplate.go.txt ./... | ||
|
|
||
| package s3 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| package v1 | ||
|
|
||
| import ( | ||
| "reflect" | ||
|
|
||
| xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/runtime/schema" | ||
| ) | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&Bucket{}, &BucketList{}) | ||
| } | ||
|
|
||
| const ( | ||
| // DeleteIfEmpty only deletes the bucket if the bucket is empty. | ||
| DeleteIfEmpty BucketDeletionPolicy = "DeleteIfEmpty" | ||
| // DeleteAll recursively deletes all objects in the bucket and then removes it. | ||
| DeleteAll BucketDeletionPolicy = "DeleteAll" | ||
| ) | ||
|
|
||
| // BucketDeletionPolicy determines how buckets should be deleted when a Bucket is deleted. | ||
| type BucketDeletionPolicy string | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" | ||
| // +kubebuilder:printcolumn:name="Synced",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" | ||
| // +kubebuilder:printcolumn:name="External Name",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" | ||
| // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" | ||
| // +kubebuilder:printcolumn:name="Endpoint",type="string",JSONPath=".status.endpointURL" | ||
| // +kubebuilder:printcolumn:name="Bucket Name",type="string",JSONPath=".status.atProvider.bucketName" | ||
| // +kubebuilder:printcolumn:name="Region",type="string",JSONPath=".spec.forProvider.region" | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:resource:scope=Cluster,categories={crossplane,s3} | ||
| // +kubebuilder:webhook:verbs=create;update,path=/validate-s3-crossplane-io-v1-bucket,mutating=false,failurePolicy=fail,groups=s3.crossplane.io,resources=buckets,versions=v1,name=buckets.s3.crossplane.io,sideEffects=None,admissionReviewVersions=v1 | ||
|
|
||
| type Bucket struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec BucketSpec `json:"spec"` | ||
| Status BucketStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| type BucketSpec struct { | ||
| xpv1.ResourceSpec `json:",inline"` | ||
| ForProvider BucketParameters `json:"forProvider,omitempty"` | ||
| } | ||
|
|
||
| type BucketStatus struct { | ||
| xpv1.ResourceStatus `json:",inline"` | ||
| Endpoint string `json:"endpoint,omitempty"` | ||
| EndpointURL string `json:"endpointURL,omitempty"` | ||
| AtProvider BucketProviderStatus `json:"atProvider,omitempty"` | ||
| } | ||
|
|
||
| type BucketParameters struct { | ||
| // BucketName is the name of the bucket to create. | ||
| // Defaults to `metadata.name` if unset. | ||
| // Cannot be changed after bucket is created. | ||
| // Name must be acceptable by the S3 protocol, which follows RFC 1123. | ||
| // Be aware that S3 providers may require a unique name across the platform or zone. | ||
| BucketName string `json:"bucketName,omitempty"` | ||
|
|
||
| // +kubebuilder:validation:Required | ||
| // +kubebuilder:default="us-east-1" | ||
|
|
||
| // Region is the name of the region where the bucket shall be created. | ||
| // The region must be available in the S3 endpoint. | ||
| // Cannot be changed after bucket is created. | ||
| Region string `json:"region,omitempty"` | ||
|
|
||
| // BucketDeletionPolicy determines how buckets should be deleted when Bucket is deleted. | ||
| // `DeleteIfEmpty` only deletes the bucket if the bucket is empty. | ||
| // `DeleteAll` recursively deletes all objects in the bucket and then removes it. | ||
| // To skip deletion of the bucket (orphan it) set `spec.deletionPolicy=Orphan`. | ||
| BucketDeletionPolicy BucketDeletionPolicy `json:"bucketDeletionPolicy,omitempty"` | ||
|
|
||
| // Policy is a raw S3 bucket policy. | ||
| // Please consult https://min.io/docs/minio/linux/administration/identity-access-management/policy-based-access-control.html for more details about the policy. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pointing to this intentionally?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still use the minio client internally. So it should still be valid. |
||
| Policy *string `json:"policy,omitempty"` | ||
| } | ||
|
|
||
| type BucketProviderStatus struct { | ||
| // BucketName is the name of the actual bucket. | ||
| BucketName string `json:"bucketName,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| type BucketList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []Bucket `json:"items"` | ||
| } | ||
|
|
||
| // Dummy type metadata. | ||
| var ( | ||
| BucketKind = reflect.TypeOf(Bucket{}).Name() | ||
| BucketGroupKind = schema.GroupKind{Group: Group, Kind: BucketKind}.String() | ||
| BucketKindAPIVersion = BucketKind + "." + SchemeGroupVersion.String() | ||
| BucketGroupVersionKind = SchemeGroupVersion.WithKind(BucketKind) | ||
| ) | ||
|
|
||
| // GetBucketName returns the spec.forProvider.bucketName if given, otherwise defaults to metadata.name. | ||
| func (in *Bucket) GetBucketName() string { | ||
| if in.Spec.ForProvider.BucketName == "" { | ||
| return in.Name | ||
| } | ||
| return in.Spec.ForProvider.BucketName | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // +kubebuilder:object:generate=true | ||
| // +groupName=s3.crossplane.io | ||
| // +versionName=v1 | ||
|
|
||
| // Package v1 contains the v1 group s3.crossplane.io resources of provider-s3. | ||
| package v1 | ||
|
|
||
| import ( | ||
| "k8s.io/apimachinery/pkg/runtime/schema" | ||
| "sigs.k8s.io/controller-runtime/pkg/scheme" | ||
| ) | ||
|
|
||
| // Package type metadata. | ||
| const ( | ||
| Group = "s3.crossplane.io" | ||
| Version = "v1" | ||
| ) | ||
|
|
||
| var ( | ||
| // SchemeGroupVersion is group version used to register these objects | ||
| SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version} | ||
|
|
||
| // SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
| SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} | ||
| ) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.