From bd8fce705fd85ff3ce95e602e2bbe15195bf2ab6 Mon Sep 17 00:00:00 2001 From: Di Xu Date: Wed, 6 Mar 2024 11:23:39 +0800 Subject: [PATCH] update with new codegen (#794) Signed-off-by: Di Xu --- apps/v1alpha1/base.go | 29 ------- apps/v1alpha1/types.go | 46 +++++++++++ proxies/install/roundtrip_test.go | 31 ------- proxies/v1alpha1/defaults.go | 2 +- proxies/v1alpha1/zz_generated.conversion.go | 92 --------------------- proxies/v1alpha1/zz_generated.defaults.go | 32 ------- 6 files changed, 47 insertions(+), 185 deletions(-) create mode 100644 apps/v1alpha1/types.go delete mode 100644 proxies/install/roundtrip_test.go delete mode 100644 proxies/v1alpha1/zz_generated.conversion.go delete mode 100644 proxies/v1alpha1/zz_generated.defaults.go diff --git a/apps/v1alpha1/base.go b/apps/v1alpha1/base.go index 9bbbd20..1fca370 100644 --- a/apps/v1alpha1/base.go +++ b/apps/v1alpha1/base.go @@ -16,25 +16,6 @@ limitations under the License. package v1alpha1 -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// Important: Run "make generated" to regenerate code after modifying this file - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +kubebuilder:resource:scope="Namespaced",categories=clusternet -// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" - -// Base represents the referenced resources/templates before rendering. -type Base struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec BaseSpec `json:"spec"` -} - // BaseSpec defines the desired state of Base type BaseSpec struct { // Feeds @@ -43,13 +24,3 @@ type BaseSpec struct { // +kubebuilder:validation:Required Feeds []Feed `json:"feeds"` } - -// +kubebuilder:object:root=true -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// BaseList contains a list of Base -type BaseList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Base `json:"items"` -} diff --git a/apps/v1alpha1/types.go b/apps/v1alpha1/types.go new file mode 100644 index 0000000..f7c90d6 --- /dev/null +++ b/apps/v1alpha1/types.go @@ -0,0 +1,46 @@ +/* +Copyright 2024 The Clusternet 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" +) + +// Important: Run "make generated" to regenerate code after modifying this file + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:scope="Namespaced",categories=clusternet +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" + +// Base represents the referenced resources/templates before rendering. +type Base struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec BaseSpec `json:"spec"` +} + +// +kubebuilder:object:root=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// BaseList contains a list of Base +type BaseList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Base `json:"items"` +} diff --git a/proxies/install/roundtrip_test.go b/proxies/install/roundtrip_test.go deleted file mode 100644 index bb3bd0c..0000000 --- a/proxies/install/roundtrip_test.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2021 The Clusternet 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" - - proxiesfuzzer "github.com/clusternet/clusternet/pkg/apis/proxies/fuzzer" -) - -func TestRoundTripTypes(t *testing.T) { - roundtrip.RoundTripTestForAPIGroup(t, Install, proxiesfuzzer.Funcs) - // TODO: enable protobuf generation for the clusternet-hubserver - // roundtrip.RoundTripProtobufTestForAPIGroup(t, Install, proxiesfuzzer.Funcs) -} diff --git a/proxies/v1alpha1/defaults.go b/proxies/v1alpha1/defaults.go index 6d4198d..8284a9c 100644 --- a/proxies/v1alpha1/defaults.go +++ b/proxies/v1alpha1/defaults.go @@ -21,5 +21,5 @@ import ( ) func addDefaultingFuncs(scheme *runtime.Scheme) error { - return RegisterDefaults(scheme) + return nil } diff --git a/proxies/v1alpha1/zz_generated.conversion.go b/proxies/v1alpha1/zz_generated.conversion.go deleted file mode 100644 index 63f8f5b..0000000 --- a/proxies/v1alpha1/zz_generated.conversion.go +++ /dev/null @@ -1,92 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -/* -Copyright The Clusternet 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 ( - url "net/url" - - proxies "github.com/clusternet/clusternet/pkg/apis/proxies" - 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((*Socket)(nil), (*proxies.Socket)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_Socket_To_proxies_Socket(a.(*Socket), b.(*proxies.Socket), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*proxies.Socket)(nil), (*Socket)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_proxies_Socket_To_v1alpha1_Socket(a.(*proxies.Socket), b.(*Socket), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*url.Values)(nil), (*Socket)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_url_Values_To_v1alpha1_Socket(a.(*url.Values), b.(*Socket), scope) - }); err != nil { - return err - } - return nil -} - -func autoConvert_v1alpha1_Socket_To_proxies_Socket(in *Socket, out *proxies.Socket, s conversion.Scope) error { - out.Path = in.Path - return nil -} - -// Convert_v1alpha1_Socket_To_proxies_Socket is an autogenerated conversion function. -func Convert_v1alpha1_Socket_To_proxies_Socket(in *Socket, out *proxies.Socket, s conversion.Scope) error { - return autoConvert_v1alpha1_Socket_To_proxies_Socket(in, out, s) -} - -func autoConvert_proxies_Socket_To_v1alpha1_Socket(in *proxies.Socket, out *Socket, s conversion.Scope) error { - out.Path = in.Path - return nil -} - -// Convert_proxies_Socket_To_v1alpha1_Socket is an autogenerated conversion function. -func Convert_proxies_Socket_To_v1alpha1_Socket(in *proxies.Socket, out *Socket, s conversion.Scope) error { - return autoConvert_proxies_Socket_To_v1alpha1_Socket(in, out, s) -} - -func autoConvert_url_Values_To_v1alpha1_Socket(in *url.Values, out *Socket, s conversion.Scope) error { - // WARNING: Field TypeMeta does not have json tag, skipping. - - if values, ok := map[string][]string(*in)["path"]; ok && len(values) > 0 { - if err := runtime.Convert_Slice_string_To_string(&values, &out.Path, s); err != nil { - return err - } - } else { - out.Path = "" - } - return nil -} - -// Convert_url_Values_To_v1alpha1_Socket is an autogenerated conversion function. -func Convert_url_Values_To_v1alpha1_Socket(in *url.Values, out *Socket, s conversion.Scope) error { - return autoConvert_url_Values_To_v1alpha1_Socket(in, out, s) -} diff --git a/proxies/v1alpha1/zz_generated.defaults.go b/proxies/v1alpha1/zz_generated.defaults.go deleted file mode 100644 index e4373f3..0000000 --- a/proxies/v1alpha1/zz_generated.defaults.go +++ /dev/null @@ -1,32 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -/* -Copyright The Clusternet 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 -}