forked from kubernetes-sigs/cluster-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kubernetes-sigs#7 from amy/api-generate
Generate controllers and api groups
- Loading branch information
Showing
19 changed files
with
1,145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
version: "2" | ||
domain: bootstrap.cluster.sigs.k8s.io | ||
repo: sigs.k8s.io/cluster-api-bootstrap-provider-kubeadm | ||
resources: | ||
- group: kubeadm | ||
version: v1alpha1 | ||
kind: KubeadmBootstrapConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright 2019 The Kubernetes 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 kubeadm v1alpha1 API group | ||
// +kubebuilder:object:generate=true | ||
// +groupName=kubeadm.bootstrap.cluster.sigs.k8s.io | ||
package v1alpha1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects | ||
GroupVersion = schema.GroupVersion{Group: "kubeadm.bootstrap.cluster.sigs.k8s.io", Version: "v1alpha1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
Copyright 2019 The Kubernetes 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 ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
// KubeadmBootstrapConfigSpec defines the desired state of KubeadmBootstrapConfig | ||
type KubeadmBootstrapConfigSpec struct { | ||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
} | ||
|
||
// KubeadmBootstrapConfigStatus defines the observed state of KubeadmBootstrapConfig | ||
type KubeadmBootstrapConfigStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// KubeadmBootstrapConfig is the Schema for the kubeadmbootstrapconfigs API | ||
type KubeadmBootstrapConfig struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec KubeadmBootstrapConfigSpec `json:"spec,omitempty"` | ||
Status KubeadmBootstrapConfigStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// KubeadmBootstrapConfigList contains a list of KubeadmBootstrapConfig | ||
type KubeadmBootstrapConfigList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []KubeadmBootstrapConfig `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&KubeadmBootstrapConfig{}, &KubeadmBootstrapConfigList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
Copyright 2019 The Kubernetes 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/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"golang.org/x/net/context" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
// These tests are written in BDD-style using Ginkgo framework. Refer to | ||
// http://onsi.github.io/ginkgo to learn more. | ||
|
||
var _ = Describe("KubeadmBootstrapConfig", func() { | ||
var ( | ||
key types.NamespacedName | ||
created, fetched *KubeadmBootstrapConfig | ||
) | ||
|
||
BeforeEach(func() { | ||
// Add any setup steps that needs to be executed before each test | ||
}) | ||
|
||
AfterEach(func() { | ||
// Add any teardown steps that needs to be executed after each test | ||
}) | ||
|
||
// Add Tests for OpenAPI validation (or additional CRD features) specified in | ||
// your API definition. | ||
// Avoid adding tests for vanilla CRUD operations because they would | ||
// test Kubernetes API server, which isn't the goal here. | ||
Context("Create API", func() { | ||
|
||
It("should create an object successfully", func() { | ||
|
||
key = types.NamespacedName{ | ||
Name: "foo", | ||
Namespace: "default", | ||
} | ||
created = &KubeadmBootstrapConfig{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "foo", | ||
Namespace: "default", | ||
}} | ||
|
||
By("creating an API obj") | ||
Expect(k8sClient.Create(context.TODO(), created)).To(Succeed()) | ||
|
||
fetched = &KubeadmBootstrapConfig{} | ||
Expect(k8sClient.Get(context.TODO(), key, fetched)).To(Succeed()) | ||
Expect(fetched).To(Equal(created)) | ||
|
||
By("deleting the created object") | ||
Expect(k8sClient.Delete(context.TODO(), created)).To(Succeed()) | ||
Expect(k8sClient.Get(context.TODO(), key, created)).ToNot(Succeed()) | ||
}) | ||
|
||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
Copyright 2019 The Kubernetes 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 ( | ||
"path/filepath" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"k8s.io/client-go/kubernetes/scheme" | ||
"k8s.io/client-go/rest" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/envtest" | ||
logf "sigs.k8s.io/controller-runtime/pkg/log" | ||
"sigs.k8s.io/controller-runtime/pkg/log/zap" | ||
) | ||
|
||
// These tests use Ginkgo (BDD-style Go testing framework). Refer to | ||
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. | ||
|
||
var cfg *rest.Config | ||
var k8sClient client.Client | ||
var testEnv *envtest.Environment | ||
|
||
func TestAPIs(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
|
||
RunSpecsWithDefaultAndCustomReporters(t, | ||
"v1alpha1 Suite", | ||
[]Reporter{envtest.NewlineReporter{}}) | ||
} | ||
|
||
var _ = BeforeSuite(func(done Done) { | ||
logf.SetLogger(zap.LoggerTo(GinkgoWriter, true)) | ||
|
||
By("bootstrapping test environment") | ||
testEnv = &envtest.Environment{ | ||
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, | ||
} | ||
|
||
err := SchemeBuilder.AddToScheme(scheme.Scheme) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
cfg, err = testEnv.Start() | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(cfg).ToNot(BeNil()) | ||
|
||
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(k8sClient).ToNot(BeNil()) | ||
|
||
close(done) | ||
}, 60) | ||
|
||
var _ = AfterSuite(func() { | ||
By("tearing down the test environment") | ||
err := testEnv.Stop() | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// +build !ignore_autogenerated | ||
|
||
/* | ||
Copyright 2019 The Kubernetes 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. | ||
*/ | ||
|
||
// autogenerated by controller-gen object, do not modify manually | ||
|
||
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 *KubeadmBootstrapConfig) DeepCopyInto(out *KubeadmBootstrapConfig) { | ||
*out = *in | ||
out.TypeMeta = in.TypeMeta | ||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) | ||
out.Spec = in.Spec | ||
out.Status = in.Status | ||
} | ||
|
||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeadmBootstrapConfig. | ||
func (in *KubeadmBootstrapConfig) DeepCopy() *KubeadmBootstrapConfig { | ||
if in == nil { | ||
return nil | ||
} | ||
out := new(KubeadmBootstrapConfig) | ||
in.DeepCopyInto(out) | ||
return out | ||
} | ||
|
||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. | ||
func (in *KubeadmBootstrapConfig) 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 *KubeadmBootstrapConfigList) DeepCopyInto(out *KubeadmBootstrapConfigList) { | ||
*out = *in | ||
out.TypeMeta = in.TypeMeta | ||
out.ListMeta = in.ListMeta | ||
if in.Items != nil { | ||
in, out := &in.Items, &out.Items | ||
*out = make([]KubeadmBootstrapConfig, len(*in)) | ||
for i := range *in { | ||
(*in)[i].DeepCopyInto(&(*out)[i]) | ||
} | ||
} | ||
} | ||
|
||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeadmBootstrapConfigList. | ||
func (in *KubeadmBootstrapConfigList) DeepCopy() *KubeadmBootstrapConfigList { | ||
if in == nil { | ||
return nil | ||
} | ||
out := new(KubeadmBootstrapConfigList) | ||
in.DeepCopyInto(out) | ||
return out | ||
} | ||
|
||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. | ||
func (in *KubeadmBootstrapConfigList) 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 *KubeadmBootstrapConfigSpec) DeepCopyInto(out *KubeadmBootstrapConfigSpec) { | ||
*out = *in | ||
} | ||
|
||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeadmBootstrapConfigSpec. | ||
func (in *KubeadmBootstrapConfigSpec) DeepCopy() *KubeadmBootstrapConfigSpec { | ||
if in == nil { | ||
return nil | ||
} | ||
out := new(KubeadmBootstrapConfigSpec) | ||
in.DeepCopyInto(out) | ||
return out | ||
} | ||
|
||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | ||
func (in *KubeadmBootstrapConfigStatus) DeepCopyInto(out *KubeadmBootstrapConfigStatus) { | ||
*out = *in | ||
} | ||
|
||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeadmBootstrapConfigStatus. | ||
func (in *KubeadmBootstrapConfigStatus) DeepCopy() *KubeadmBootstrapConfigStatus { | ||
if in == nil { | ||
return nil | ||
} | ||
out := new(KubeadmBootstrapConfigStatus) | ||
in.DeepCopyInto(out) | ||
return out | ||
} |
Oops, something went wrong.