kubebuilderv2: migrate core apis and controllers
Signed-off-by: hasheddan <georgedanielmangum@gmail.com> Co-authored-by: Muvaffak Onus <onus.muvaffak@gmail.com> Co-authored-by: Jared Watts <jbw976@gmail.com> Co-authored-by: hasheddan <georgedanielmangum@gmail.com>
This commit is contained in:
parent
e1f86bcd40
commit
5bde15f3b4
|
|
@ -14,18 +14,35 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package database contains Kubernetes API groups for database resource claims.
|
||||
package database
|
||||
// Generate deepcopy for apis
|
||||
//go:generate go run ../vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=../hack/boilerplate.go.txt paths=./...
|
||||
|
||||
// Package apis contains Kubernetes API groups
|
||||
package apis
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/database/v1alpha1"
|
||||
"github.com/crossplaneio/crossplane/apis/cache"
|
||||
"github.com/crossplaneio/crossplane/apis/compute"
|
||||
"github.com/crossplaneio/crossplane/apis/core"
|
||||
"github.com/crossplaneio/crossplane/apis/database"
|
||||
"github.com/crossplaneio/crossplane/apis/extensions"
|
||||
"github.com/crossplaneio/crossplane/apis/storage"
|
||||
"github.com/crossplaneio/crossplane/apis/workload"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
|
||||
AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme)
|
||||
AddToSchemes = append(AddToSchemes,
|
||||
cache.AddToScheme,
|
||||
compute.AddToScheme,
|
||||
core.AddToScheme,
|
||||
extensions.AddToScheme,
|
||||
database.AddToScheme,
|
||||
storage.AddToScheme,
|
||||
workload.AddToScheme,
|
||||
)
|
||||
}
|
||||
|
||||
// AddToSchemes may be used to add all resources defined in the project to a Scheme
|
||||
|
|
@ -14,29 +14,34 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package cache contains cache API versions
|
||||
package cache
|
||||
package apis
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/cache/v1alpha1"
|
||||
)
|
||||
|
||||
func TestAddToScheme(t *testing.T) {
|
||||
s := runtime.NewScheme()
|
||||
if err := AddToScheme(s); err != nil {
|
||||
t.Errorf("AddToScheme() error = %v", err)
|
||||
type args struct {
|
||||
s *runtime.Scheme
|
||||
}
|
||||
gvs := []schema.GroupVersion{
|
||||
v1alpha1.SchemeGroupVersion,
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Test",
|
||||
args: args{s: runtime.NewScheme()},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, gv := range gvs {
|
||||
if !s.IsVersionRegistered(gv) {
|
||||
t.Errorf("AddToScheme() %v should be registered", gv)
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := AddToScheme(tt.args.s); (err != nil) != tt.wantErr {
|
||||
t.Errorf("AddToScheme() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ package core
|
|||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/core/v1alpha1"
|
||||
"github.com/crossplaneio/crossplane/apis/core/v1alpha1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -20,10 +20,10 @@ package core
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/crossplaneio/crossplane/apis/core/v1alpha1"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/core/v1alpha1"
|
||||
)
|
||||
|
||||
func TestAddToScheme(t *testing.T) {
|
||||
|
|
@ -41,7 +41,7 @@ const (
|
|||
// A BindingStatus represents the bindability and binding of a resource.
|
||||
type BindingStatus struct {
|
||||
// Phase represents the binding phase of the resource.
|
||||
// +kubebuilder:validation:Enum=Unbindable,Unbound,Bound
|
||||
// +kubebuilder:validation:Enum=Unbindable;Unbound;Bound
|
||||
Phase BindingPhase `json:"bindingPhase,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -15,5 +15,4 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
// Package v1alpha1 contains API Schema definitions for the crossplane core v1alpha1 API group
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
package v1alpha1
|
||||
|
|
@ -13,6 +13,9 @@ 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.
|
||||
*/
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=core.crossplane.io
|
||||
// +versionName=v1alpha1
|
||||
|
||||
package v1alpha1
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ const (
|
|||
ResourceCredentialsTokenKey = "token"
|
||||
)
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// ResourceClass is the Schema for the instances API
|
||||
// +kubebuilder:printcolumn:name="PROVISIONER",type="string",JSONPath=".provisioner"
|
||||
|
|
@ -86,7 +86,7 @@ func (r *ResourceClass) SetReclaimPolicy(p ReclaimPolicy) {
|
|||
r.ReclaimPolicy = p
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// ResourceClassList contains a list of resource classes.
|
||||
type ResourceClassList struct {
|
||||
|
|
@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
// autogenerated by controller-gen object, do not modify manually
|
||||
|
||||
package v1alpha1
|
||||
|
||||
|
|
@ -28,7 +28,6 @@ import (
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *BindingStatus) DeepCopyInto(out *BindingStatus) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BindingStatus.
|
||||
|
|
@ -45,7 +44,6 @@ func (in *BindingStatus) DeepCopy() *BindingStatus {
|
|||
func (in *Condition) DeepCopyInto(out *Condition) {
|
||||
*out = *in
|
||||
in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition.
|
||||
|
|
@ -68,7 +66,6 @@ func (in *ConditionedStatus) DeepCopyInto(out *ConditionedStatus) {
|
|||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionedStatus.
|
||||
|
|
@ -89,7 +86,6 @@ func (in *Policy) DeepCopyInto(out *Policy) {
|
|||
*out = new(v1.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Policy.
|
||||
|
|
@ -116,7 +112,6 @@ func (in *ResourceClaimSpec) DeepCopyInto(out *ResourceClaimSpec) {
|
|||
*out = new(v1.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClaimSpec.
|
||||
|
|
@ -134,7 +129,6 @@ func (in *ResourceClaimStatus) DeepCopyInto(out *ResourceClaimStatus) {
|
|||
*out = *in
|
||||
in.ConditionedStatus.DeepCopyInto(&out.ConditionedStatus)
|
||||
out.BindingStatus = in.BindingStatus
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClaimStatus.
|
||||
|
|
@ -164,7 +158,6 @@ func (in *ResourceClass) DeepCopyInto(out *ResourceClass) {
|
|||
*out = new(v1.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClass.
|
||||
|
|
@ -197,7 +190,6 @@ func (in *ResourceClassList) DeepCopyInto(out *ResourceClassList) {
|
|||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClassList.
|
||||
|
|
@ -226,7 +218,6 @@ func (in *ResourceClassSpecTemplate) DeepCopyInto(out *ResourceClassSpecTemplate
|
|||
*out = new(v1.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClassSpecTemplate.
|
||||
|
|
@ -258,7 +249,6 @@ func (in *ResourceSpec) DeepCopyInto(out *ResourceSpec) {
|
|||
*out = new(v1.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceSpec.
|
||||
|
|
@ -276,7 +266,6 @@ func (in *ResourceStatus) DeepCopyInto(out *ResourceStatus) {
|
|||
*out = *in
|
||||
in.ConditionedStatus.DeepCopyInto(&out.ConditionedStatus)
|
||||
out.BindingStatus = in.BindingStatus
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceStatus.
|
||||
|
|
@ -20,7 +20,7 @@ package extensions
|
|||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/extensions/v1alpha1"
|
||||
"github.com/crossplaneio/crossplane/apis/extensions/v1alpha1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -20,10 +20,10 @@ package extensions
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/crossplaneio/crossplane/apis/extensions/v1alpha1"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/extensions/v1alpha1"
|
||||
)
|
||||
|
||||
func TestAddToScheme(t *testing.T) {
|
||||
|
|
@ -15,5 +15,4 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
// Package v1alpha1 contains API Schema definitions for the crossplane extensions v1alpha1 API group
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
package v1alpha1
|
||||
|
|
@ -13,6 +13,9 @@ 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.
|
||||
*/
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=extensions.crossplane.io
|
||||
// +versionName=v1alpha1
|
||||
|
||||
package v1alpha1
|
||||
|
||||
|
|
@ -23,17 +23,17 @@ import (
|
|||
rbac "k8s.io/api/rbac/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
corev1alpha1 "github.com/crossplaneio/crossplane/pkg/apis/core/v1alpha1"
|
||||
"github.com/crossplaneio/crossplane/apis/core/v1alpha1"
|
||||
)
|
||||
|
||||
// TODO: how do we pretty print conditioned status items? There may be multiple of them, and they
|
||||
// can have varying status (e.g., True, False, Unknown)
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// ExtensionRequest is the CRD type for a request to add an extension to Crossplane.
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=="Ready")].status"
|
||||
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type==Ready)].status"
|
||||
// +kubebuilder:printcolumn:name="SOURCE",type="string",JSONPath=".spec.source"
|
||||
// +kubebuilder:printcolumn:name="PACKAGE",type="string",JSONPath=".spec.package"
|
||||
// +kubebuilder:printcolumn:name="CRD",type="string",JSONPath=".spec.crd"
|
||||
|
|
@ -46,7 +46,7 @@ type ExtensionRequest struct {
|
|||
Status ExtensionRequestStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// ExtensionRequestList contains a list of ExtensionRequest
|
||||
type ExtensionRequestList struct {
|
||||
|
|
@ -74,17 +74,17 @@ type ExtensionRequestSpec struct {
|
|||
|
||||
// ExtensionRequestStatus defines the observed state of ExtensionRequest
|
||||
type ExtensionRequestStatus struct {
|
||||
corev1alpha1.ConditionedStatus
|
||||
v1alpha1.ConditionedStatus `json:"conditionedStatus,omitempty"`
|
||||
|
||||
InstallJob *corev1.ObjectReference `json:"installJob,omitempty"`
|
||||
ExtensionRecord *corev1.ObjectReference `json:"extensionRecord,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// Extension is the CRD type for a request to add an extension to Crossplane.
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=="Ready")].status"
|
||||
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type==Ready)].status"
|
||||
// +kubebuilder:printcolumn:name="VERSION",type="string",JSONPath=".spec.version"
|
||||
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
type Extension struct {
|
||||
|
|
@ -95,7 +95,7 @@ type Extension struct {
|
|||
Status ExtensionStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// ExtensionList contains a list of Extension
|
||||
type ExtensionList struct {
|
||||
|
|
@ -114,8 +114,8 @@ type ExtensionSpec struct {
|
|||
|
||||
// ExtensionStatus defines the observed state of Extension
|
||||
type ExtensionStatus struct {
|
||||
corev1alpha1.ConditionedStatus
|
||||
ControllerRef *corev1.ObjectReference `json:"controllerRef,omitempty"`
|
||||
v1alpha1.ConditionedStatus `json:"conditionedStatus,omitempty"`
|
||||
ControllerRef *corev1.ObjectReference `json:"controllerRef,omitempty"`
|
||||
}
|
||||
|
||||
// AppMetadataSpec defines metadata about the extension application
|
||||
|
|
@ -16,14 +16,14 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
// autogenerated by controller-gen object, do not modify manually
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
|
|
@ -55,7 +55,6 @@ func (in *AppMetadataSpec) DeepCopyInto(out *AppMetadataSpec) {
|
|||
*out = make([]LinkSpec, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppMetadataSpec.
|
||||
|
|
@ -73,15 +72,14 @@ func (in *CRDList) DeepCopyInto(out *CRDList) {
|
|||
*out = *in
|
||||
if in.Owned != nil {
|
||||
in, out := &in.Owned, &out.Owned
|
||||
*out = make([]v1.TypeMeta, len(*in))
|
||||
*out = make([]metav1.TypeMeta, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.DependsOn != nil {
|
||||
in, out := &in.DependsOn, &out.DependsOn
|
||||
*out = make([]v1.TypeMeta, len(*in))
|
||||
*out = make([]metav1.TypeMeta, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CRDList.
|
||||
|
|
@ -97,7 +95,6 @@ func (in *CRDList) DeepCopy() *CRDList {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ContributorSpec) DeepCopyInto(out *ContributorSpec) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContributorSpec.
|
||||
|
|
@ -114,7 +111,6 @@ func (in *ContributorSpec) DeepCopy() *ContributorSpec {
|
|||
func (in *ControllerDeployment) DeepCopyInto(out *ControllerDeployment) {
|
||||
*out = *in
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControllerDeployment.
|
||||
|
|
@ -131,7 +127,6 @@ func (in *ControllerDeployment) DeepCopy() *ControllerDeployment {
|
|||
func (in *ControllerJob) DeepCopyInto(out *ControllerJob) {
|
||||
*out = *in
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControllerJob.
|
||||
|
|
@ -157,7 +152,6 @@ func (in *ControllerSpec) DeepCopyInto(out *ControllerSpec) {
|
|||
*out = new(ControllerJob)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControllerSpec.
|
||||
|
|
@ -177,7 +171,6 @@ func (in *Extension) DeepCopyInto(out *Extension) {
|
|||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Extension.
|
||||
|
|
@ -210,7 +203,6 @@ func (in *ExtensionList) DeepCopyInto(out *ExtensionList) {
|
|||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionList.
|
||||
|
|
@ -238,7 +230,6 @@ func (in *ExtensionRequest) DeepCopyInto(out *ExtensionRequest) {
|
|||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionRequest.
|
||||
|
|
@ -271,7 +262,6 @@ func (in *ExtensionRequestList) DeepCopyInto(out *ExtensionRequestList) {
|
|||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionRequestList.
|
||||
|
|
@ -295,7 +285,6 @@ func (in *ExtensionRequestList) DeepCopyObject() runtime.Object {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ExtensionRequestSpec) DeepCopyInto(out *ExtensionRequestSpec) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionRequestSpec.
|
||||
|
|
@ -314,15 +303,14 @@ func (in *ExtensionRequestStatus) DeepCopyInto(out *ExtensionRequestStatus) {
|
|||
in.ConditionedStatus.DeepCopyInto(&out.ConditionedStatus)
|
||||
if in.InstallJob != nil {
|
||||
in, out := &in.InstallJob, &out.InstallJob
|
||||
*out = new(corev1.ObjectReference)
|
||||
*out = new(v1.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
if in.ExtensionRecord != nil {
|
||||
in, out := &in.ExtensionRecord, &out.ExtensionRecord
|
||||
*out = new(corev1.ObjectReference)
|
||||
*out = new(v1.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionRequestStatus.
|
||||
|
|
@ -342,7 +330,6 @@ func (in *ExtensionSpec) DeepCopyInto(out *ExtensionSpec) {
|
|||
in.CRDs.DeepCopyInto(&out.CRDs)
|
||||
in.Controller.DeepCopyInto(&out.Controller)
|
||||
in.Permissions.DeepCopyInto(&out.Permissions)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionSpec.
|
||||
|
|
@ -361,10 +348,9 @@ func (in *ExtensionStatus) DeepCopyInto(out *ExtensionStatus) {
|
|||
in.ConditionedStatus.DeepCopyInto(&out.ConditionedStatus)
|
||||
if in.ControllerRef != nil {
|
||||
in, out := &in.ControllerRef, &out.ControllerRef
|
||||
*out = new(corev1.ObjectReference)
|
||||
*out = new(v1.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionStatus.
|
||||
|
|
@ -380,7 +366,6 @@ func (in *ExtensionStatus) DeepCopy() *ExtensionStatus {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IconSpec) DeepCopyInto(out *IconSpec) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IconSpec.
|
||||
|
|
@ -396,7 +381,6 @@ func (in *IconSpec) DeepCopy() *IconSpec {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LinkSpec) DeepCopyInto(out *LinkSpec) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LinkSpec.
|
||||
|
|
@ -419,7 +403,6 @@ func (in *PermissionsSpec) DeepCopyInto(out *PermissionsSpec) {
|
|||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PermissionsSpec.
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 cache contains cache API versions
|
||||
package cache
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/cache/v1alpha1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
|
||||
AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme)
|
||||
}
|
||||
|
||||
// AddToSchemes may be used to add all resources defined in the project to a Scheme
|
||||
var AddToSchemes runtime.SchemeBuilder
|
||||
|
||||
// AddToScheme adds all Resources to the Scheme
|
||||
func AddToScheme(s *runtime.Scheme) error {
|
||||
return AddToSchemes.AddToScheme(s)
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 API Schema definitions for the cache v1alpha1 API group
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
package v1alpha1
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
corev1alpha1 "github.com/crossplaneio/crossplane/pkg/apis/core/v1alpha1"
|
||||
"github.com/crossplaneio/crossplane/pkg/resource"
|
||||
)
|
||||
|
||||
// RedisClusterSpec defines the desired state of RedisCluster
|
||||
type RedisClusterSpec struct {
|
||||
corev1alpha1.ResourceClaimSpec `json:",inline"`
|
||||
|
||||
// EngineVersion specifies the desired Redis version.
|
||||
// +kubebuilder:validation:Enum=2.6,2.8,3.2,4.0,5.0
|
||||
EngineVersion string `json:"engineVersion"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// RedisCluster is the the CRD type for abstract Redis clusters. Crossplane
|
||||
// considers a single Redis instance a 'cluster' of one instance.
|
||||
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.bindingPhase"
|
||||
// +kubebuilder:printcolumn:name="CLASS",type="string",JSONPath=".spec.classRef.name"
|
||||
// +kubebuilder:printcolumn:name="VERSION",type="string",JSONPath=".spec.engineVersion"
|
||||
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
// +kubebuilder:subresource:status
|
||||
type RedisCluster struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec RedisClusterSpec `json:"spec,omitempty"`
|
||||
Status corev1alpha1.ResourceClaimStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// SetBindingPhase of this RedisCluster.
|
||||
func (rc *RedisCluster) SetBindingPhase(p corev1alpha1.BindingPhase) {
|
||||
rc.Status.SetBindingPhase(p)
|
||||
}
|
||||
|
||||
// GetBindingPhase of this RedisCluster.
|
||||
func (rc *RedisCluster) GetBindingPhase() corev1alpha1.BindingPhase {
|
||||
return rc.Status.GetBindingPhase()
|
||||
}
|
||||
|
||||
// SetConditions of this RedisCluster.
|
||||
func (rc *RedisCluster) SetConditions(c ...corev1alpha1.Condition) {
|
||||
rc.Status.SetConditions(c...)
|
||||
}
|
||||
|
||||
// SetClassReference of this RedisCluster.
|
||||
func (rc *RedisCluster) SetClassReference(r *corev1.ObjectReference) {
|
||||
rc.Spec.ClassReference = r
|
||||
}
|
||||
|
||||
// GetClassReference of this RedisCluster.
|
||||
func (rc *RedisCluster) GetClassReference() *corev1.ObjectReference {
|
||||
return rc.Spec.ClassReference
|
||||
}
|
||||
|
||||
// SetResourceReference of this RedisCluster.
|
||||
func (rc *RedisCluster) SetResourceReference(r *corev1.ObjectReference) {
|
||||
rc.Spec.ResourceReference = r
|
||||
}
|
||||
|
||||
// GetResourceReference of this RedisCluster.
|
||||
func (rc *RedisCluster) GetResourceReference() *corev1.ObjectReference {
|
||||
return rc.Spec.ResourceReference
|
||||
}
|
||||
|
||||
// SetWriteConnectionSecretToReference of this RedisCluster.
|
||||
func (rc *RedisCluster) SetWriteConnectionSecretToReference(r corev1.LocalObjectReference) {
|
||||
rc.Spec.WriteConnectionSecretToReference = r
|
||||
}
|
||||
|
||||
// GetWriteConnectionSecretToReference of this RedisCluster.
|
||||
func (rc *RedisCluster) GetWriteConnectionSecretToReference() corev1.LocalObjectReference {
|
||||
return rc.Spec.WriteConnectionSecretToReference
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// RedisClusterList contains a list of RedisCluster
|
||||
type RedisClusterList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []RedisCluster `json:"items"`
|
||||
}
|
||||
|
||||
// All policies must satisfy the Policy interface
|
||||
var _ resource.Policy = &RedisClusterPolicy{}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// RedisClusterPolicy contains a namespace-scoped policy for RedisCluster
|
||||
type RedisClusterPolicy struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
corev1alpha1.Policy `json:",inline"`
|
||||
}
|
||||
|
||||
// All policy lists must satisfy the PolicyList interface
|
||||
var _ resource.PolicyList = &RedisClusterPolicyList{}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// RedisClusterPolicyList contains a list of RedisClusterPolicy
|
||||
type RedisClusterPolicyList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []RedisClusterPolicy `json:"items"`
|
||||
}
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/core/v1alpha1"
|
||||
"github.com/crossplaneio/crossplane/pkg/resource"
|
||||
)
|
||||
|
||||
var _ resource.Claim = &RedisCluster{}
|
||||
|
||||
func TestRedisClusterStorage(t *testing.T) {
|
||||
g := gomega.NewGomegaWithT(t)
|
||||
|
||||
created := &RedisCluster{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace},
|
||||
Spec: RedisClusterSpec{
|
||||
ResourceClaimSpec: v1alpha1.ResourceClaimSpec{
|
||||
ClassReference: &corev1.ObjectReference{
|
||||
Name: "test-class",
|
||||
Namespace: "test-system",
|
||||
},
|
||||
},
|
||||
EngineVersion: "3.2",
|
||||
},
|
||||
}
|
||||
|
||||
// Test Create
|
||||
fetched := &RedisCluster{}
|
||||
g.Expect(c.Create(ctx, created)).NotTo(gomega.HaveOccurred())
|
||||
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(gomega.HaveOccurred())
|
||||
g.Expect(fetched).To(gomega.Equal(created))
|
||||
|
||||
// Test Updating the Labels
|
||||
updated := fetched.DeepCopy()
|
||||
updated.Labels = map[string]string{"hello": "world"}
|
||||
updated.Spec.ResourceReference = &corev1.ObjectReference{
|
||||
Name: "test-class",
|
||||
Namespace: "test-resource",
|
||||
}
|
||||
g.Expect(c.Update(ctx, updated)).NotTo(gomega.HaveOccurred())
|
||||
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(gomega.HaveOccurred())
|
||||
g.Expect(fetched).To(gomega.Equal(updated))
|
||||
|
||||
// Test Delete
|
||||
g.Expect(c.Delete(ctx, fetched)).NotTo(gomega.HaveOccurred())
|
||||
g.Expect(c.Get(ctx, key, fetched)).To(gomega.HaveOccurred())
|
||||
}
|
||||
|
||||
func TestEngineVersion(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
version string
|
||||
valid bool
|
||||
}{
|
||||
{
|
||||
name: "ValidVersion",
|
||||
version: "3.2",
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "InvalidVersion",
|
||||
version: "0.0",
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
name: "PatchVersionIsInvalid",
|
||||
version: "3.2.1",
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
name: "EmptyVersionIsInvalid",
|
||||
version: "",
|
||||
valid: false,
|
||||
},
|
||||
}
|
||||
|
||||
g := gomega.NewGomegaWithT(t)
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
created := &RedisCluster{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace},
|
||||
Spec: RedisClusterSpec{
|
||||
ResourceClaimSpec: v1alpha1.ResourceClaimSpec{
|
||||
ClassReference: &corev1.ObjectReference{
|
||||
Name: "test-class",
|
||||
Namespace: "test-system",
|
||||
},
|
||||
},
|
||||
EngineVersion: tc.version,
|
||||
},
|
||||
}
|
||||
|
||||
fetched := &RedisCluster{}
|
||||
|
||||
if !tc.valid {
|
||||
g.Expect(c.Create(ctx, created)).To(gomega.HaveOccurred())
|
||||
return
|
||||
}
|
||||
g.Expect(c.Create(ctx, created)).NotTo(gomega.HaveOccurred())
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(gomega.HaveOccurred())
|
||||
g.Expect(fetched).To(gomega.Equal(created))
|
||||
g.Expect(c.Delete(ctx, fetched)).NotTo(gomega.HaveOccurred())
|
||||
g.Expect(c.Get(ctx, key, fetched)).To(gomega.HaveOccurred())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
|
||||
)
|
||||
|
||||
// Package type metadata.
|
||||
const (
|
||||
Group = "cache.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}
|
||||
)
|
||||
|
||||
// RedisCluster type metadata.
|
||||
var (
|
||||
RedisClusterKind = reflect.TypeOf(RedisCluster{}).Name()
|
||||
RedisClusterKindAPIVersion = RedisClusterKind + "." + SchemeGroupVersion.String()
|
||||
RedisClusterGroupVersionKind = SchemeGroupVersion.WithKind(RedisClusterKind)
|
||||
)
|
||||
|
||||
// RedisClusterPolicy type metadata.
|
||||
var (
|
||||
RedisClusterPolicyKind = reflect.TypeOf(RedisClusterPolicy{}).Name()
|
||||
RedisClusterPolicyKindAPIVersion = RedisClusterPolicyKind + "." + SchemeGroupVersion.String()
|
||||
RedisClusterPolicyGroupVersionKind = SchemeGroupVersion.WithKind(RedisClusterPolicyKind)
|
||||
)
|
||||
|
||||
// RedisClusterPolicyList type metadata.
|
||||
var (
|
||||
RedisClusterPolicyListKind = reflect.TypeOf(RedisClusterPolicyList{}).Name()
|
||||
RedisClusterPolicyListKindAPIVersion = RedisClusterPolicyListKind + "." + SchemeGroupVersion.String()
|
||||
RedisClusterPolicyListGroupVersionKind = SchemeGroupVersion.WithKind(RedisClusterPolicyListKind)
|
||||
)
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&RedisCluster{}, &RedisClusterList{})
|
||||
SchemeBuilder.Register(&RedisClusterPolicy{}, &RedisClusterPolicyList{})
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/test"
|
||||
)
|
||||
|
||||
const (
|
||||
namespace = "default"
|
||||
name = "test-instance"
|
||||
)
|
||||
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
c client.Client
|
||||
key = types.NamespacedName{Name: name, Namespace: namespace}
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
t := test.NewEnv(namespace, SchemeBuilder.SchemeBuilder, test.CRDs())
|
||||
c = t.StartClient()
|
||||
t.StopAndExit(m.Run())
|
||||
}
|
||||
|
|
@ -1,163 +0,0 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2019 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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
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 *RedisCluster) DeepCopyInto(out *RedisCluster) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RedisCluster.
|
||||
func (in *RedisCluster) DeepCopy() *RedisCluster {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RedisCluster)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *RedisCluster) 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 *RedisClusterList) DeepCopyInto(out *RedisClusterList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]RedisCluster, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RedisClusterList.
|
||||
func (in *RedisClusterList) DeepCopy() *RedisClusterList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RedisClusterList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *RedisClusterList) 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 *RedisClusterPolicy) DeepCopyInto(out *RedisClusterPolicy) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Policy.DeepCopyInto(&out.Policy)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RedisClusterPolicy.
|
||||
func (in *RedisClusterPolicy) DeepCopy() *RedisClusterPolicy {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RedisClusterPolicy)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *RedisClusterPolicy) 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 *RedisClusterPolicyList) DeepCopyInto(out *RedisClusterPolicyList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]RedisClusterPolicy, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RedisClusterPolicyList.
|
||||
func (in *RedisClusterPolicyList) DeepCopy() *RedisClusterPolicyList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RedisClusterPolicyList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *RedisClusterPolicyList) 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 *RedisClusterSpec) DeepCopyInto(out *RedisClusterSpec) {
|
||||
*out = *in
|
||||
in.ResourceClaimSpec.DeepCopyInto(&out.ResourceClaimSpec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RedisClusterSpec.
|
||||
func (in *RedisClusterSpec) DeepCopy() *RedisClusterSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RedisClusterSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 compute contains Kubernetes API groups for cloud compute resources.
|
||||
package compute
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/compute/v1alpha1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
|
||||
AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme)
|
||||
}
|
||||
|
||||
// AddToSchemes may be used to add all resources defined in the project to a Scheme
|
||||
var AddToSchemes runtime.SchemeBuilder
|
||||
|
||||
// AddToScheme adds all Resources to the Scheme
|
||||
func AddToScheme(s *runtime.Scheme) error {
|
||||
return AddToSchemes.AddToScheme(s)
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 compute contains Kubernetes API groups for cloud compute resources.
|
||||
package compute
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/compute/v1alpha1"
|
||||
)
|
||||
|
||||
func TestAddToScheme(t *testing.T) {
|
||||
s := runtime.NewScheme()
|
||||
if err := AddToScheme(s); err != nil {
|
||||
t.Errorf("AddToScheme() error = %v", err)
|
||||
}
|
||||
gvs := []schema.GroupVersion{
|
||||
v1alpha1.SchemeGroupVersion,
|
||||
}
|
||||
for _, gv := range gvs {
|
||||
if !s.IsVersionRegistered(gv) {
|
||||
t.Errorf("AddToScheme() %v should be registered", gv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
|
||||
)
|
||||
|
||||
// Package type metadata.
|
||||
const (
|
||||
Group = "compute.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}
|
||||
)
|
||||
|
||||
// KubernetesCluster type metadata.
|
||||
var (
|
||||
KubernetesClusterKind = reflect.TypeOf(KubernetesCluster{}).Name()
|
||||
KubernetesClusterKindAPIVersion = KubernetesClusterKind + "." + SchemeGroupVersion.String()
|
||||
KubernetesClusterGroupVersionKind = SchemeGroupVersion.WithKind(KubernetesClusterKind)
|
||||
)
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&KubernetesCluster{}, &KubernetesClusterList{})
|
||||
}
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
corev1alpha1 "github.com/crossplaneio/crossplane/pkg/apis/core/v1alpha1"
|
||||
)
|
||||
|
||||
// KubernetesClusterSpec specifies the configuration of a Kubernetes cluster.
|
||||
type KubernetesClusterSpec struct {
|
||||
corev1alpha1.ResourceClaimSpec `json:",inline"`
|
||||
|
||||
// cluster properties
|
||||
ClusterVersion string `json:"clusterVersion,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// KubernetesCluster is the Schema for the instances API
|
||||
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.bindingPhase"
|
||||
// +kubebuilder:printcolumn:name="CLUSTER-CLASS",type="string",JSONPath=".spec.classRef.name"
|
||||
// +kubebuilder:printcolumn:name="CLUSTER-REF",type="string",JSONPath=".spec.resourceName.name"
|
||||
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
// +kubebuilder:subresource:status
|
||||
type KubernetesCluster struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec KubernetesClusterSpec `json:"spec,omitempty"`
|
||||
Status corev1alpha1.ResourceClaimStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// SetBindingPhase of this KubernetesCluster.
|
||||
func (kc *KubernetesCluster) SetBindingPhase(p corev1alpha1.BindingPhase) {
|
||||
kc.Status.SetBindingPhase(p)
|
||||
}
|
||||
|
||||
// GetBindingPhase of this KubernetesCluster.
|
||||
func (kc *KubernetesCluster) GetBindingPhase() corev1alpha1.BindingPhase {
|
||||
return kc.Status.GetBindingPhase()
|
||||
}
|
||||
|
||||
// SetConditions of this KubernetesCluster.
|
||||
func (kc *KubernetesCluster) SetConditions(c ...corev1alpha1.Condition) {
|
||||
kc.Status.SetConditions(c...)
|
||||
}
|
||||
|
||||
// SetClassReference of this KubernetesCluster.
|
||||
func (kc *KubernetesCluster) SetClassReference(r *corev1.ObjectReference) {
|
||||
kc.Spec.ClassReference = r
|
||||
}
|
||||
|
||||
// GetClassReference of this KubernetesCluster.
|
||||
func (kc *KubernetesCluster) GetClassReference() *corev1.ObjectReference {
|
||||
return kc.Spec.ClassReference
|
||||
}
|
||||
|
||||
// SetResourceReference of this KubernetesCluster.
|
||||
func (kc *KubernetesCluster) SetResourceReference(r *corev1.ObjectReference) {
|
||||
kc.Spec.ResourceReference = r
|
||||
}
|
||||
|
||||
// GetResourceReference of this KubernetesCluster.
|
||||
func (kc *KubernetesCluster) GetResourceReference() *corev1.ObjectReference {
|
||||
return kc.Spec.ResourceReference
|
||||
}
|
||||
|
||||
// SetWriteConnectionSecretToReference of this KubernetesCluster.
|
||||
func (kc *KubernetesCluster) SetWriteConnectionSecretToReference(r corev1.LocalObjectReference) {
|
||||
kc.Spec.WriteConnectionSecretToReference = r
|
||||
}
|
||||
|
||||
// GetWriteConnectionSecretToReference of this KubernetesCluster.
|
||||
func (kc *KubernetesCluster) GetWriteConnectionSecretToReference() corev1.LocalObjectReference {
|
||||
return kc.Spec.WriteConnectionSecretToReference
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// KubernetesClusterList contains a list of KubernetesClusters.
|
||||
type KubernetesClusterList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []KubernetesCluster `json:"items"`
|
||||
}
|
||||
|
||||
// ResourceReference is generic resource represented by the resource name and the secret name that will be generated
|
||||
// for the consumption inside the Workload.
|
||||
// TODO(negz): Remove this.
|
||||
type ResourceReference struct {
|
||||
// reference to a resource object in the same namespace
|
||||
corev1.ObjectReference `json:",inline"`
|
||||
// name of the generated resource secret
|
||||
SecretName string `json:"secretName"`
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/gomega"
|
||||
"golang.org/x/net/context"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/core/v1alpha1"
|
||||
"github.com/crossplaneio/crossplane/pkg/resource"
|
||||
"github.com/crossplaneio/crossplane/pkg/test"
|
||||
)
|
||||
|
||||
const (
|
||||
namespace = "default"
|
||||
name = "test-instance"
|
||||
)
|
||||
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
c client.Client
|
||||
|
||||
key = types.NamespacedName{Name: name, Namespace: namespace}
|
||||
)
|
||||
|
||||
var _ resource.Claim = &KubernetesCluster{}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
t := test.NewEnv(namespace, SchemeBuilder.SchemeBuilder, test.CRDs())
|
||||
c = t.StartClient()
|
||||
t.StopAndExit(m.Run())
|
||||
}
|
||||
|
||||
func TestKubernetes(t *testing.T) {
|
||||
g := NewGomegaWithT(t)
|
||||
|
||||
created := &KubernetesCluster{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace},
|
||||
Spec: KubernetesClusterSpec{
|
||||
ResourceClaimSpec: v1alpha1.ResourceClaimSpec{
|
||||
ClassReference: &corev1.ObjectReference{
|
||||
Name: "test-class",
|
||||
Namespace: "test-system",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Test Create
|
||||
fetched := &KubernetesCluster{}
|
||||
g.Expect(c.Create(ctx, created)).NotTo(HaveOccurred())
|
||||
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(fetched).To(Equal(created))
|
||||
|
||||
// Test Updating the Labels
|
||||
updated := fetched.DeepCopy()
|
||||
updated.Labels = map[string]string{"hello": "world"}
|
||||
updated.Spec.ResourceReference = &corev1.ObjectReference{
|
||||
Name: "test-class",
|
||||
Namespace: "test-resource",
|
||||
}
|
||||
g.Expect(c.Update(ctx, updated)).NotTo(HaveOccurred())
|
||||
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(fetched).To(Equal(updated))
|
||||
|
||||
// Test Delete
|
||||
g.Expect(c.Delete(ctx, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(c.Get(ctx, key, fetched)).To(HaveOccurred())
|
||||
}
|
||||
|
|
@ -1,120 +0,0 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2019 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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
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 *KubernetesCluster) DeepCopyInto(out *KubernetesCluster) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesCluster.
|
||||
func (in *KubernetesCluster) DeepCopy() *KubernetesCluster {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(KubernetesCluster)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *KubernetesCluster) 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 *KubernetesClusterList) DeepCopyInto(out *KubernetesClusterList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]KubernetesCluster, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesClusterList.
|
||||
func (in *KubernetesClusterList) DeepCopy() *KubernetesClusterList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(KubernetesClusterList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *KubernetesClusterList) 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 *KubernetesClusterSpec) DeepCopyInto(out *KubernetesClusterSpec) {
|
||||
*out = *in
|
||||
in.ResourceClaimSpec.DeepCopyInto(&out.ResourceClaimSpec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesClusterSpec.
|
||||
func (in *KubernetesClusterSpec) DeepCopy() *KubernetesClusterSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(KubernetesClusterSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ResourceReference) DeepCopyInto(out *ResourceReference) {
|
||||
*out = *in
|
||||
out.ObjectReference = in.ObjectReference
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceReference.
|
||||
func (in *ResourceReference) DeepCopy() *ResourceReference {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ResourceReference)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 API Schema definitions for the crossplane core v1alpha1 API group
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
package v1alpha1
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 storage contains Kubernetes API groups for cloud provider storage.
|
||||
package database
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/database/v1alpha1"
|
||||
)
|
||||
|
||||
func TestAddToScheme(t *testing.T) {
|
||||
s := runtime.NewScheme()
|
||||
if err := AddToScheme(s); err != nil {
|
||||
t.Errorf("AddToScheme() error = %v", err)
|
||||
}
|
||||
gvs := []schema.GroupVersion{
|
||||
v1alpha1.SchemeGroupVersion,
|
||||
}
|
||||
for _, gv := range gvs {
|
||||
if !s.IsVersionRegistered(gv) {
|
||||
t.Errorf("AddToScheme() %v should be registered", gv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 API Schema definitions for the crossplane core v1alpha1 API group
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
package v1alpha1
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
|
||||
)
|
||||
|
||||
// Package type metadata.
|
||||
const (
|
||||
Group = "database.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}
|
||||
)
|
||||
|
||||
// MySQLInstance type metadata.
|
||||
var (
|
||||
MySQLInstanceKind = reflect.TypeOf(MySQLInstance{}).Name()
|
||||
MySQLInstanceKindAPIVersion = MySQLInstanceKind + "." + SchemeGroupVersion.String()
|
||||
MySQLInstanceGroupVersionKind = SchemeGroupVersion.WithKind(MySQLInstanceKind)
|
||||
)
|
||||
|
||||
// PostgreSQLInstance type metadata.
|
||||
var (
|
||||
PostgreSQLInstanceKind = reflect.TypeOf(PostgreSQLInstance{}).Name()
|
||||
PostgreSQLInstanceKindAPIVersion = PostgreSQLInstanceKind + "." + SchemeGroupVersion.String()
|
||||
PostgreSQLInstanceGroupVersionKind = SchemeGroupVersion.WithKind(PostgreSQLInstanceKind)
|
||||
)
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&MySQLInstance{}, &MySQLInstanceList{})
|
||||
SchemeBuilder.Register(&PostgreSQLInstance{}, &PostgreSQLInstanceList{})
|
||||
}
|
||||
|
|
@ -1,183 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
corev1alpha1 "github.com/crossplaneio/crossplane/pkg/apis/core/v1alpha1"
|
||||
)
|
||||
|
||||
// MySQLInstanceSpec specifies the configuration of a MySQL instance.
|
||||
type MySQLInstanceSpec struct {
|
||||
corev1alpha1.ResourceClaimSpec `json:",inline"`
|
||||
|
||||
// mysql instance properties
|
||||
// +kubebuilder:validation:Enum=5.6,5.7
|
||||
EngineVersion string `json:"engineVersion"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// MySQLInstance is the CRD type for abstract MySQL database instances
|
||||
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.bindingPhase"
|
||||
// +kubebuilder:printcolumn:name="CLASS",type="string",JSONPath=".spec.classRef.name"
|
||||
// +kubebuilder:printcolumn:name="VERSION",type="string",JSONPath=".spec.engineVersion"
|
||||
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
// +kubebuilder:subresource:status
|
||||
type MySQLInstance struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec MySQLInstanceSpec `json:"spec,omitempty"`
|
||||
Status corev1alpha1.ResourceClaimStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// SetBindingPhase of this MySQLInstance.
|
||||
func (i *MySQLInstance) SetBindingPhase(p corev1alpha1.BindingPhase) {
|
||||
i.Status.SetBindingPhase(p)
|
||||
}
|
||||
|
||||
// GetBindingPhase of this MySQLInstance.
|
||||
func (i *MySQLInstance) GetBindingPhase() corev1alpha1.BindingPhase {
|
||||
return i.Status.GetBindingPhase()
|
||||
}
|
||||
|
||||
// SetConditions of this MySQLInstance.
|
||||
func (i *MySQLInstance) SetConditions(c ...corev1alpha1.Condition) {
|
||||
i.Status.SetConditions(c...)
|
||||
}
|
||||
|
||||
// SetClassReference of this MySQLInstance.
|
||||
func (i *MySQLInstance) SetClassReference(r *corev1.ObjectReference) {
|
||||
i.Spec.ClassReference = r
|
||||
}
|
||||
|
||||
// GetClassReference of this MySQLInstance.
|
||||
func (i *MySQLInstance) GetClassReference() *corev1.ObjectReference {
|
||||
return i.Spec.ClassReference
|
||||
}
|
||||
|
||||
// SetResourceReference of this MySQLInstance.
|
||||
func (i *MySQLInstance) SetResourceReference(r *corev1.ObjectReference) {
|
||||
i.Spec.ResourceReference = r
|
||||
}
|
||||
|
||||
// GetResourceReference of this MySQLInstance.
|
||||
func (i *MySQLInstance) GetResourceReference() *corev1.ObjectReference {
|
||||
return i.Spec.ResourceReference
|
||||
}
|
||||
|
||||
// SetWriteConnectionSecretToReference of this MySQLInstance.
|
||||
func (i *MySQLInstance) SetWriteConnectionSecretToReference(r corev1.LocalObjectReference) {
|
||||
i.Spec.WriteConnectionSecretToReference = r
|
||||
}
|
||||
|
||||
// GetWriteConnectionSecretToReference of this MySQLInstance.
|
||||
func (i *MySQLInstance) GetWriteConnectionSecretToReference() corev1.LocalObjectReference {
|
||||
return i.Spec.WriteConnectionSecretToReference
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// MySQLInstanceList contains a list of MySQLInstance
|
||||
type MySQLInstanceList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []MySQLInstance `json:"items"`
|
||||
}
|
||||
|
||||
// PostgreSQLInstanceSpec specifies the configuration of this
|
||||
// PostgreSQLInstance.
|
||||
type PostgreSQLInstanceSpec struct {
|
||||
corev1alpha1.ResourceClaimSpec `json:",inline"`
|
||||
|
||||
// postgresql instance properties
|
||||
// +kubebuilder:validation:Enum=9.6
|
||||
EngineVersion string `json:"engineVersion,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// PostgreSQLInstance is the CRD type for abstract PostgreSQL database instances
|
||||
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.bindingPhase"
|
||||
// +kubebuilder:printcolumn:name="CLASS",type="string",JSONPath=".spec.classRef.name"
|
||||
// +kubebuilder:printcolumn:name="VERSION",type="string",JSONPath=".spec.engineVersion"
|
||||
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
// +kubebuilder:subresource:status
|
||||
type PostgreSQLInstance struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec PostgreSQLInstanceSpec `json:"spec,omitempty"`
|
||||
Status corev1alpha1.ResourceClaimStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// SetBindingPhase of this PostgreSQLInstance.
|
||||
func (i *PostgreSQLInstance) SetBindingPhase(p corev1alpha1.BindingPhase) {
|
||||
i.Status.SetBindingPhase(p)
|
||||
}
|
||||
|
||||
// GetBindingPhase of this PostgreSQLInstance.
|
||||
func (i *PostgreSQLInstance) GetBindingPhase() corev1alpha1.BindingPhase {
|
||||
return i.Status.GetBindingPhase()
|
||||
}
|
||||
|
||||
// SetConditions of this PostgreSQLInstance.
|
||||
func (i *PostgreSQLInstance) SetConditions(c ...corev1alpha1.Condition) {
|
||||
i.Status.SetConditions(c...)
|
||||
}
|
||||
|
||||
// SetClassReference of this PostgreSQLInstance.
|
||||
func (i *PostgreSQLInstance) SetClassReference(r *corev1.ObjectReference) {
|
||||
i.Spec.ClassReference = r
|
||||
}
|
||||
|
||||
// GetClassReference of this PostgreSQLInstance.
|
||||
func (i *PostgreSQLInstance) GetClassReference() *corev1.ObjectReference {
|
||||
return i.Spec.ClassReference
|
||||
}
|
||||
|
||||
// SetResourceReference of this PostgreSQLInstance.
|
||||
func (i *PostgreSQLInstance) SetResourceReference(r *corev1.ObjectReference) {
|
||||
i.Spec.ResourceReference = r
|
||||
}
|
||||
|
||||
// GetResourceReference of this PostgreSQLInstance.
|
||||
func (i *PostgreSQLInstance) GetResourceReference() *corev1.ObjectReference {
|
||||
return i.Spec.ResourceReference
|
||||
}
|
||||
|
||||
// SetWriteConnectionSecretToReference of this PostgreSQLInstance.
|
||||
func (i *PostgreSQLInstance) SetWriteConnectionSecretToReference(r corev1.LocalObjectReference) {
|
||||
i.Spec.WriteConnectionSecretToReference = r
|
||||
}
|
||||
|
||||
// GetWriteConnectionSecretToReference of this PostgreSQLInstance.
|
||||
func (i *PostgreSQLInstance) GetWriteConnectionSecretToReference() corev1.LocalObjectReference {
|
||||
return i.Spec.WriteConnectionSecretToReference
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// PostgreSQLInstanceList contains a list of PostgreSQLInstance
|
||||
type PostgreSQLInstanceList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []PostgreSQLInstance `json:"items"`
|
||||
}
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/core/v1alpha1"
|
||||
"github.com/crossplaneio/crossplane/pkg/resource"
|
||||
)
|
||||
|
||||
var (
|
||||
_ resource.Claim = &MySQLInstance{}
|
||||
_ resource.Claim = &PostgreSQLInstance{}
|
||||
)
|
||||
|
||||
func TestMySQLInstanceStorage(t *testing.T) {
|
||||
g := NewGomegaWithT(t)
|
||||
|
||||
created := &MySQLInstance{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace},
|
||||
Spec: MySQLInstanceSpec{
|
||||
ResourceClaimSpec: v1alpha1.ResourceClaimSpec{
|
||||
ClassReference: &corev1.ObjectReference{
|
||||
Name: "test-class",
|
||||
Namespace: "test-system",
|
||||
},
|
||||
},
|
||||
EngineVersion: "5.6",
|
||||
},
|
||||
}
|
||||
|
||||
// Test Create
|
||||
fetched := &MySQLInstance{}
|
||||
g.Expect(c.Create(ctx, created)).NotTo(HaveOccurred())
|
||||
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(fetched).To(Equal(created))
|
||||
|
||||
// Test Updating the Labels
|
||||
updated := fetched.DeepCopy()
|
||||
updated.Labels = map[string]string{"hello": "world"}
|
||||
updated.Spec.ResourceReference = &corev1.ObjectReference{
|
||||
Name: "test-class",
|
||||
Namespace: "test-resource",
|
||||
}
|
||||
g.Expect(c.Update(ctx, updated)).NotTo(HaveOccurred())
|
||||
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(fetched).To(Equal(updated))
|
||||
|
||||
// Test Delete
|
||||
g.Expect(c.Delete(ctx, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(c.Get(ctx, key, fetched)).To(HaveOccurred())
|
||||
}
|
||||
|
||||
func TestPostgreSQLInstanceStorage(t *testing.T) {
|
||||
g := NewGomegaWithT(t)
|
||||
|
||||
key := types.NamespacedName{Name: name, Namespace: namespace}
|
||||
created := &PostgreSQLInstance{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace},
|
||||
Spec: PostgreSQLInstanceSpec{
|
||||
ResourceClaimSpec: v1alpha1.ResourceClaimSpec{
|
||||
ClassReference: &corev1.ObjectReference{
|
||||
Name: "test-class",
|
||||
Namespace: "test-system",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Test Create
|
||||
fetched := &PostgreSQLInstance{}
|
||||
g.Expect(c.Create(ctx, created)).NotTo(HaveOccurred())
|
||||
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(fetched).To(Equal(created))
|
||||
|
||||
// Test Updating the Labels
|
||||
updated := fetched.DeepCopy()
|
||||
updated.Labels = map[string]string{"hello": "world"}
|
||||
updated.Spec.ResourceReference = &corev1.ObjectReference{
|
||||
Name: "test-class",
|
||||
Namespace: "test-resource",
|
||||
}
|
||||
g.Expect(c.Update(ctx, updated)).NotTo(HaveOccurred())
|
||||
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(fetched).To(Equal(updated))
|
||||
|
||||
// Test Delete
|
||||
g.Expect(c.Delete(ctx, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(c.Get(ctx, key, fetched)).To(HaveOccurred())
|
||||
}
|
||||
|
||||
func TestEngineVersion(t *testing.T) {
|
||||
g := NewGomegaWithT(t)
|
||||
|
||||
validate := func(version string, expectedValid bool) {
|
||||
created := &MySQLInstance{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace},
|
||||
Spec: MySQLInstanceSpec{
|
||||
ResourceClaimSpec: v1alpha1.ResourceClaimSpec{
|
||||
ClassReference: &corev1.ObjectReference{
|
||||
Name: "test-class",
|
||||
Namespace: "test-system",
|
||||
},
|
||||
},
|
||||
EngineVersion: version,
|
||||
},
|
||||
}
|
||||
|
||||
fetched := &MySQLInstance{}
|
||||
|
||||
if expectedValid {
|
||||
g.Expect(c.Create(ctx, created)).NotTo(HaveOccurred())
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(fetched).To(Equal(created))
|
||||
g.Expect(c.Delete(ctx, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(c.Get(ctx, key, fetched)).To(HaveOccurred())
|
||||
} else {
|
||||
g.Expect(c.Create(ctx, created)).To(HaveOccurred())
|
||||
}
|
||||
}
|
||||
|
||||
// Test Create: valid versions
|
||||
validate("5.6", true)
|
||||
validate("5.7", true)
|
||||
|
||||
// Test Create: invalid versions
|
||||
validate("", false)
|
||||
validate("5.8", false)
|
||||
validate("5.6.40", false)
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/test"
|
||||
)
|
||||
|
||||
const (
|
||||
namespace = "default"
|
||||
name = "test-instance"
|
||||
)
|
||||
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
c client.Client
|
||||
key = types.NamespacedName{Name: name, Namespace: namespace}
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
t := test.NewEnv(namespace, SchemeBuilder.SchemeBuilder, test.CRDs())
|
||||
c = t.StartClient()
|
||||
t.StopAndExit(m.Run())
|
||||
}
|
||||
|
|
@ -1,181 +0,0 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2019 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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
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 *MySQLInstance) DeepCopyInto(out *MySQLInstance) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MySQLInstance.
|
||||
func (in *MySQLInstance) DeepCopy() *MySQLInstance {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(MySQLInstance)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *MySQLInstance) 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 *MySQLInstanceList) DeepCopyInto(out *MySQLInstanceList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]MySQLInstance, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MySQLInstanceList.
|
||||
func (in *MySQLInstanceList) DeepCopy() *MySQLInstanceList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(MySQLInstanceList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *MySQLInstanceList) 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 *MySQLInstanceSpec) DeepCopyInto(out *MySQLInstanceSpec) {
|
||||
*out = *in
|
||||
in.ResourceClaimSpec.DeepCopyInto(&out.ResourceClaimSpec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MySQLInstanceSpec.
|
||||
func (in *MySQLInstanceSpec) DeepCopy() *MySQLInstanceSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(MySQLInstanceSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PostgreSQLInstance) DeepCopyInto(out *PostgreSQLInstance) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PostgreSQLInstance.
|
||||
func (in *PostgreSQLInstance) DeepCopy() *PostgreSQLInstance {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(PostgreSQLInstance)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *PostgreSQLInstance) 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 *PostgreSQLInstanceList) DeepCopyInto(out *PostgreSQLInstanceList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]PostgreSQLInstance, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PostgreSQLInstanceList.
|
||||
func (in *PostgreSQLInstanceList) DeepCopy() *PostgreSQLInstanceList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(PostgreSQLInstanceList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *PostgreSQLInstanceList) 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 *PostgreSQLInstanceSpec) DeepCopyInto(out *PostgreSQLInstanceSpec) {
|
||||
*out = *in
|
||||
in.ResourceClaimSpec.DeepCopyInto(&out.ResourceClaimSpec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PostgreSQLInstanceSpec.
|
||||
func (in *PostgreSQLInstanceSpec) DeepCopy() *PostgreSQLInstanceSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(PostgreSQLInstanceSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 storage contains Kubernetes API groups for cloud provider storage.
|
||||
package storage
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/storage/v1alpha1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
|
||||
AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme)
|
||||
}
|
||||
|
||||
// AddToSchemes may be used to add all resources defined in the project to a Scheme
|
||||
var AddToSchemes runtime.SchemeBuilder
|
||||
|
||||
// AddToScheme adds all Resources to the Scheme
|
||||
func AddToScheme(s *runtime.Scheme) error {
|
||||
return AddToSchemes.AddToScheme(s)
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 storage contains Kubernetes API groups for cloud provider storage.
|
||||
package storage
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/storage/v1alpha1"
|
||||
)
|
||||
|
||||
func TestAddToScheme(t *testing.T) {
|
||||
s := runtime.NewScheme()
|
||||
if err := AddToScheme(s); err != nil {
|
||||
t.Errorf("AddToScheme() error = %v", err)
|
||||
}
|
||||
gvs := []schema.GroupVersion{
|
||||
v1alpha1.SchemeGroupVersion,
|
||||
}
|
||||
for _, gv := range gvs {
|
||||
if !s.IsVersionRegistered(gv) {
|
||||
t.Errorf("AddToScheme() %v should be registered", gv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 API Schema definitions for the crossplane core v1alpha1 API group
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
package v1alpha1
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
|
||||
)
|
||||
|
||||
// Package type metadata.
|
||||
const (
|
||||
Group = "storage.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}
|
||||
)
|
||||
|
||||
// Bucket type metadata.
|
||||
var (
|
||||
BucketKind = reflect.TypeOf(Bucket{}).Name()
|
||||
BucketKindAPIVersion = BucketKind + "." + SchemeGroupVersion.String()
|
||||
BucketGroupVersionKind = SchemeGroupVersion.WithKind(BucketKind)
|
||||
)
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&Bucket{}, &BucketList{})
|
||||
}
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
corev1alpha1 "github.com/crossplaneio/crossplane/pkg/apis/core/v1alpha1"
|
||||
)
|
||||
|
||||
// LocalPermissionType - Base type for LocalPermissions
|
||||
type LocalPermissionType string
|
||||
|
||||
const (
|
||||
// ReadOnlyPermission will grant read objects in a bucket
|
||||
ReadOnlyPermission LocalPermissionType = "Read"
|
||||
// WriteOnlyPermission will grant write/delete objects in a bucket
|
||||
WriteOnlyPermission LocalPermissionType = "Write"
|
||||
// ReadWritePermission LocalPermissionType Grant both read and write permissions
|
||||
ReadWritePermission LocalPermissionType = "ReadWrite"
|
||||
)
|
||||
|
||||
// PredefinedACL represents predefied bucket ACLs.
|
||||
type PredefinedACL string
|
||||
|
||||
// Predefined ACLs.
|
||||
const (
|
||||
ACLPrivate PredefinedACL = "Private"
|
||||
ACLPublicRead PredefinedACL = "PublicRead"
|
||||
ACLPublicReadWrite PredefinedACL = "PublicReadWrite"
|
||||
ACLAuthenticatedRead PredefinedACL = "AuthenticatedRead"
|
||||
)
|
||||
|
||||
// BucketSpec defines the desired state of Bucket
|
||||
type BucketSpec struct {
|
||||
corev1alpha1.ResourceClaimSpec `json:",inline"`
|
||||
|
||||
// Name properties
|
||||
// +kubebuilder:validation:MaxLength=63
|
||||
// +kubebuilder:validation:MinLength=3
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// +kubebuilder:validation:Enum=Private,PublicRead,PublicReadWrite,AuthenticatedRead
|
||||
// NOTE: AWS S3 and GCP Bucket values (not in Azure)
|
||||
PredefinedACL *PredefinedACL `json:"predefinedACL,omitempty"`
|
||||
|
||||
// LocalPermission is the permissions granted on the bucket for the provider specific
|
||||
// bucket service account that is available in a secret after provisioning.
|
||||
// +kubebuilder:validation:Enum=Read,Write,ReadWrite
|
||||
// NOTE: AWS S3 Specific value
|
||||
LocalPermission *LocalPermissionType `json:"localPermission,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// Bucket is the Schema for the Bucket API
|
||||
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.bindingPhase"
|
||||
// +kubebuilder:printcolumn:name="CLASS",type="string",JSONPath=".spec.classRef.name"
|
||||
// +kubebuilder:printcolumn:name="PREDEFINED-ACL",type="string",JSONPath=".spec.predefinedACL"
|
||||
// +kubebuilder:printcolumn:name="LOCAL-PERMISSION",type="string",JSONPath=".spec.localPermission"
|
||||
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
// +kubebuilder:subresource:status
|
||||
type Bucket struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec BucketSpec `json:"spec,omitempty"`
|
||||
Status corev1alpha1.ResourceClaimStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// SetBindingPhase of this Bucket.
|
||||
func (b *Bucket) SetBindingPhase(p corev1alpha1.BindingPhase) {
|
||||
b.Status.SetBindingPhase(p)
|
||||
}
|
||||
|
||||
// GetBindingPhase of this Bucket.
|
||||
func (b *Bucket) GetBindingPhase() corev1alpha1.BindingPhase {
|
||||
return b.Status.GetBindingPhase()
|
||||
}
|
||||
|
||||
// SetConditions of this Bucket.
|
||||
func (b *Bucket) SetConditions(c ...corev1alpha1.Condition) {
|
||||
b.Status.SetConditions(c...)
|
||||
}
|
||||
|
||||
// SetClassReference of this Bucket.
|
||||
func (b *Bucket) SetClassReference(r *corev1.ObjectReference) {
|
||||
b.Spec.ClassReference = r
|
||||
}
|
||||
|
||||
// GetClassReference of this Bucket.
|
||||
func (b *Bucket) GetClassReference() *corev1.ObjectReference {
|
||||
return b.Spec.ClassReference
|
||||
}
|
||||
|
||||
// SetResourceReference of this Bucket.
|
||||
func (b *Bucket) SetResourceReference(r *corev1.ObjectReference) {
|
||||
b.Spec.ResourceReference = r
|
||||
}
|
||||
|
||||
// GetResourceReference of this Bucket.
|
||||
func (b *Bucket) GetResourceReference() *corev1.ObjectReference {
|
||||
return b.Spec.ResourceReference
|
||||
}
|
||||
|
||||
// SetWriteConnectionSecretToReference of this Bucket.
|
||||
func (b *Bucket) SetWriteConnectionSecretToReference(r corev1.LocalObjectReference) {
|
||||
b.Spec.WriteConnectionSecretToReference = r
|
||||
}
|
||||
|
||||
// GetWriteConnectionSecretToReference of this Bucket.
|
||||
func (b *Bucket) GetWriteConnectionSecretToReference() corev1.LocalObjectReference {
|
||||
return b.Spec.WriteConnectionSecretToReference
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// BucketList contains a list of Buckets
|
||||
type BucketList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []Bucket `json:"items"`
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"github.com/crossplaneio/crossplane/pkg/resource"
|
||||
)
|
||||
|
||||
var (
|
||||
_ resource.Claim = &Bucket{}
|
||||
)
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/test"
|
||||
)
|
||||
|
||||
const (
|
||||
namespace = "default"
|
||||
)
|
||||
|
||||
var (
|
||||
c client.Client
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
t := test.NewEnv(namespace, SchemeBuilder.SchemeBuilder, test.CRDs())
|
||||
c = t.StartClient()
|
||||
t.StopAndExit(m.Run())
|
||||
}
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2019 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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
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 *Bucket) DeepCopyInto(out *Bucket) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Bucket.
|
||||
func (in *Bucket) DeepCopy() *Bucket {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Bucket)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *Bucket) 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 *BucketList) DeepCopyInto(out *BucketList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]Bucket, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BucketList.
|
||||
func (in *BucketList) DeepCopy() *BucketList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(BucketList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *BucketList) 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 *BucketSpec) DeepCopyInto(out *BucketSpec) {
|
||||
*out = *in
|
||||
in.ResourceClaimSpec.DeepCopyInto(&out.ResourceClaimSpec)
|
||||
if in.PredefinedACL != nil {
|
||||
in, out := &in.PredefinedACL, &out.PredefinedACL
|
||||
*out = new(PredefinedACL)
|
||||
**out = **in
|
||||
}
|
||||
if in.LocalPermission != nil {
|
||||
in, out := &in.LocalPermission, &out.LocalPermission
|
||||
*out = new(LocalPermissionType)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BucketSpec.
|
||||
func (in *BucketSpec) DeepCopy() *BucketSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(BucketSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 API Schema definitions for the crossplane workload
|
||||
// v1alpha1 API group.
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
package v1alpha1
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
|
||||
)
|
||||
|
||||
// Package type metadata.
|
||||
const (
|
||||
Group = "workload.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}
|
||||
)
|
||||
|
||||
// KubernetesApplication type metadata.
|
||||
var (
|
||||
KubernetesApplicationKind = reflect.TypeOf(KubernetesApplication{}).Name()
|
||||
KubernetesApplicationKindAPIVersion = KubernetesApplicationKind + "." + SchemeGroupVersion.String()
|
||||
KubernetesApplicationGroupVersionKind = SchemeGroupVersion.WithKind(KubernetesApplicationKind)
|
||||
)
|
||||
|
||||
// KubernetesApplicationResource type metadata.
|
||||
var (
|
||||
KubernetesApplicationResourceKind = reflect.TypeOf(KubernetesApplicationResource{}).Name()
|
||||
KubernetesApplicationResourceKindAPIVersion = KubernetesApplicationResourceKind + "." + SchemeGroupVersion.String()
|
||||
KubernetesApplicationResourceGroupVersionKind = SchemeGroupVersion.WithKind(KubernetesApplicationResourceKind)
|
||||
)
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&KubernetesApplication{}, &KubernetesApplicationList{})
|
||||
SchemeBuilder.Register(&KubernetesApplicationResource{}, &KubernetesApplicationResourceList{})
|
||||
}
|
||||
|
|
@ -1,219 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
|
||||
corev1alpha1 "github.com/crossplaneio/crossplane/pkg/apis/core/v1alpha1"
|
||||
)
|
||||
|
||||
// KubernetesApplicationState represents the state of a Kubernetes application.
|
||||
type KubernetesApplicationState string
|
||||
|
||||
// KubernetesApplication states.
|
||||
const (
|
||||
KubernetesApplicationStateUnknown KubernetesApplicationState = ""
|
||||
KubernetesApplicationStatePending KubernetesApplicationState = "Pending"
|
||||
KubernetesApplicationStateScheduled KubernetesApplicationState = "Scheduled"
|
||||
KubernetesApplicationStatePartial KubernetesApplicationState = "PartiallySubmitted"
|
||||
KubernetesApplicationStateSubmitted KubernetesApplicationState = "Submitted"
|
||||
KubernetesApplicationStateFailed KubernetesApplicationState = "Failed"
|
||||
)
|
||||
|
||||
// A KubernetesApplicationSpec specifies the resources of a Kubernetes
|
||||
// application.
|
||||
type KubernetesApplicationSpec struct {
|
||||
// TODO(negz): Use a validation webhook to ensure the below selectors cannot
|
||||
// be updated - only set at creation time.
|
||||
|
||||
// TODO(negz): Use a validation webhook to ensure ResourceSelector matches
|
||||
// the labels of all templated KubernetesApplicationResources.
|
||||
|
||||
// ResourceSelector selects the KubernetesApplicationResources that are
|
||||
// managed by this KubernetesApplication. Note that a KubernetesApplication
|
||||
// will never adopt orphaned KubernetesApplicationResources, and thus this
|
||||
// selector serves only to help match a KubernetesApplication to its
|
||||
// KubernetesApplicationResources.
|
||||
ResourceSelector *metav1.LabelSelector `json:"resourceSelector"`
|
||||
|
||||
// ClusterSelector selects the clusters to which this application may be
|
||||
// scheduled. Leave both match labels and expressions empty to match any
|
||||
// cluster.
|
||||
ClusterSelector *metav1.LabelSelector `json:"clusterSelector"`
|
||||
|
||||
// TODO(negz): Use a validation webhook to ensure the below templates have
|
||||
// unique names.
|
||||
|
||||
// ResourceTemplates specifies a set of Kubernetes application resources
|
||||
// managed by this application.
|
||||
ResourceTemplates []KubernetesApplicationResourceTemplate `json:"resourceTemplates"`
|
||||
}
|
||||
|
||||
// A KubernetesApplicationResourceTemplate is used to instantiate new
|
||||
// KubernetesApplicationResources.
|
||||
type KubernetesApplicationResourceTemplate struct {
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec KubernetesApplicationResourceSpec `json:"spec,omitempty"`
|
||||
}
|
||||
|
||||
// KubernetesApplicationStatus represents the status of a Kubernetes
|
||||
// application.
|
||||
type KubernetesApplicationStatus struct {
|
||||
corev1alpha1.ConditionedStatus
|
||||
|
||||
// State of the application.
|
||||
State KubernetesApplicationState `json:"state,omitempty"`
|
||||
|
||||
// Cluster to which this application has been scheduled.
|
||||
Cluster *corev1.ObjectReference `json:"clusterRef,omitempty"`
|
||||
|
||||
// Desired resources of this application, i.e. the number of resources
|
||||
// that match this application's resource selector.
|
||||
DesiredResources int `json:"desiredResources,omitempty"`
|
||||
|
||||
// Submitted resources of this workload, i.e. the subset of desired
|
||||
// resources that have been successfully submitted to their scheduled
|
||||
// Kubernetes cluster.
|
||||
SubmittedResources int `json:"submittedResources,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// A KubernetesApplication defines an application deployed by Crossplane to a
|
||||
// Kubernetes cluster that is managed by Crossplane.
|
||||
// +kubebuilder:printcolumn:name="CLUSTER",type="string",JSONPath=".status.clusterRef.name"
|
||||
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.state"
|
||||
// +kubebuilder:printcolumn:name="DESIRED",type="integer",JSONPath=".status.desiredResources"
|
||||
// +kubebuilder:printcolumn:name="SUBMITTED",type="integer",JSONPath=".status.submittedResources"
|
||||
type KubernetesApplication struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec KubernetesApplicationSpec `json:"spec,omitempty"`
|
||||
Status KubernetesApplicationStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// KubernetesApplicationList contains a list of KubernetesApplications.
|
||||
type KubernetesApplicationList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []KubernetesApplication `json:"items"`
|
||||
}
|
||||
|
||||
// KubernetesApplicationResourceState represents the state of a Kubernetes application.
|
||||
type KubernetesApplicationResourceState string
|
||||
|
||||
// KubernetesApplicationResource states.
|
||||
const (
|
||||
KubernetesApplicationResourceStateUnknown KubernetesApplicationResourceState = ""
|
||||
KubernetesApplicationResourceStatePending KubernetesApplicationResourceState = "Pending"
|
||||
KubernetesApplicationResourceStateScheduled KubernetesApplicationResourceState = "Scheduled"
|
||||
KubernetesApplicationResourceStateSubmitted KubernetesApplicationResourceState = "Submitted"
|
||||
KubernetesApplicationResourceStateFailed KubernetesApplicationResourceState = "Failed"
|
||||
)
|
||||
|
||||
// KubernetesApplicationResourceSpec specifies the configuration of a
|
||||
// Kubernetes application resource.
|
||||
type KubernetesApplicationResourceSpec struct {
|
||||
// TODO(negz): Use a validation webhook to reject updates to the template's
|
||||
// group, version, kind, namespace, and name. Changing any of these fields
|
||||
// would cause our controller to orphan any existing resource and create a
|
||||
// new one.
|
||||
|
||||
// A Template for a Kubernetes resource to be submitted to the
|
||||
// KubernetesCluster to which this application resource is scheduled. The
|
||||
// resource must be understood by the KubernetesCluster. Crossplane requires
|
||||
// only that the resource contains standard Kubernetes type and object
|
||||
// metadata.
|
||||
Template *unstructured.Unstructured `json:"template"`
|
||||
|
||||
// Secrets upon which this application resource depends. These secrets will
|
||||
// be propagated to the Kubernetes cluster to which this application is
|
||||
// scheduled.
|
||||
Secrets []corev1.LocalObjectReference `json:"secrets,omitempty"`
|
||||
}
|
||||
|
||||
// RemoteStatus represents the status of a resource in a remote Kubernetes
|
||||
// cluster. Its content is opaque to Crossplane. We wrap json.RawMessage in this
|
||||
// type in order to trick controller-tools into generating an OpenAPI spec that
|
||||
// expects RemoteStatus to be a JSON object rather than a byte array. It is not
|
||||
// currently possible to override controller-tools' type detection per
|
||||
// https://github.com/kubernetes-sigs/controller-tools/issues/155
|
||||
type RemoteStatus struct {
|
||||
// Raw JSON representation of the remote status as a byte array.
|
||||
Raw json.RawMessage
|
||||
}
|
||||
|
||||
// MarshalJSON returns the JSON encoding of the RemoteStatus.
|
||||
func (s RemoteStatus) MarshalJSON() ([]byte, error) {
|
||||
return s.Raw.MarshalJSON()
|
||||
}
|
||||
|
||||
// UnmarshalJSON sets the RemoteStatus to a copy of data.
|
||||
func (s *RemoteStatus) UnmarshalJSON(data []byte) error {
|
||||
return s.Raw.UnmarshalJSON(data)
|
||||
}
|
||||
|
||||
// KubernetesApplicationResourceStatus represents the status of a Kubernetes
|
||||
// application resource.
|
||||
type KubernetesApplicationResourceStatus struct {
|
||||
corev1alpha1.ConditionedStatus
|
||||
|
||||
// State of the application.
|
||||
State KubernetesApplicationResourceState `json:"state,omitempty"`
|
||||
|
||||
// Cluster to which this application has been scheduled.
|
||||
Cluster *corev1.ObjectReference `json:"clusterRef,omitempty"`
|
||||
|
||||
// Remote status of the resource templated by this application resource.
|
||||
Remote *RemoteStatus `json:"remote,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// A KubernetesApplicationResource is a resource of a Kubernetes application.
|
||||
// Each resource templates a single Kubernetes resource to be deployed to its
|
||||
// scheduled KubernetesCluster.
|
||||
// +kubebuilder:printcolumn:name="TEMPLATE-KIND",type="string",JSONPath=".spec.template.kind"
|
||||
// +kubebuilder:printcolumn:name="TEMPLATE-NAME",type="string",JSONPath=".spec.template.metadata.name"
|
||||
// +kubebuilder:printcolumn:name="CLUSTER",type="string",JSONPath=".status.clusterRef.name"
|
||||
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.state"
|
||||
type KubernetesApplicationResource struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec KubernetesApplicationResourceSpec `json:"spec,omitempty"`
|
||||
Status KubernetesApplicationResourceStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// KubernetesApplicationResourceList contains a list of
|
||||
// KubernetesApplicationResources.
|
||||
type KubernetesApplicationResourceList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []KubernetesApplicationResource `json:"items"`
|
||||
}
|
||||
|
|
@ -1,188 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
. "github.com/onsi/gomega"
|
||||
"golang.org/x/net/context"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/test"
|
||||
)
|
||||
|
||||
const (
|
||||
namespace = "default"
|
||||
name = "test-instance"
|
||||
)
|
||||
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
c client.Client
|
||||
|
||||
key = types.NamespacedName{Name: name, Namespace: namespace}
|
||||
labels = map[string]string{"cool": "super"}
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
t := test.NewEnv(namespace, SchemeBuilder.SchemeBuilder, test.CRDs())
|
||||
c = t.StartClient()
|
||||
t.StopAndExit(m.Run())
|
||||
}
|
||||
|
||||
func TestKubernetesApplication(t *testing.T) {
|
||||
g := NewGomegaWithT(t)
|
||||
|
||||
created := &KubernetesApplication{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: namespace,
|
||||
Name: name,
|
||||
},
|
||||
Spec: KubernetesApplicationSpec{
|
||||
ResourceSelector: &metav1.LabelSelector{MatchLabels: labels},
|
||||
ClusterSelector: &metav1.LabelSelector{},
|
||||
ResourceTemplates: []KubernetesApplicationResourceTemplate{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Labels: labels,
|
||||
},
|
||||
Spec: KubernetesApplicationResourceSpec{
|
||||
Secrets: []corev1.LocalObjectReference{{Name: name}},
|
||||
Template: resourceTemplate(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Test Create
|
||||
fetched := &KubernetesApplication{}
|
||||
g.Expect(c.Create(ctx, created)).NotTo(HaveOccurred())
|
||||
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(fetched).To(Equal(created))
|
||||
|
||||
// Test Updating the annotations
|
||||
updated := fetched.DeepCopy()
|
||||
updated.Annotations = map[string]string{"hello": "world"}
|
||||
g.Expect(c.Update(ctx, updated)).NotTo(HaveOccurred())
|
||||
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(fetched).To(Equal(updated))
|
||||
|
||||
// Test Delete
|
||||
g.Expect(c.Delete(ctx, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(c.Get(ctx, key, fetched)).To(HaveOccurred())
|
||||
}
|
||||
|
||||
func TestKubernetesApplicationResource(t *testing.T) {
|
||||
g := NewGomegaWithT(t)
|
||||
|
||||
created := &KubernetesApplicationResource{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: namespace,
|
||||
Name: name,
|
||||
Labels: labels,
|
||||
},
|
||||
Spec: KubernetesApplicationResourceSpec{
|
||||
Secrets: []corev1.LocalObjectReference{{Name: name}},
|
||||
Template: resourceTemplate(),
|
||||
},
|
||||
}
|
||||
|
||||
// Test Create
|
||||
fetched := &KubernetesApplicationResource{}
|
||||
g.Expect(c.Create(ctx, created)).NotTo(HaveOccurred())
|
||||
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(fetched).To(Equal(created))
|
||||
|
||||
// Test Updating the annotations
|
||||
updated := fetched.DeepCopy()
|
||||
updated.Annotations = map[string]string{"hello": "world"}
|
||||
g.Expect(c.Update(ctx, updated)).NotTo(HaveOccurred())
|
||||
|
||||
g.Expect(c.Get(ctx, key, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(fetched).To(Equal(updated))
|
||||
|
||||
// Test Delete
|
||||
g.Expect(c.Delete(ctx, fetched)).NotTo(HaveOccurred())
|
||||
g.Expect(c.Get(ctx, key, fetched)).To(HaveOccurred())
|
||||
}
|
||||
|
||||
func resourceTemplate() *unstructured.Unstructured {
|
||||
tmpl := &unstructured.Unstructured{}
|
||||
deploy := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Namespace: namespace, Name: name}}
|
||||
|
||||
s := runtime.NewScheme()
|
||||
appsv1.AddToScheme(s)
|
||||
s.Convert(deploy, tmpl, nil)
|
||||
|
||||
return tmpl
|
||||
}
|
||||
|
||||
func TestRemoteStatus(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
want []byte
|
||||
}{
|
||||
{
|
||||
name: "ValidJSONObject",
|
||||
want: []byte(`{"coolness":"EXTREME!"}`),
|
||||
},
|
||||
{
|
||||
name: "ValidJSONArray",
|
||||
want: []byte(`["cool","cooler","coolest"]`),
|
||||
},
|
||||
{
|
||||
name: "ValidJSONString",
|
||||
want: []byte(`"hi"`),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
rs := &RemoteStatus{}
|
||||
if err := json.Unmarshal(tc.want, rs); err != nil {
|
||||
t.Fatalf("json.Unmarshal(...): %s", err)
|
||||
}
|
||||
|
||||
if diff := cmp.Diff(string(rs.Raw), string(tc.want)); diff != "" {
|
||||
t.Errorf("json.Unmarshal(...): got != want: %s", diff)
|
||||
}
|
||||
|
||||
got, err := json.Marshal(rs)
|
||||
if err != nil {
|
||||
t.Fatalf("json.Marshal(...): %s", err)
|
||||
}
|
||||
|
||||
if diff := cmp.Diff(string(got), string(tc.want)); diff != "" {
|
||||
t.Errorf("json.Marshal(...): got != want: %s", diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1,297 +0,0 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2019 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.
|
||||
*/
|
||||
|
||||
// Code generated by main. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
json "encoding/json"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
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 *KubernetesApplication) DeepCopyInto(out *KubernetesApplication) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesApplication.
|
||||
func (in *KubernetesApplication) DeepCopy() *KubernetesApplication {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(KubernetesApplication)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *KubernetesApplication) 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 *KubernetesApplicationList) DeepCopyInto(out *KubernetesApplicationList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]KubernetesApplication, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesApplicationList.
|
||||
func (in *KubernetesApplicationList) DeepCopy() *KubernetesApplicationList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(KubernetesApplicationList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *KubernetesApplicationList) 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 *KubernetesApplicationResource) DeepCopyInto(out *KubernetesApplicationResource) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesApplicationResource.
|
||||
func (in *KubernetesApplicationResource) DeepCopy() *KubernetesApplicationResource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(KubernetesApplicationResource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *KubernetesApplicationResource) 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 *KubernetesApplicationResourceList) DeepCopyInto(out *KubernetesApplicationResourceList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]KubernetesApplicationResource, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesApplicationResourceList.
|
||||
func (in *KubernetesApplicationResourceList) DeepCopy() *KubernetesApplicationResourceList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(KubernetesApplicationResourceList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *KubernetesApplicationResourceList) 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 *KubernetesApplicationResourceSpec) DeepCopyInto(out *KubernetesApplicationResourceSpec) {
|
||||
*out = *in
|
||||
if in.Template != nil {
|
||||
in, out := &in.Template, &out.Template
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
if in.Secrets != nil {
|
||||
in, out := &in.Secrets, &out.Secrets
|
||||
*out = make([]v1.LocalObjectReference, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesApplicationResourceSpec.
|
||||
func (in *KubernetesApplicationResourceSpec) DeepCopy() *KubernetesApplicationResourceSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(KubernetesApplicationResourceSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *KubernetesApplicationResourceStatus) DeepCopyInto(out *KubernetesApplicationResourceStatus) {
|
||||
*out = *in
|
||||
in.ConditionedStatus.DeepCopyInto(&out.ConditionedStatus)
|
||||
if in.Cluster != nil {
|
||||
in, out := &in.Cluster, &out.Cluster
|
||||
*out = new(v1.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
if in.Remote != nil {
|
||||
in, out := &in.Remote, &out.Remote
|
||||
*out = new(RemoteStatus)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesApplicationResourceStatus.
|
||||
func (in *KubernetesApplicationResourceStatus) DeepCopy() *KubernetesApplicationResourceStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(KubernetesApplicationResourceStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *KubernetesApplicationResourceTemplate) DeepCopyInto(out *KubernetesApplicationResourceTemplate) {
|
||||
*out = *in
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesApplicationResourceTemplate.
|
||||
func (in *KubernetesApplicationResourceTemplate) DeepCopy() *KubernetesApplicationResourceTemplate {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(KubernetesApplicationResourceTemplate)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *KubernetesApplicationSpec) DeepCopyInto(out *KubernetesApplicationSpec) {
|
||||
*out = *in
|
||||
if in.ResourceSelector != nil {
|
||||
in, out := &in.ResourceSelector, &out.ResourceSelector
|
||||
*out = new(metav1.LabelSelector)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.ClusterSelector != nil {
|
||||
in, out := &in.ClusterSelector, &out.ClusterSelector
|
||||
*out = new(metav1.LabelSelector)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.ResourceTemplates != nil {
|
||||
in, out := &in.ResourceTemplates, &out.ResourceTemplates
|
||||
*out = make([]KubernetesApplicationResourceTemplate, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesApplicationSpec.
|
||||
func (in *KubernetesApplicationSpec) DeepCopy() *KubernetesApplicationSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(KubernetesApplicationSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *KubernetesApplicationStatus) DeepCopyInto(out *KubernetesApplicationStatus) {
|
||||
*out = *in
|
||||
in.ConditionedStatus.DeepCopyInto(&out.ConditionedStatus)
|
||||
if in.Cluster != nil {
|
||||
in, out := &in.Cluster, &out.Cluster
|
||||
*out = new(v1.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesApplicationStatus.
|
||||
func (in *KubernetesApplicationStatus) DeepCopy() *KubernetesApplicationStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(KubernetesApplicationStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RemoteStatus) DeepCopyInto(out *RemoteStatus) {
|
||||
*out = *in
|
||||
if in.Raw != nil {
|
||||
in, out := &in.Raw, &out.Raw
|
||||
*out = make(json.RawMessage, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteStatus.
|
||||
func (in *RemoteStatus) DeepCopy() *RemoteStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RemoteStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 workload contains Kubernetes API groups for cloud workload resources.
|
||||
package workload
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/workload/v1alpha1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Register the types with the Scheme so the resources can map objects to GroupVersionKinds and back
|
||||
AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme)
|
||||
}
|
||||
|
||||
// AddToSchemes may be used to add all resources defined in the project to a Scheme
|
||||
var AddToSchemes runtime.SchemeBuilder
|
||||
|
||||
// AddToScheme adds all Resources to the Scheme
|
||||
func AddToScheme(s *runtime.Scheme) error {
|
||||
return AddToSchemes.AddToScheme(s)
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
Copyright 2019 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 workload contains Kubernetes API groups for cloud workload resources.
|
||||
package workload
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"github.com/crossplaneio/crossplane/pkg/apis/workload/v1alpha1"
|
||||
)
|
||||
|
||||
func TestAddToScheme(t *testing.T) {
|
||||
s := runtime.NewScheme()
|
||||
if err := AddToScheme(s); err != nil {
|
||||
t.Errorf("AddToScheme() error = %v", err)
|
||||
}
|
||||
gvs := []schema.GroupVersion{
|
||||
v1alpha1.SchemeGroupVersion,
|
||||
}
|
||||
for _, gv := range gvs {
|
||||
if !s.IsVersionRegistered(gv) {
|
||||
t.Errorf("AddToScheme() %v should be registered", gv)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue