From 1cb53dea1b639772dc01398b1c64f4f7dce354ac Mon Sep 17 00:00:00 2001 From: ChrisLiu <70144550+chrisliu1995@users.noreply.github.com> Date: Wed, 19 Apr 2023 19:53:30 +0800 Subject: [PATCH] update alibabacloud API group version to v1beta1 (#41) Signed-off-by: ChrisLiu --- cloudprovider/alibabacloud/apis/v1/doc.go | 4 -- .../alibabacloud/apis/v1beta1/doc.go | 4 ++ .../apis/{v1 => v1beta1}/poddnat_types.go | 72 ++++++++----------- .../apis/{v1 => v1beta1}/register.go | 6 +- .../{v1 => v1beta1}/zz_generated.deepcopy.go | 2 +- cloudprovider/alibabacloud/natgw.go | 4 +- .../crd/bases/alibabacloud.com_poddnats.yaml | 10 +-- main.go | 4 +- 8 files changed, 47 insertions(+), 59 deletions(-) delete mode 100644 cloudprovider/alibabacloud/apis/v1/doc.go create mode 100644 cloudprovider/alibabacloud/apis/v1beta1/doc.go rename cloudprovider/alibabacloud/apis/{v1 => v1beta1}/poddnat_types.go (66%) rename cloudprovider/alibabacloud/apis/{v1 => v1beta1}/register.go (82%) rename cloudprovider/alibabacloud/apis/{v1 => v1beta1}/zz_generated.deepcopy.go (99%) diff --git a/cloudprovider/alibabacloud/apis/v1/doc.go b/cloudprovider/alibabacloud/apis/v1/doc.go deleted file mode 100644 index 76ab508d..00000000 --- a/cloudprovider/alibabacloud/apis/v1/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package v1 contains API Schema definitions for the alibabacloud v1 API group -// +k8s:deepcopy-gen=package,register -// +groupName=alibabacloud.com -package v1 diff --git a/cloudprovider/alibabacloud/apis/v1beta1/doc.go b/cloudprovider/alibabacloud/apis/v1beta1/doc.go new file mode 100644 index 00000000..72ea4f9c --- /dev/null +++ b/cloudprovider/alibabacloud/apis/v1beta1/doc.go @@ -0,0 +1,4 @@ +// Package v1beta1 Package v1 contains API Schema definitions for the alibabacloud v1beta1 API group +// +k8s:deepcopy-gen=package,register +// +groupName=alibabacloud.com +package v1beta1 diff --git a/cloudprovider/alibabacloud/apis/v1/poddnat_types.go b/cloudprovider/alibabacloud/apis/v1beta1/poddnat_types.go similarity index 66% rename from cloudprovider/alibabacloud/apis/v1/poddnat_types.go rename to cloudprovider/alibabacloud/apis/v1beta1/poddnat_types.go index 031ddfc0..bfed05b8 100644 --- a/cloudprovider/alibabacloud/apis/v1/poddnat_types.go +++ b/cloudprovider/alibabacloud/apis/v1beta1/poddnat_types.go @@ -1,5 +1,5 @@ /* -Copyright 2022 The Kruise Authors. +Copyright 2023 The Kruise Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,52 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1 +package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func init() { - SchemeBuilder.Register(&PodDNAT{}, &PodDNATList{}) -} - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// PodDNAT let you specficy DNAT rule for pod on nat gateway -type PodDNAT struct { - metav1.TypeMeta `json:",inline"` - // Standard object's metadata. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata - // +optional - metav1.ObjectMeta `json:"metadata,omitempty"` - - // Spec is the desired state of the PodDNAT. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - Spec PodDNATSpec `json:"spec,omitempty"` - - // 'Status is the current state of the dnat. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional - Status PodDNATStatus `json:"status,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// PodDNATList is a collection of PodDNAT. -type PodDNATList struct { - metav1.TypeMeta `json:",inline"` - // Standard object's metadata. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - - // Items is the list of PodDNAT. - Items []PodDNAT `json:"items"` -} - -// PodDNATSpec describes the PodDNAT the user wishes to exist. +// PodDNATSpec defines the desired state of PodDNAT type PodDNATSpec struct { VSwitch *string `json:"vswitch,omitempty"` // deprecated ENI *string `json:"eni,omitempty"` // deprecated @@ -79,7 +40,7 @@ type PortMapping struct { InternalPort string `json:"internalPort,omitempty"` } -// PodDNATStatus is the current state of the dnat. +// PodDNATStatus defines the observed state of PodDNAT type PodDNATStatus struct { // created create status // +optional @@ -100,3 +61,28 @@ type Entry struct { ForwardEntryID string `json:"forwardEntryId,omitempty"` IPProtocol string `json:"ipProtocol,omitempty"` } + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status + +// PodDNAT is the Schema for the poddnats API +type PodDNAT struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec PodDNATSpec `json:"spec,omitempty"` + Status PodDNATStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// PodDNATList contains a list of PodDNAT +type PodDNATList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []PodDNAT `json:"items"` +} + +func init() { + SchemeBuilder.Register(&PodDNAT{}, &PodDNATList{}) +} diff --git a/cloudprovider/alibabacloud/apis/v1/register.go b/cloudprovider/alibabacloud/apis/v1beta1/register.go similarity index 82% rename from cloudprovider/alibabacloud/apis/v1/register.go rename to cloudprovider/alibabacloud/apis/v1beta1/register.go index 8eeb8425..d15b4681 100644 --- a/cloudprovider/alibabacloud/apis/v1/register.go +++ b/cloudprovider/alibabacloud/apis/v1beta1/register.go @@ -1,10 +1,10 @@ // NOTE: Boilerplate only. Ignore this file. -// Package v1 contains API Schema definitions for the alibabacloud v1 API group +// Package v1beta1 contains API Schema definitions for the alibabacloud v1beta1 API group // +k8s:deepcopy-gen=package,register // +groupName=alibabacloud.com -package v1 +package v1beta1 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -13,7 +13,7 @@ import ( var ( // SchemeGroupVersion is group version used to register these objects - SchemeGroupVersion = schema.GroupVersion{Group: "alibabacloud.com", Version: "v1"} + SchemeGroupVersion = schema.GroupVersion{Group: "alibabacloud.com", Version: "v1beta1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} diff --git a/cloudprovider/alibabacloud/apis/v1/zz_generated.deepcopy.go b/cloudprovider/alibabacloud/apis/v1beta1/zz_generated.deepcopy.go similarity index 99% rename from cloudprovider/alibabacloud/apis/v1/zz_generated.deepcopy.go rename to cloudprovider/alibabacloud/apis/v1beta1/zz_generated.deepcopy.go index 7436326b..d8bacb15 100644 --- a/cloudprovider/alibabacloud/apis/v1/zz_generated.deepcopy.go +++ b/cloudprovider/alibabacloud/apis/v1beta1/zz_generated.deepcopy.go @@ -19,7 +19,7 @@ limitations under the License. // Code generated by controller-gen. DO NOT EDIT. -package v1 +package v1beta1 import ( runtime "k8s.io/apimachinery/pkg/runtime" diff --git a/cloudprovider/alibabacloud/natgw.go b/cloudprovider/alibabacloud/natgw.go index a3783f22..ce289da1 100644 --- a/cloudprovider/alibabacloud/natgw.go +++ b/cloudprovider/alibabacloud/natgw.go @@ -20,7 +20,7 @@ import ( "context" gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1" "github.com/openkruise/kruise-game/cloudprovider" - "github.com/openkruise/kruise-game/cloudprovider/alibabacloud/apis/v1" + "github.com/openkruise/kruise-game/cloudprovider/alibabacloud/apis/v1beta1" "github.com/openkruise/kruise-game/cloudprovider/errors" "github.com/openkruise/kruise-game/cloudprovider/utils" corev1 "k8s.io/api/core/v1" @@ -83,7 +83,7 @@ func (n NatGwPlugin) OnPodUpdated(c client.Client, pod *corev1.Pod, ctx context. return pod, errors.ToPluginError(err, errors.InternalError) } - podDNat := &v1.PodDNAT{} + podDNat := &v1beta1.PodDNAT{} err := c.Get(ctx, types.NamespacedName{ Name: pod.GetName(), Namespace: pod.GetNamespace(), diff --git a/config/crd/bases/alibabacloud.com_poddnats.yaml b/config/crd/bases/alibabacloud.com_poddnats.yaml index 87219e9c..3867b071 100644 --- a/config/crd/bases/alibabacloud.com_poddnats.yaml +++ b/config/crd/bases/alibabacloud.com_poddnats.yaml @@ -15,10 +15,10 @@ spec: singular: poddnat scope: Namespaced versions: - - name: v1 + - name: v1beta1 schema: openAPIV3Schema: - description: PodDNAT let you specficy DNAT rule for pod on nat gateway + description: PodDNAT is the Schema for the poddnats API properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -33,7 +33,7 @@ spec: metadata: type: object spec: - description: 'Spec is the desired state of the PodDNAT. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status' + description: PodDNATSpec defines the desired state of PodDNAT properties: eni: type: string @@ -66,7 +66,7 @@ spec: type: string type: object status: - description: '''Status is the current state of the dnat. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status' + description: PodDNATStatus defines the observed state of PodDNAT properties: created: description: created create status @@ -94,3 +94,5 @@ spec: type: object served: true storage: true + subresources: + status: {} diff --git a/main.go b/main.go index 6d2e3d0b..cc90921a 100644 --- a/main.go +++ b/main.go @@ -31,7 +31,7 @@ import ( // to ensure that exec-entrypoint and run can make use of them. _ "k8s.io/client-go/plugin/pkg/client/auth" - aliv1 "github.com/openkruise/kruise-game/cloudprovider/alibabacloud/apis/v1" + aliv1beta1 "github.com/openkruise/kruise-game/cloudprovider/alibabacloud/apis/v1beta1" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" @@ -56,7 +56,7 @@ func init() { utilruntime.Must(kruiseV1beta1.AddToScheme(scheme)) utilruntime.Must(kruiseV1alpha1.AddToScheme(scheme)) - utilruntime.Must(aliv1.AddToScheme(scheme)) + utilruntime.Must(aliv1beta1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme }