Skip to content

Commit

Permalink
update alibabacloud API group version to v1beta1 (openkruise#41)
Browse files Browse the repository at this point in the history
Signed-off-by: ChrisLiu <[email protected]>
  • Loading branch information
chrisliu1995 authored Apr 19, 2023
1 parent ba8ce6c commit 1cb53de
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 59 deletions.
4 changes: 0 additions & 4 deletions cloudprovider/alibabacloud/apis/v1/doc.go

This file was deleted.

4 changes: 4 additions & 0 deletions cloudprovider/alibabacloud/apis/v1beta1/doc.go
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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{})
}
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cloudprovider/alibabacloud/natgw.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(),
Expand Down
10 changes: 6 additions & 4 deletions config/crd/bases/alibabacloud.com_poddnats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -94,3 +94,5 @@ spec:
type: object
served: true
storage: true
subresources:
status: {}
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}

Expand Down

0 comments on commit 1cb53de

Please sign in to comment.