From fb81666e5679ee92507dd96eeb4dcc40f37afdec Mon Sep 17 00:00:00 2001 From: James Munnelly Date: Fri, 1 Oct 2021 15:02:25 +0100 Subject: [PATCH] Add config.cert-manager.io API group Signed-off-by: James Munnelly --- hack/update-codegen.sh | 4 ++ internal/apis/config/BUILD.bazel | 37 ++++++++++ internal/apis/config/doc.go | 21 ++++++ internal/apis/config/install/BUILD.bazel | 47 +++++++++++++ internal/apis/config/install/install.go | 33 +++++++++ internal/apis/config/install/pruning_test.go | 32 +++++++++ .../apis/config/install/roundtrip_test.go | 29 ++++++++ internal/apis/config/register.go | 46 +++++++++++++ internal/apis/config/types_webhook.go | 9 +++ internal/apis/config/v1alpha1/BUILD.bazel | 37 ++++++++++ internal/apis/config/v1alpha1/conversion.go | 17 +++++ internal/apis/config/v1alpha1/defaults.go | 25 +++++++ internal/apis/config/v1alpha1/doc.go | 23 +++++++ internal/apis/config/v1alpha1/register.go | 44 ++++++++++++ .../v1alpha1/zz_generated.conversion.go | 67 +++++++++++++++++++ .../config/v1alpha1/zz_generated.defaults.go | 33 +++++++++ internal/apis/config/zz_generated.deepcopy.go | 51 ++++++++++++++ pkg/apis/BUILD.bazel | 1 + pkg/apis/config/BUILD.bazel | 25 +++++++ pkg/apis/config/doc.go | 22 ++++++ pkg/apis/config/v1alpha1/BUILD.bazel | 33 +++++++++ pkg/apis/config/v1alpha1/doc.go | 22 ++++++ pkg/apis/config/v1alpha1/register.go | 56 ++++++++++++++++ pkg/apis/config/v1alpha1/types_webhook.go | 9 +++ .../config/v1alpha1/zz_generated.deepcopy.go | 51 ++++++++++++++ 25 files changed, 774 insertions(+) create mode 100644 internal/apis/config/BUILD.bazel create mode 100644 internal/apis/config/doc.go create mode 100644 internal/apis/config/install/BUILD.bazel create mode 100644 internal/apis/config/install/install.go create mode 100644 internal/apis/config/install/pruning_test.go create mode 100644 internal/apis/config/install/roundtrip_test.go create mode 100644 internal/apis/config/register.go create mode 100644 internal/apis/config/types_webhook.go create mode 100644 internal/apis/config/v1alpha1/BUILD.bazel create mode 100644 internal/apis/config/v1alpha1/conversion.go create mode 100644 internal/apis/config/v1alpha1/defaults.go create mode 100644 internal/apis/config/v1alpha1/doc.go create mode 100644 internal/apis/config/v1alpha1/register.go create mode 100644 internal/apis/config/v1alpha1/zz_generated.conversion.go create mode 100644 internal/apis/config/v1alpha1/zz_generated.defaults.go create mode 100644 internal/apis/config/zz_generated.deepcopy.go create mode 100644 pkg/apis/config/BUILD.bazel create mode 100644 pkg/apis/config/doc.go create mode 100644 pkg/apis/config/v1alpha1/BUILD.bazel create mode 100644 pkg/apis/config/v1alpha1/doc.go create mode 100644 pkg/apis/config/v1alpha1/register.go create mode 100644 pkg/apis/config/v1alpha1/types_webhook.go create mode 100644 pkg/apis/config/v1alpha1/zz_generated.deepcopy.go diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 6461f1e82..1bfdfe541 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -44,6 +44,8 @@ deepcopy_inputs=( pkg/apis/acme/v1beta1 \ pkg/apis/acme/v1 \ internal/apis/acme \ + pkg/apis/config/v1alpha1 \ + internal/apis/config \ pkg/apis/meta/v1 \ internal/apis/meta \ pkg/webhook/handlers/testdata/apis/testgroup/v2 \ @@ -76,6 +78,7 @@ defaulter_inputs=( internal/apis/acme/v1alpha3 \ internal/apis/acme/v1beta1 \ internal/apis/acme/v1 \ + internal/apis/config/v1alpha1 \ internal/apis/meta/v1 \ pkg/webhook/handlers/testdata/apis/testgroup/v2 \ pkg/webhook/handlers/testdata/apis/testgroup/v1 \ @@ -91,6 +94,7 @@ conversion_inputs=( internal/apis/acme/v1alpha3 \ internal/apis/acme/v1beta1 \ internal/apis/acme/v1 \ + internal/apis/config/v1alpha1 \ internal/apis/meta/v1 \ pkg/webhook/handlers/testdata/apis/testgroup/v2 \ pkg/webhook/handlers/testdata/apis/testgroup/v1 \ diff --git a/internal/apis/config/BUILD.bazel b/internal/apis/config/BUILD.bazel new file mode 100644 index 000000000..3ecf484b1 --- /dev/null +++ b/internal/apis/config/BUILD.bazel @@ -0,0 +1,37 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "register.go", + "types_webhook.go", + "zz_generated.deepcopy.go", + ], + importpath = "github.com/jetstack/cert-manager/internal/apis/config", + visibility = ["//pkg:__subpackages__"], + deps = [ + "//pkg/apis/config:go_default_library", + "@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library", + "@io_k8s_apimachinery//pkg/runtime:go_default_library", + "@io_k8s_apimachinery//pkg/runtime/schema:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//internal/apis/config/install:all-srcs", + "//internal/apis/config/v1alpha1:all-srcs", + ], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/internal/apis/config/doc.go b/internal/apis/config/doc.go new file mode 100644 index 000000000..8e6aca8ca --- /dev/null +++ b/internal/apis/config/doc.go @@ -0,0 +1,21 @@ +/* +Copyright 2020 The cert-manager 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. +*/ + +// +k8s:deepcopy-gen=package,register + +// Package config is the internal version of the API. +// +groupName=config.cert-manager.io +package config diff --git a/internal/apis/config/install/BUILD.bazel b/internal/apis/config/install/BUILD.bazel new file mode 100644 index 000000000..b8c56c2ce --- /dev/null +++ b/internal/apis/config/install/BUILD.bazel @@ -0,0 +1,47 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["install.go"], + importpath = "github.com/jetstack/cert-manager/internal/apis/config/install", + visibility = ["//visibility:public"], + deps = [ + "//internal/apis/config:go_default_library", + "//internal/apis/config/v1alpha1:go_default_library", + "@io_k8s_apimachinery//pkg/runtime:go_default_library", + "@io_k8s_apimachinery//pkg/util/runtime: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"], +) + +go_test( + name = "go_default_test", + srcs = [ + "pruning_test.go", + "roundtrip_test.go", + ], + data = [ + "//deploy/crds:templated_files", + ], + embed = [":go_default_library"], + deps = [ + "//pkg/api:go_default_library", + "//pkg/api/testing:go_default_library", + "//internal/apis/acme/fuzzer:go_default_library", + "@com_github_munnerz_crd_schema_fuzz//:go_default_library", + "@io_k8s_apimachinery//pkg/api/apitesting/roundtrip:go_default_library", + ], +) diff --git a/internal/apis/config/install/install.go b/internal/apis/config/install/install.go new file mode 100644 index 000000000..8edb703d2 --- /dev/null +++ b/internal/apis/config/install/install.go @@ -0,0 +1,33 @@ +/* +Copyright 2020 The cert-manager 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 install installs the API group, making it available as an option to +// all of the API encoding/decoding machinery. +package install + +import ( + "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + + "github.com/jetstack/cert-manager/internal/apis/config" + "github.com/jetstack/cert-manager/internal/apis/config/v1alpha1" +) + +// Install registers the API group and adds types to a scheme +func Install(scheme *runtime.Scheme) { + utilruntime.Must(config.AddToScheme(scheme)) + utilruntime.Must(v1alpha1.AddToScheme(scheme)) +} diff --git a/internal/apis/config/install/pruning_test.go b/internal/apis/config/install/pruning_test.go new file mode 100644 index 000000000..9c82bdb00 --- /dev/null +++ b/internal/apis/config/install/pruning_test.go @@ -0,0 +1,32 @@ +/* +Copyright 2020 The cert-manager 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 install + +import ( + "testing" + + crdfuzz "github.com/munnerz/crd-schema-fuzz" + + acmefuzzer "github.com/jetstack/cert-manager/internal/apis/acme/fuzzer" + "github.com/jetstack/cert-manager/pkg/api" + apitesting "github.com/jetstack/cert-manager/pkg/api/testing" +) + +func TestPruneTypes(t *testing.T) { + crdfuzz.SchemaFuzzTestForCRDWithPath(t, api.Scheme, apitesting.PathForCRD(t, "orders"), acmefuzzer.Funcs) + crdfuzz.SchemaFuzzTestForCRDWithPath(t, api.Scheme, apitesting.PathForCRD(t, "challenges"), acmefuzzer.Funcs) +} diff --git a/internal/apis/config/install/roundtrip_test.go b/internal/apis/config/install/roundtrip_test.go new file mode 100644 index 000000000..c634f2f00 --- /dev/null +++ b/internal/apis/config/install/roundtrip_test.go @@ -0,0 +1,29 @@ +/* +Copyright 2020 The cert-manager 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 install + +import ( + "testing" + + "k8s.io/apimachinery/pkg/api/apitesting/roundtrip" + + acmefuzzer "github.com/jetstack/cert-manager/internal/apis/acme/fuzzer" +) + +func TestRoundTripTypes(t *testing.T) { + roundtrip.RoundTripTestForAPIGroup(t, Install, acmefuzzer.Funcs) +} diff --git a/internal/apis/config/register.go b/internal/apis/config/register.go new file mode 100644 index 000000000..f4875d621 --- /dev/null +++ b/internal/apis/config/register.go @@ -0,0 +1,46 @@ +/* +Copyright 2020 The cert-manager 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 config + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/jetstack/cert-manager/pkg/apis/config" +) + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: config.GroupName, Version: runtime.APIVersionInternal} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &WebhookConfiguration{}, + // Add new kinds to be registered here + ) + return nil +} diff --git a/internal/apis/config/types_webhook.go b/internal/apis/config/types_webhook.go new file mode 100644 index 000000000..80ac8909c --- /dev/null +++ b/internal/apis/config/types_webhook.go @@ -0,0 +1,9 @@ +package config + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type WebhookConfiguration struct { + metav1.TypeMeta `json:",inline"` +} diff --git a/internal/apis/config/v1alpha1/BUILD.bazel b/internal/apis/config/v1alpha1/BUILD.bazel new file mode 100644 index 000000000..8d2e5fd2e --- /dev/null +++ b/internal/apis/config/v1alpha1/BUILD.bazel @@ -0,0 +1,37 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "conversion.go", + "defaults.go", + "doc.go", + "register.go", + "zz_generated.conversion.go", + "zz_generated.defaults.go", + ], + importpath = "github.com/jetstack/cert-manager/internal/apis/config/v1alpha1", + visibility = ["//pkg:__subpackages__"], + deps = [ + "//pkg/apis/config:go_default_library", + "//pkg/apis/config/v1alpha1:go_default_library", + "//internal/apis/config: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", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/internal/apis/config/v1alpha1/conversion.go b/internal/apis/config/v1alpha1/conversion.go new file mode 100644 index 000000000..335956697 --- /dev/null +++ b/internal/apis/config/v1alpha1/conversion.go @@ -0,0 +1,17 @@ +/* +Copyright 2021 The cert-manager 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 diff --git a/internal/apis/config/v1alpha1/defaults.go b/internal/apis/config/v1alpha1/defaults.go new file mode 100644 index 000000000..f79f2d48e --- /dev/null +++ b/internal/apis/config/v1alpha1/defaults.go @@ -0,0 +1,25 @@ +/* +Copyright 2021 The cert-manager 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 ( + "k8s.io/apimachinery/pkg/runtime" +) + +func addDefaultingFuncs(scheme *runtime.Scheme) error { + return RegisterDefaults(scheme) +} diff --git a/internal/apis/config/v1alpha1/doc.go b/internal/apis/config/v1alpha1/doc.go new file mode 100644 index 000000000..6e719c1cc --- /dev/null +++ b/internal/apis/config/v1alpha1/doc.go @@ -0,0 +1,23 @@ +/* +Copyright 2021 The cert-manager 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. +*/ + +// +k8s:conversion-gen=github.com/jetstack/cert-manager/internal/apis/config +// +k8s:conversion-gen-external-types=github.com/jetstack/cert-manager/pkg/apis/config/v1alpha1 +// +k8s:defaulter-gen=TypeMeta +// +k8s:defaulter-gen-input=../../../../apis/config/v1alpha1 + +// +groupName=config.cert-manager.io +package v1alpha1 diff --git a/internal/apis/config/v1alpha1/register.go b/internal/apis/config/v1alpha1/register.go new file mode 100644 index 000000000..4b4d4c4bb --- /dev/null +++ b/internal/apis/config/v1alpha1/register.go @@ -0,0 +1,44 @@ +/* +Copyright 2021 The cert-manager 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 ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/jetstack/cert-manager/pkg/apis/config" + "github.com/jetstack/cert-manager/pkg/apis/config/v1alpha1" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: config.GroupName, Version: "v1alpha1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + localSchemeBuilder = &v1alpha1.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(addDefaultingFuncs) +} diff --git a/internal/apis/config/v1alpha1/zz_generated.conversion.go b/internal/apis/config/v1alpha1/zz_generated.conversion.go new file mode 100644 index 000000000..56fd8f5bb --- /dev/null +++ b/internal/apis/config/v1alpha1/zz_generated.conversion.go @@ -0,0 +1,67 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The cert-manager 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 conversion-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "github.com/jetstack/cert-manager/internal/apis/config" + v1alpha1 "github.com/jetstack/cert-manager/pkg/apis/config/v1alpha1" + 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((*v1alpha1.WebhookConfiguration)(nil), (*config.WebhookConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_WebhookConfiguration_To_config_WebhookConfiguration(a.(*v1alpha1.WebhookConfiguration), b.(*config.WebhookConfiguration), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.WebhookConfiguration)(nil), (*v1alpha1.WebhookConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_WebhookConfiguration_To_v1alpha1_WebhookConfiguration(a.(*config.WebhookConfiguration), b.(*v1alpha1.WebhookConfiguration), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1alpha1_WebhookConfiguration_To_config_WebhookConfiguration(in *v1alpha1.WebhookConfiguration, out *config.WebhookConfiguration, s conversion.Scope) error { + return nil +} + +// Convert_v1alpha1_WebhookConfiguration_To_config_WebhookConfiguration is an autogenerated conversion function. +func Convert_v1alpha1_WebhookConfiguration_To_config_WebhookConfiguration(in *v1alpha1.WebhookConfiguration, out *config.WebhookConfiguration, s conversion.Scope) error { + return autoConvert_v1alpha1_WebhookConfiguration_To_config_WebhookConfiguration(in, out, s) +} + +func autoConvert_config_WebhookConfiguration_To_v1alpha1_WebhookConfiguration(in *config.WebhookConfiguration, out *v1alpha1.WebhookConfiguration, s conversion.Scope) error { + return nil +} + +// Convert_config_WebhookConfiguration_To_v1alpha1_WebhookConfiguration is an autogenerated conversion function. +func Convert_config_WebhookConfiguration_To_v1alpha1_WebhookConfiguration(in *config.WebhookConfiguration, out *v1alpha1.WebhookConfiguration, s conversion.Scope) error { + return autoConvert_config_WebhookConfiguration_To_v1alpha1_WebhookConfiguration(in, out, s) +} diff --git a/internal/apis/config/v1alpha1/zz_generated.defaults.go b/internal/apis/config/v1alpha1/zz_generated.defaults.go new file mode 100644 index 000000000..48c7e75b4 --- /dev/null +++ b/internal/apis/config/v1alpha1/zz_generated.defaults.go @@ -0,0 +1,33 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The cert-manager 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 defaulter-gen. DO NOT EDIT. + +package v1alpha1 + +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 { + return nil +} diff --git a/internal/apis/config/zz_generated.deepcopy.go b/internal/apis/config/zz_generated.deepcopy.go new file mode 100644 index 000000000..efd5df937 --- /dev/null +++ b/internal/apis/config/zz_generated.deepcopy.go @@ -0,0 +1,51 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The cert-manager 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 deepcopy-gen. DO NOT EDIT. + +package config + +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 *WebhookConfiguration) DeepCopyInto(out *WebhookConfiguration) { + *out = *in + out.TypeMeta = in.TypeMeta + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookConfiguration. +func (in *WebhookConfiguration) DeepCopy() *WebhookConfiguration { + if in == nil { + return nil + } + out := new(WebhookConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *WebhookConfiguration) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} diff --git a/pkg/apis/BUILD.bazel b/pkg/apis/BUILD.bazel index f045e68a8..012210456 100644 --- a/pkg/apis/BUILD.bazel +++ b/pkg/apis/BUILD.bazel @@ -20,6 +20,7 @@ filegroup( ":package-srcs", "//pkg/apis/acme:all-srcs", "//pkg/apis/certmanager:all-srcs", + "//pkg/apis/config:all-srcs", "//pkg/apis/experimental:all-srcs", "//pkg/apis/meta:all-srcs", ], diff --git a/pkg/apis/config/BUILD.bazel b/pkg/apis/config/BUILD.bazel new file mode 100644 index 000000000..08d473549 --- /dev/null +++ b/pkg/apis/config/BUILD.bazel @@ -0,0 +1,25 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["doc.go"], + importpath = "github.com/jetstack/cert-manager/pkg/apis/config", + visibility = ["//visibility:public"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//pkg/apis/config/v1alpha1:all-srcs", + ], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/apis/config/doc.go b/pkg/apis/config/doc.go new file mode 100644 index 000000000..590999204 --- /dev/null +++ b/pkg/apis/config/doc.go @@ -0,0 +1,22 @@ +/* +Copyright 2021 The cert-manager 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. +*/ + +// +groupName=config.cert-manager.io + +// Package config contains types used to configure cert-manager components +package config + +const GroupName = "config.cert-manager.io" diff --git a/pkg/apis/config/v1alpha1/BUILD.bazel b/pkg/apis/config/v1alpha1/BUILD.bazel new file mode 100644 index 000000000..4c8995b22 --- /dev/null +++ b/pkg/apis/config/v1alpha1/BUILD.bazel @@ -0,0 +1,33 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "register.go", + "types_webhook.go", + "zz_generated.deepcopy.go", + ], + importpath = "github.com/jetstack/cert-manager/pkg/apis/config/v1alpha1", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/config:go_default_library", + "@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library", + "@io_k8s_apimachinery//pkg/runtime:go_default_library", + "@io_k8s_apimachinery//pkg/runtime/schema: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"], +) diff --git a/pkg/apis/config/v1alpha1/doc.go b/pkg/apis/config/v1alpha1/doc.go new file mode 100644 index 000000000..faac8e388 --- /dev/null +++ b/pkg/apis/config/v1alpha1/doc.go @@ -0,0 +1,22 @@ +/* +Copyright 2021 The cert-manager 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 is the v1alpha1 version of the API. +// +k8s:deepcopy-gen=package,register +// +k8s:conversion-gen=github.com/jetstack/cert-manager/pkg/apis/config +// +k8s:defaulter-gen=TypeMeta +// +groupName=config.cert-manager.io +package v1alpha1 diff --git a/pkg/apis/config/v1alpha1/register.go b/pkg/apis/config/v1alpha1/register.go new file mode 100644 index 000000000..608f9d7c4 --- /dev/null +++ b/pkg/apis/config/v1alpha1/register.go @@ -0,0 +1,56 @@ +/* +Copyright 2021 The cert-manager 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" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/jetstack/cert-manager/pkg/apis/config" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: config.GroupName, Version: "v1alpha1"} + +// 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) +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &WebhookConfiguration{}, + // Add new kinds to be registered here + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/config/v1alpha1/types_webhook.go b/pkg/apis/config/v1alpha1/types_webhook.go new file mode 100644 index 000000000..8a8927710 --- /dev/null +++ b/pkg/apis/config/v1alpha1/types_webhook.go @@ -0,0 +1,9 @@ +package v1alpha1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type WebhookConfiguration struct { + metav1.TypeMeta `json:",inline"` +} diff --git a/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..b32dcdb60 --- /dev/null +++ b/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,51 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The cert-manager 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 deepcopy-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 *WebhookConfiguration) DeepCopyInto(out *WebhookConfiguration) { + *out = *in + out.TypeMeta = in.TypeMeta + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookConfiguration. +func (in *WebhookConfiguration) DeepCopy() *WebhookConfiguration { + if in == nil { + return nil + } + out := new(WebhookConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *WebhookConfiguration) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +}