Add v2 version to testgroup API

Signed-off-by: James Munnelly <james@munnelly.eu>
This commit is contained in:
James Munnelly
2019-10-24 19:41:55 +01:00
parent 5312cfc508
commit 0209686ed7
14 changed files with 401 additions and 1 deletions
+3
View File
@@ -41,6 +41,7 @@ deepcopy_inputs=(
pkg/internal/apis/acme \
pkg/apis/meta/v1 \
pkg/internal/apis/meta \
pkg/webhook/handlers/testdata/apis/testgroup/v2 \
pkg/webhook/handlers/testdata/apis/testgroup/v1 \
pkg/webhook/handlers/testdata/apis/testgroup \
pkg/acme/webhook/apis/acme/v1alpha1 \
@@ -59,6 +60,7 @@ defaulter_inputs=(
pkg/internal/apis/certmanager/v1alpha2 \
pkg/internal/apis/acme/v1alpha2 \
pkg/internal/apis/meta/v1 \
pkg/webhook/handlers/testdata/apis/testgroup/v2 \
pkg/webhook/handlers/testdata/apis/testgroup/v1 \
)
@@ -67,6 +69,7 @@ conversion_inputs=(
pkg/internal/apis/certmanager/v1alpha2 \
pkg/internal/apis/acme/v1alpha2 \
pkg/internal/apis/meta/v1 \
pkg/webhook/handlers/testdata/apis/testgroup/v2 \
pkg/webhook/handlers/testdata/apis/testgroup/v1 \
)
@@ -31,6 +31,7 @@ filegroup(
"//pkg/webhook/handlers/testdata/apis/testgroup/fuzzer:all-srcs",
"//pkg/webhook/handlers/testdata/apis/testgroup/install:all-srcs",
"//pkg/webhook/handlers/testdata/apis/testgroup/v1:all-srcs",
"//pkg/webhook/handlers/testdata/apis/testgroup/v2:all-srcs",
"//pkg/webhook/handlers/testdata/apis/testgroup/validation:all-srcs",
],
tags = ["automanaged"],
@@ -8,6 +8,7 @@ go_library(
deps = [
"//pkg/webhook/handlers/testdata/apis/testgroup:go_default_library",
"//pkg/webhook/handlers/testdata/apis/testgroup/v1:go_default_library",
"//pkg/webhook/handlers/testdata/apis/testgroup/v2:go_default_library",
"@io_k8s_apimachinery//pkg/runtime:go_default_library",
"@io_k8s_apimachinery//pkg/util/runtime:go_default_library",
],
@@ -24,10 +24,12 @@ import (
"github.com/jetstack/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup"
"github.com/jetstack/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/v1"
"github.com/jetstack/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/v2"
)
// Install registers the API group and adds types to a scheme
func Install(scheme *runtime.Scheme) {
utilruntime.Must(testgroup.AddToScheme(scheme))
utilruntime.Must(v1.AddToScheme(scheme))
utilruntime.Must(v2.AddToScheme(scheme))
}
+1 -1
View File
@@ -29,7 +29,7 @@ type TestType struct {
// TestField is used in tests.
// Validation doesn't allow this to be set to the value of TestFieldValueNotAllowed.
TestField string `json:"testField"`
TestFieldPtr *string `json:"testFieldPtr"`
TestFieldPtr *string `json:"testFieldPtr,omitempty"`
// TestFieldImmutable cannot be changed after being set to a non-zero value
TestFieldImmutable string `json:"testFieldImmutable"`
@@ -0,0 +1,39 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"convert.go",
"defaults.go",
"doc.go",
"register.go",
"types.go",
"zz_generated.conversion.go",
"zz_generated.deepcopy.go",
"zz_generated.defaults.go",
],
importpath = "github.com/jetstack/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/v2",
visibility = ["//visibility:public"],
deps = [
"//pkg/webhook/handlers/testdata/apis/testgroup:go_default_library",
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
"@io_k8s_apimachinery//pkg/conversion:go_default_library",
"@io_k8s_apimachinery//pkg/runtime:go_default_library",
"@io_k8s_apimachinery//pkg/runtime/schema:go_default_library",
"@io_k8s_utils//pointer:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
@@ -0,0 +1,41 @@
/*
Copyright 2019 The Jetstack cert-manager contributors.
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 v2
import (
"unsafe"
"k8s.io/apimachinery/pkg/conversion"
"github.com/jetstack/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup"
)
func Convert_v2_TestType_To_testgroup_TestType(in *TestType, out *testgroup.TestType, s conversion.Scope) error {
if err := autoConvert_v2_TestType_To_testgroup_TestType(in, out, s); err != nil {
return err
}
out.TestFieldPtr = (*string)(unsafe.Pointer(in.TestFieldPtrAlt))
return nil
}
func Convert_testgroup_TestType_To_v2_TestType(in *testgroup.TestType, out *TestType, s conversion.Scope) error {
if err := autoConvert_testgroup_TestType_To_v2_TestType(in, out, s); err != nil {
return err
}
out.TestFieldPtrAlt = (*string)(unsafe.Pointer(in.TestFieldPtr))
return nil
}
@@ -0,0 +1,32 @@
/*
Copyright 2019 The Jetstack cert-manager contributors.
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 v2
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
)
func addDefaultingFuncs(scheme *runtime.Scheme) error {
return RegisterDefaults(scheme)
}
func SetDefaults_TestType(obj *TestType) {
if obj.TestFieldPtrAlt == nil {
obj.TestFieldPtrAlt = pointer.StringPtr("teststr")
}
}
+22
View File
@@ -0,0 +1,22 @@
/*
Copyright 2019 The Jetstack cert-manager contributors.
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.
*/
// +k8s:conversion-gen=github.com/jetstack/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup
// +k8s:deepcopy-gen=package,register
// +k8s:defaulter-gen=TypeMeta
// +groupName=testgroup.testing.cert-manager.io
package v2
@@ -0,0 +1,55 @@
/*
Copyright 2019 The Jetstack cert-manager contributors.
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 v2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/jetstack/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup"
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: testgroup.GroupName, Version: "v2"}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
SchemeBuilder runtime.SchemeBuilder
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)
func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs)
}
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&TestType{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
@@ -0,0 +1,38 @@
/*
Copyright 2019 The Jetstack cert-manager contributors.
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 v2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// TestType in v2 is identical to v1, except TestFieldPtr has been renamed to TestFieldPtrAlt
type TestType struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
// TestField is used in tests.
// Validation doesn't allow this to be set to the value of TestFieldValueNotAllowed.
TestField string `json:"testField"`
// +optional
TestFieldPtrAlt *string `json:"testFieldPtrAlt,omitempty"`
// TestFieldImmutable cannot be changed after being set to a non-zero value
TestFieldImmutable string `json:"testFieldImmutable"`
}
@@ -0,0 +1,73 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Jetstack cert-manager contributors.
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 conversion-gen. DO NOT EDIT.
package v2
import (
testgroup "github.com/jetstack/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
)
func init() {
localSchemeBuilder.Register(RegisterConversions)
}
// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func RegisterConversions(s *runtime.Scheme) error {
if err := s.AddGeneratedConversionFunc((*TestType)(nil), (*testgroup.TestType)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v2_TestType_To_testgroup_TestType(a.(*TestType), b.(*testgroup.TestType), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*testgroup.TestType)(nil), (*TestType)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_testgroup_TestType_To_v2_TestType(a.(*testgroup.TestType), b.(*TestType), scope)
}); err != nil {
return err
}
if err := s.AddConversionFunc((*testgroup.TestType)(nil), (*TestType)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_testgroup_TestType_To_v2_TestType(a.(*testgroup.TestType), b.(*TestType), scope)
}); err != nil {
return err
}
if err := s.AddConversionFunc((*TestType)(nil), (*testgroup.TestType)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v2_TestType_To_testgroup_TestType(a.(*TestType), b.(*testgroup.TestType), scope)
}); err != nil {
return err
}
return nil
}
func autoConvert_v2_TestType_To_testgroup_TestType(in *TestType, out *testgroup.TestType, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.TestField = in.TestField
// WARNING: in.TestFieldPtrAlt requires manual conversion: does not exist in peer-type
out.TestFieldImmutable = in.TestFieldImmutable
return nil
}
func autoConvert_testgroup_TestType_To_v2_TestType(in *testgroup.TestType, out *TestType, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.TestField = in.TestField
// WARNING: in.TestFieldPtr requires manual conversion: does not exist in peer-type
out.TestFieldImmutable = in.TestFieldImmutable
return nil
}
@@ -0,0 +1,56 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Jetstack cert-manager contributors.
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 deepcopy-gen. DO NOT EDIT.
package v2
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 *TestType) DeepCopyInto(out *TestType) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
if in.TestFieldPtrAlt != nil {
in, out := &in.TestFieldPtrAlt, &out.TestFieldPtrAlt
*out = new(string)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType.
func (in *TestType) DeepCopy() *TestType {
if in == nil {
return nil
}
out := new(TestType)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *TestType) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
@@ -0,0 +1,37 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Jetstack cert-manager contributors.
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 defaulter-gen. DO NOT EDIT.
package v2
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// RegisterDefaults adds defaulters functions to the given scheme.
// Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters.
func RegisterDefaults(scheme *runtime.Scheme) error {
scheme.AddTypeDefaultingFunc(&TestType{}, func(obj interface{}) { SetObjectDefaults_TestType(obj.(*TestType)) })
return nil
}
func SetObjectDefaults_TestType(in *TestType) {
SetDefaults_TestType(in)
}