Make API compatible with k8s apimachinary
Each object must implement runtime.Object interface. Therefore we need DeepCopy methods implemented for each API struct. Implementation is generated by controller-get utility. Relates-To: #259 Change-Id: I535bf9ec3ff61597a778f73ca449313b7455b989
This commit is contained in:
parent
f1471d1189
commit
cad8177fee
4
Makefile
4
Makefile
@ -33,6 +33,7 @@ TESTS ?= .
|
|||||||
TEST_FLAGS ?=
|
TEST_FLAGS ?=
|
||||||
COVER_FLAGS ?=
|
COVER_FLAGS ?=
|
||||||
COVER_PROFILE ?= cover.out
|
COVER_PROFILE ?= cover.out
|
||||||
|
COVER_EXCLUDE ?= (zz_generated)
|
||||||
|
|
||||||
# proxy options
|
# proxy options
|
||||||
PROXY ?= http://proxy.foo.com:8000
|
PROXY ?= http://proxy.foo.com:8000
|
||||||
@ -77,8 +78,9 @@ unit-tests:
|
|||||||
@echo "All unit tests passed"
|
@echo "All unit tests passed"
|
||||||
|
|
||||||
.PHONY: cover
|
.PHONY: cover
|
||||||
cover: COVER_FLAGS = -covermode=atomic -coverprofile=$(COVER_PROFILE)
|
cover: COVER_FLAGS = -covermode=atomic -coverprofile=fullcover.out
|
||||||
cover: unit-tests
|
cover: unit-tests
|
||||||
|
@grep -vE "$(COVER_EXCLUDE)" fullcover.out > $(COVER_PROFILE)
|
||||||
@./tools/coverage_check $(COVER_PROFILE)
|
@./tools/coverage_check $(COVER_PROFILE)
|
||||||
|
|
||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
|
@ -20,13 +20,13 @@ import (
|
|||||||
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
|
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO (kkalynovskyi) add generators for deepcopy methods, so we can use kubernetes schema
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// GroupVersionKind is group version used to register these objects
|
// GroupVersionKind is group version used to register these objects
|
||||||
GroupVersionKind = schema.GroupVersionKind{Group: "airshipit.org", Version: "v1alpha1", Kind: "Clusterctl"}
|
GroupVersionKind = schema.GroupVersionKind{Group: "airshipit.org", Version: "v1alpha1", Kind: "Clusterctl"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// +kubebuilder:object:root=true
|
||||||
|
|
||||||
// Clusterctl provides information about clusterctl components
|
// Clusterctl provides information about clusterctl components
|
||||||
type Clusterctl struct {
|
type Clusterctl struct {
|
||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
|
45
pkg/api/v1alpha1/groupversion_info.go
Normal file
45
pkg/api/v1alpha1/groupversion_info.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
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
|
||||||
|
|
||||||
|
https://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 airshipctl
|
||||||
|
// +kubebuilder:object:generate=true
|
||||||
|
// +groupName=airshipit.org
|
||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/scheme"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// GroupVersion is group version used to register objects
|
||||||
|
GroupVersion = schema.GroupVersion{Group: "airshipit.org", 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
|
||||||
|
|
||||||
|
// Scheme contains mappings from Gvk to Go API
|
||||||
|
Scheme *runtime.Scheme
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Scheme = runtime.NewScheme()
|
||||||
|
// NOTE add all api objects to scheme here
|
||||||
|
SchemeBuilder.Register(&Clusterctl{})
|
||||||
|
_ = AddToScheme(Scheme) //nolint:errcheck
|
||||||
|
}
|
122
pkg/api/v1alpha1/zz_generated.deepcopy.go
Normal file
122
pkg/api/v1alpha1/zz_generated.deepcopy.go
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
|
// Code generated by controller-gen. 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 *Clusterctl) DeepCopyInto(out *Clusterctl) {
|
||||||
|
*out = *in
|
||||||
|
out.TypeMeta = in.TypeMeta
|
||||||
|
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||||
|
if in.Providers != nil {
|
||||||
|
in, out := &in.Providers, &out.Providers
|
||||||
|
*out = make([]*Provider, len(*in))
|
||||||
|
for i := range *in {
|
||||||
|
if (*in)[i] != nil {
|
||||||
|
in, out := &(*in)[i], &(*out)[i]
|
||||||
|
*out = new(Provider)
|
||||||
|
(*in).DeepCopyInto(*out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if in.InitOptions != nil {
|
||||||
|
in, out := &in.InitOptions, &out.InitOptions
|
||||||
|
*out = new(InitOptions)
|
||||||
|
(*in).DeepCopyInto(*out)
|
||||||
|
}
|
||||||
|
if in.MoveOptions != nil {
|
||||||
|
in, out := &in.MoveOptions, &out.MoveOptions
|
||||||
|
*out = new(MoveOptions)
|
||||||
|
**out = **in
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Clusterctl.
|
||||||
|
func (in *Clusterctl) DeepCopy() *Clusterctl {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(Clusterctl)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||||
|
func (in *Clusterctl) 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 *InitOptions) DeepCopyInto(out *InitOptions) {
|
||||||
|
*out = *in
|
||||||
|
if in.BootstrapProviders != nil {
|
||||||
|
in, out := &in.BootstrapProviders, &out.BootstrapProviders
|
||||||
|
*out = make([]string, len(*in))
|
||||||
|
copy(*out, *in)
|
||||||
|
}
|
||||||
|
if in.InfrastructureProviders != nil {
|
||||||
|
in, out := &in.InfrastructureProviders, &out.InfrastructureProviders
|
||||||
|
*out = make([]string, len(*in))
|
||||||
|
copy(*out, *in)
|
||||||
|
}
|
||||||
|
if in.ControlPlaneProviders != nil {
|
||||||
|
in, out := &in.ControlPlaneProviders, &out.ControlPlaneProviders
|
||||||
|
*out = make([]string, len(*in))
|
||||||
|
copy(*out, *in)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InitOptions.
|
||||||
|
func (in *InitOptions) DeepCopy() *InitOptions {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(InitOptions)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *MoveOptions) DeepCopyInto(out *MoveOptions) {
|
||||||
|
*out = *in
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MoveOptions.
|
||||||
|
func (in *MoveOptions) DeepCopy() *MoveOptions {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(MoveOptions)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *Provider) DeepCopyInto(out *Provider) {
|
||||||
|
*out = *in
|
||||||
|
if in.Versions != nil {
|
||||||
|
in, out := &in.Versions, &out.Versions
|
||||||
|
*out = make(map[string]string, len(*in))
|
||||||
|
for key, val := range *in {
|
||||||
|
(*out)[key] = val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Provider.
|
||||||
|
func (in *Provider) DeepCopy() *Provider {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(Provider)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
@ -18,7 +18,7 @@ declare FILES_MISSING_COPYRIGHT=()
|
|||||||
check_license() {
|
check_license() {
|
||||||
ext=$1
|
ext=$1
|
||||||
# skipping license for testdata and manifests folders
|
# skipping license for testdata and manifests folders
|
||||||
FILES=$(find -L . -name "*.${ext}" | grep -v "testdata" | grep -v "manifests")
|
FILES=$(find -L . -name "*.${ext}" | grep -vE "(testdata|manifests|zz_generated)")
|
||||||
|
|
||||||
for each in $FILES
|
for each in $FILES
|
||||||
do
|
do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user