Skip to content
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

Added Object Store Support for Crossplane #32

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions apis/civo/objectstore/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2020 The Crossplane 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 contains the v1alpha1 group Sample resources of the Template provider.
// +kubebuilder:object:generate=true
// +groupName=objectstore.civo.crossplane.io
// +versionName=v1alpha1
package v1alpha1
34 changes: 34 additions & 0 deletions apis/civo/objectstore/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package v1alpha1

import (
"reflect"

"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

// Package type metadata.
const (
Group = "objectstore.civo.crossplane.io"
Version = "v1alpha1"
)

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}
)

// CivoObjectStore type metadata.
var (
CivoObjectStoreKind = reflect.TypeOf(CivoObjectStore{}).Name()
CivoObjectStoreGroupKind = schema.GroupKind{Group: Group, Kind: CivoObjectStoreKind}.String()
CivoObjectStoreKindAPIVersion = CivoObjectStoreKind + "." + SchemeGroupVersion.String()
CivoObjectStoreGroupVersionKind = SchemeGroupVersion.WithKind(CivoObjectStoreKind)
)

func init() {
SchemeBuilder.Register(&CivoObjectStore{}, &CivoObjectStoreList{})
}
78 changes: 78 additions & 0 deletions apis/civo/objectstore/v1alpha1/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package v1alpha1

import (
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// CivoObjectStoreObservation are the observable fields of a CivoObjectStore.
type CivoObjectStoreObservation struct {
ID string `json:"id"`
Name string `json:"name"`
MaxSize int `json:"max_size"`
BucketURL string `json:"objectstore_endpoint"`
Status string `json:"status"`
}

// CivoObjectStoreConnectionDetails is the desired output secret to store connection information
type CivoObjectStoreConnectionDetails struct {
ConnectionSecretNamePrefix string `json:"connectionSecretNamePrefix"`
ConnectionSecretNamespace string `json:"connectionSecretNamespace"`
}

// CivoObjectStoreSpec defines the spec for CivoObjectStore
type CivoObjectStoreSpec struct {
xpv1.ResourceSpec `json:",inline"`

// Name is user-given name for the object store. It should be a S3 compatible name
// +required
// +immutable
// +kubebuilder:validation:Required
Name string `json:"name"`

// +optional
// Size should be specified in GB
// +kubebuilder:default:=500
MaxSizeGB int64 `json:"maxSize,omitempty"`

// Name of the CivoObjectStore access key
// if the provided access key is found it'll be the owner
// for object store, else a new credential will be created which can be accessed via the location given in connection details
// +optional
AccessKey string `json:"accessKey,omitempty"`

// Location of the CivoObjectStore Connection
ConnectionDetails CivoObjectStoreConnectionDetails `json:"connectionDetails"`
}

// CivoObjectStoreStatus defines the status for CivoObjectStore
type CivoObjectStoreStatus struct {
xpv1.ResourceStatus `json:",inline"`
AtProvider CivoObjectStoreObservation `json:"atProvider,omitempty"`
Message string `json:"message"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName="cos"
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.atProvider.status",description="State of the Bucket"
// +kubebuilder:printcolumn:name="Bucket",type="string",JSONPath=".spec.name",description="Name of the Bucket which can be used against S3 API"
// +kubebuilder:printcolumn:name="Size",type="string",JSONPath=".spec.maxSize",description="Size of the Bucket in GB"

// CivoObjectStore is the Schema for the ObjectStore API
type CivoObjectStore struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CivoObjectStoreSpec `json:"spec,omitempty"`
Status CivoObjectStoreStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// CivoObjectStoreList contains a list of CivoObjectStore
type CivoObjectStoreList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CivoObjectStore `json:"items"`
}
149 changes: 149 additions & 0 deletions apis/civo/objectstore/v1alpha1/zz_generated.deepcopy.go

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

76 changes: 76 additions & 0 deletions apis/civo/objectstore/v1alpha1/zz_generated.managed.go

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

29 changes: 29 additions & 0 deletions apis/civo/objectstore/v1alpha1/zz_generated.managedlist.go

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

Loading