From a1ba5e96ef6410278c3df047fed5cdd60f8a0e02 Mon Sep 17 00:00:00 2001 From: zhouqunjie <450705171@qq.com> Date: Mon, 16 May 2022 15:53:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9mod=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=EF=BC=8CHuawei=20SDK=20=E4=BF=AE=E6=94=B9=E5=92=8C=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=8A=9F=E8=83=BD=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pod/server/ali/create_container_group.go | 10 +- .../pod/server/ali/delete_container_group.go | 8 +- .../server/ali/describe_container_groups.go | 6 +- .../pod/server/ali/update_container_group.go | 8 +- .../server/kubernetes/api/core/v1/types.go | 102 +- .../pkg/apis/meta/v1/micro_time.go | 181 +++ .../apimachinery/pkg/apis/meta/v1/time.go | 182 +++ .../apimachinery/pkg/apis/meta/v1/types.go | 1436 +++++++++++++++++ .../client-go/kubernetes/clientset.go | 2 +- .../client-go/kubernetes/typed/core/v1/pod.go | 195 ++- adaptor/pod/server/pod.go | 8 +- adaptor/pod/service/ali_eci.go | 6 +- adaptor/pod/service/huawei_cci.go | 6 +- adaptor/pod/service/k8s.go | 6 +- adaptor/pod/service/poder.go | 6 +- adaptor/pod/service/tencent_eks.go | 6 +- adaptor/vm/server/ecs/list.go | 8 +- adaptor/vm/server/ecs/list_test.go | 4 +- adaptor/vm/server/ecs/main_test.go | 4 +- adaptor/vm/service/ecser/ali.go | 6 +- adaptor/vm/service/ecser/aws.go | 6 +- adaptor/vm/service/ecser/ecser.go | 6 +- adaptor/vm/service/ecser/ecser_test.go | 6 +- adaptor/vm/service/ecser/harvester.go | 6 +- adaptor/vm/service/ecser/huawei.go | 6 +- adaptor/vm/service/ecser/main_test.go | 4 +- adaptor/vm/service/ecser/tencent.go | 6 +- common/server/server.go | 6 +- common/server/server_ecs.go | 4 +- common/server/server_pod.go | 4 +- common/tenanter/main_test.go | 2 +- common/tenanter/region.go | 2 +- common/tenanter/region_test.go | 2 +- common/tenanter/tenanter.go | 2 +- examples/pcm_ali.go | 2 +- examples/pcm_huawei.go | 62 +- go.mod | 4 +- idl/demo/demo.proto | 2 +- idl/pbecs/ecs.proto | 2 +- idl/pbpod/pod.proto | 2 +- idl/pbtenant/tenant.proto | 4 +- lan_trans/idl/pbecs/ecs.pb.go | 2 +- lan_trans/idl/pbpod/pod.pb.go | 2 +- main.go | 10 +- 44 files changed, 2148 insertions(+), 196 deletions(-) create mode 100644 adaptor/pod/server/kubernetes/apimachinery/pkg/apis/meta/v1/micro_time.go create mode 100644 adaptor/pod/server/kubernetes/apimachinery/pkg/apis/meta/v1/time.go create mode 100644 adaptor/pod/server/kubernetes/apimachinery/pkg/apis/meta/v1/types.go diff --git a/adaptor/pod/server/ali/create_container_group.go b/adaptor/pod/server/ali/create_container_group.go index 6e754c80..503cc846 100644 --- a/adaptor/pod/server/ali/create_container_group.go +++ b/adaptor/pod/server/ali/create_container_group.go @@ -1,15 +1,15 @@ package ali import ( + "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "errors" "flag" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" "github.com/golang/glog" - "gitlink.org.cn/JCCE/PCM/adaptor/pod/server" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "strconv" ) @@ -45,8 +45,8 @@ func CreateContainerGroup(request *CreateContainerGroupRequest) (response *Creat regionId, _ = tenanter.GetAliRegionId(request.RegionId) case 1: regionId, _ = tenanter.GetTencentRegionId(request.RegionId) - case 2: + //华为的CPU和内存数量要进行转换 regionId, _ = tenanter.GetHuaweiRegionId(request.RegionId) cpuPod = strconv.FormatFloat(cpuPodFloat*1000, 'f', 0, 64) memoryPod = strconv.FormatFloat(memoryPodFloat, 'f', 0, 64) diff --git a/adaptor/pod/server/ali/delete_container_group.go b/adaptor/pod/server/ali/delete_container_group.go index b97bf646..07a85c9d 100644 --- a/adaptor/pod/server/ali/delete_container_group.go +++ b/adaptor/pod/server/ali/delete_container_group.go @@ -16,15 +16,15 @@ package ali import ( + "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "errors" "flag" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" "github.com/golang/glog" - "gitlink.org.cn/JCCE/PCM/adaptor/pod/server" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" ) // DeleteContainerGroup invokes the eci.DeleteContainerGroup API synchronously diff --git a/adaptor/pod/server/ali/describe_container_groups.go b/adaptor/pod/server/ali/describe_container_groups.go index 399bfe7e..9c57b0b0 100644 --- a/adaptor/pod/server/ali/describe_container_groups.go +++ b/adaptor/pod/server/ali/describe_container_groups.go @@ -1,11 +1,11 @@ package ali import ( + "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" - "gitlink.org.cn/JCCE/PCM/adaptor/pod/server" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" ) // DescribeContainerGroups invokes the eci.DescribeContainerGroups API synchronously diff --git a/adaptor/pod/server/ali/update_container_group.go b/adaptor/pod/server/ali/update_container_group.go index 29f4cec2..a7f82fde 100644 --- a/adaptor/pod/server/ali/update_container_group.go +++ b/adaptor/pod/server/ali/update_container_group.go @@ -16,15 +16,15 @@ package ali import ( + "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "errors" "flag" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" "github.com/golang/glog" - "gitlink.org.cn/JCCE/PCM/adaptor/pod/server" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" ) // UpdateContainerGroup invokes the eci.UpdateContainerGroup API synchronously diff --git a/adaptor/pod/server/kubernetes/api/core/v1/types.go b/adaptor/pod/server/kubernetes/api/core/v1/types.go index ba4e5c64..d848e030 100644 --- a/adaptor/pod/server/kubernetes/api/core/v1/types.go +++ b/adaptor/pod/server/kubernetes/api/core/v1/types.go @@ -299,7 +299,7 @@ const ( // +genclient // +genclient:nonNamespaced -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PersistentVolume (PV) is a storage resource provisioned by an administrator. // It is analogous to a node. @@ -415,7 +415,7 @@ type PersistentVolumeStatus struct { Reason string `json:"reason,omitempty" protobuf:"bytes,3,opt,name=reason"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PersistentVolumeList is a list of PersistentVolume items. type PersistentVolumeList struct { @@ -430,7 +430,7 @@ type PersistentVolumeList struct { } // +genclient -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PersistentVolumeClaim is a user's request for and claim to a persistent volume type PersistentVolumeClaim struct { @@ -452,7 +452,7 @@ type PersistentVolumeClaim struct { Status PersistentVolumeClaimStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PersistentVolumeClaimList is a list of PersistentVolumeClaim items. type PersistentVolumeClaimList struct { @@ -3664,7 +3664,7 @@ type PodStatus struct { EphemeralContainerStatuses []ContainerStatus `json:"ephemeralContainerStatuses,omitempty" protobuf:"bytes,13,rep,name=ephemeralContainerStatuses"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PodStatusResult is a wrapper for PodStatus returned by kubelet that can be encode/decoded type PodStatusResult struct { @@ -3685,7 +3685,7 @@ type PodStatusResult struct { // +genclient // +genclient:method=GetEphemeralContainers,verb=get,subresource=ephemeralcontainers,result=EphemeralContainers // +genclient:method=UpdateEphemeralContainers,verb=update,subresource=ephemeralcontainers,input=EphemeralContainers,result=EphemeralContainers -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // Pod is a collection of containers that can run on a host. This resource is created // by clients and scheduled onto hosts. @@ -3710,7 +3710,7 @@ type Pod struct { Status PodStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PodList is a list of Pods. type PodList struct { @@ -3739,7 +3739,7 @@ type PodTemplateSpec struct { } // +genclient -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PodTemplate describes a template for creating copies of a predefined pod. type PodTemplate struct { @@ -3755,7 +3755,7 @@ type PodTemplate struct { Template PodTemplateSpec `json:"template,omitempty" protobuf:"bytes,2,opt,name=template"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PodTemplateList is a list of PodTemplates. type PodTemplateList struct { @@ -3863,9 +3863,9 @@ type ReplicationControllerCondition struct { } // +genclient -// +genclient:method=GetScale,verb=get,subresource=scale,result=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/autoscaling/v1.Scale -// +genclient:method=UpdateScale,verb=update,subresource=scale,input=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/autoscaling/v1.Scale,result=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/autoscaling/v1.Scale -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +genclient:method=GetScale,verb=get,subresource=scale,result=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/autoscaling/v1.Scale +// +genclient:method=UpdateScale,verb=update,subresource=scale,input=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/autoscaling/v1.Scale,result=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/autoscaling/v1.Scale +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // ReplicationController represents the configuration of a replication controller. type ReplicationController struct { @@ -3891,7 +3891,7 @@ type ReplicationController struct { Status ReplicationControllerStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // ReplicationControllerList is a collection of replication controllers. type ReplicationControllerList struct { @@ -4374,7 +4374,7 @@ type ServicePort struct { // +genclient // +genclient:skipVerbs=deleteCollection -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // Service is a named abstraction of software service (for example, mysql) consisting of local port // (for example 3306) that the proxy listens on, and the selector that determines which pods @@ -4405,7 +4405,7 @@ const ( ClusterIPNone = "None" ) -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // ServiceList holds a list of services. type ServiceList struct { @@ -4420,8 +4420,8 @@ type ServiceList struct { } // +genclient -// +genclient:method=CreateToken,verb=create,subresource=token,input=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/authentication/v1.TokenRequest,result=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/authentication/v1.TokenRequest -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +genclient:method=CreateToken,verb=create,subresource=token,input=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/authentication/v1.TokenRequest,result=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/authentication/v1.TokenRequest +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // ServiceAccount binds together: // * a name, understood by users, and perhaps by peripheral systems, for an identity @@ -4454,7 +4454,7 @@ type ServiceAccount struct { AutomountServiceAccountToken *bool `json:"automountServiceAccountToken,omitempty" protobuf:"varint,4,opt,name=automountServiceAccountToken"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // ServiceAccountList is a list of ServiceAccount objects type ServiceAccountList struct { @@ -4470,7 +4470,7 @@ type ServiceAccountList struct { } // +genclient -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // Endpoints is a collection of endpoints that implement the actual service. Example: // Name: "mysvc", @@ -4577,7 +4577,7 @@ type EndpointPort struct { AppProtocol *string `json:"appProtocol,omitempty" protobuf:"bytes,4,opt,name=appProtocol"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // EndpointsList is a list of endpoints. type EndpointsList struct { @@ -4970,7 +4970,7 @@ type ResourceList map[ResourceName]resource.Quantity // +genclient // +genclient:nonNamespaced -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // Node is a worker node in Kubernetes. // Each node will have a unique identifier in the cache (i.e. in etcd). @@ -4994,7 +4994,7 @@ type Node struct { Status NodeStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // NodeList is the whole list of all Nodes which have been registered with master. type NodeList struct { @@ -5088,7 +5088,7 @@ type NamespaceCondition struct { // +genclient // +genclient:nonNamespaced // +genclient:skipVerbs=deleteCollection -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // Namespace provides a scope for Names. // Use of multiple namespaces is optional. @@ -5110,7 +5110,7 @@ type Namespace struct { Status NamespaceStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // NamespaceList is a list of Namespaces. type NamespaceList struct { @@ -5125,7 +5125,7 @@ type NamespaceList struct { Items []Namespace `json:"items" protobuf:"bytes,2,rep,name=items"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // Binding ties one object to another; for example, a pod is bound to a node by a scheduler. // Deprecated in 1.7, please use the bindings subresource of pods instead. @@ -5140,7 +5140,7 @@ type Binding struct { Target ObjectReference `json:"target" protobuf:"bytes,2,opt,name=target"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // A list of ephemeral containers used with the Pod ephemeralcontainers subresource. type EphemeralContainers struct { @@ -5161,11 +5161,11 @@ type EphemeralContainers struct { type Preconditions struct { // Specifies the target UID. // +optional - UID *types.UID `json:"uid,omitempty" protobuf:"bytes,1,opt,name=uid,casttype=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/types.UID"` + UID *types.UID `json:"uid,omitempty" protobuf:"bytes,1,opt,name=uid,casttype=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/types.UID"` } // +k8s:conversion-gen:explicit-from=net/url.Values -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PodLogOptions is the query options for a Pod's logs REST call. type PodLogOptions struct { @@ -5217,7 +5217,7 @@ type PodLogOptions struct { } // +k8s:conversion-gen:explicit-from=net/url.Values -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PodAttachOptions is the query options to a Pod's remote attach call. // --- @@ -5255,7 +5255,7 @@ type PodAttachOptions struct { } // +k8s:conversion-gen:explicit-from=net/url.Values -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PodExecOptions is the query options to a Pod's remote exec call. // --- @@ -5294,7 +5294,7 @@ type PodExecOptions struct { } // +k8s:conversion-gen:explicit-from=net/url.Values -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PodPortForwardOptions is the query options to a Pod's port forward call // when using WebSockets. @@ -5312,7 +5312,7 @@ type PodPortForwardOptions struct { } // +k8s:conversion-gen:explicit-from=net/url.Values -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // PodProxyOptions is the query options to a Pod's proxy call. type PodProxyOptions struct { @@ -5324,7 +5324,7 @@ type PodProxyOptions struct { } // +k8s:conversion-gen:explicit-from=net/url.Values -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // NodeProxyOptions is the query options to a Node's proxy call. type NodeProxyOptions struct { @@ -5336,7 +5336,7 @@ type NodeProxyOptions struct { } // +k8s:conversion-gen:explicit-from=net/url.Values -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // ServiceProxyOptions is the query options to a Service's proxy call. type ServiceProxyOptions struct { @@ -5366,7 +5366,7 @@ type ServiceProxyOptions struct { // will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control. // Instead of using this type, create a locally provided and used type that is well-focused on your reference. // For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 . -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object type ObjectReference struct { // Kind of the referent. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds @@ -5383,7 +5383,7 @@ type ObjectReference struct { // UID of the referent. // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids // +optional - UID types.UID `json:"uid,omitempty" protobuf:"bytes,4,opt,name=uid,casttype=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/types.UID"` + UID types.UID `json:"uid,omitempty" protobuf:"bytes,4,opt,name=uid,casttype=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/types.UID"` // API version of the referent. // +optional APIVersion string `json:"apiVersion,omitempty" protobuf:"bytes,5,opt,name=apiVersion"` @@ -5428,7 +5428,7 @@ type TypedLocalObjectReference struct { Name string `json:"name" protobuf:"bytes,3,opt,name=name"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // SerializedReference is a reference to serialized object. type SerializedReference struct { @@ -5457,7 +5457,7 @@ const ( ) // +genclient -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // Event is a report of an event somewhere in the cluster. Events // have a limited retention time and triggers and messages may evolve @@ -5541,7 +5541,7 @@ type EventSeries struct { // +k8s:deprecated=state,protobuf=3 } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // EventList is a list of events. type EventList struct { @@ -5555,7 +5555,7 @@ type EventList struct { Items []Event `json:"items" protobuf:"bytes,2,rep,name=items"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // List holds a list of objects, which may not be known by the server. type List metav1.List @@ -5600,7 +5600,7 @@ type LimitRangeSpec struct { } // +genclient -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // LimitRange sets resource usage limits for each kind of resource in a Namespace. type LimitRange struct { @@ -5616,7 +5616,7 @@ type LimitRange struct { Spec LimitRangeSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // LimitRangeList is a list of LimitRange items. type LimitRangeList struct { @@ -5759,7 +5759,7 @@ type ResourceQuotaStatus struct { } // +genclient -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // ResourceQuota sets aggregate quota restrictions enforced per namespace type ResourceQuota struct { @@ -5780,7 +5780,7 @@ type ResourceQuota struct { Status ResourceQuotaStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // ResourceQuotaList is a list of ResourceQuota items. type ResourceQuotaList struct { @@ -5796,7 +5796,7 @@ type ResourceQuotaList struct { } // +genclient -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // Secret holds secret data of a certain type. The total bytes of the values in // the Data field must be less than MaxSecretSize bytes. @@ -5921,7 +5921,7 @@ const ( SecretTypeBootstrapToken SecretType = "bootstrap.kubernetes.io/token" ) -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // SecretList is a list of Secret. type SecretList struct { @@ -5937,7 +5937,7 @@ type SecretList struct { } // +genclient -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // ConfigMap holds configuration data for pods to consume. type ConfigMap struct { @@ -5973,7 +5973,7 @@ type ConfigMap struct { BinaryData map[string][]byte `json:"binaryData,omitempty" protobuf:"bytes,3,rep,name=binaryData"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // ConfigMapList is a resource containing a list of ConfigMap objects. type ConfigMapList struct { @@ -6015,7 +6015,7 @@ type ComponentCondition struct { // +genclient // +genclient:nonNamespaced -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // ComponentStatus (and ComponentStatusList) holds the cluster validation info. // Deprecated: This API is deprecated in v1.19+ @@ -6033,7 +6033,7 @@ type ComponentStatus struct { Conditions []ComponentCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,2,rep,name=conditions"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // Status of all the conditions for the component as a list of ComponentStatus objects. // Deprecated: This API is deprecated in v1.19+ @@ -6219,7 +6219,7 @@ type WindowsSecurityContextOptions struct { RunAsUserName *string `json:"runAsUserName,omitempty" protobuf:"bytes,3,opt,name=runAsUserName"` } -// +k8s:deepcopy-gen:interfaces=gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object +// +k8s:deepcopy-gen:interfaces=code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/apimachinery/pkg/runtime.Object // RangeAllocation is not a public type. type RangeAllocation struct { diff --git a/adaptor/pod/server/kubernetes/apimachinery/pkg/apis/meta/v1/micro_time.go b/adaptor/pod/server/kubernetes/apimachinery/pkg/apis/meta/v1/micro_time.go new file mode 100644 index 00000000..8eb37f43 --- /dev/null +++ b/adaptor/pod/server/kubernetes/apimachinery/pkg/apis/meta/v1/micro_time.go @@ -0,0 +1,181 @@ +/* +Copyright 2016 The Kubernetes 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 v1 + +import ( + "encoding/json" + "time" +) + +const RFC3339Micro = "2006-01-02T15:04:05.000000Z07:00" + +// MicroTime is version of Time with microsecond level precision. +// +// +protobuf.options.marshal=false +// +protobuf.as=Timestamp +// +protobuf.options.(gogoproto.goproto_stringer)=false +type MicroTime struct { + time.Time `protobuf:"-"` +} + +// DeepCopy returns a deep-copy of the MicroTime value. The underlying time.Time +// type is effectively immutable in the time API, so it is safe to +// copy-by-assign, despite the presence of (unexported) Pointer fields. +func (t *MicroTime) DeepCopyInto(out *MicroTime) { + *out = *t +} + +// NewMicroTime returns a wrapped instance of the provided time +func NewMicroTime(time time.Time) MicroTime { + return MicroTime{time} +} + +// DateMicro returns the MicroTime corresponding to the supplied parameters +// by wrapping time.Date. +func DateMicro(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) MicroTime { + return MicroTime{time.Date(year, month, day, hour, min, sec, nsec, loc)} +} + +// NowMicro returns the current local time. +func NowMicro() MicroTime { + return MicroTime{time.Now()} +} + +// IsZero returns true if the value is nil or time is zero. +func (t *MicroTime) IsZero() bool { + if t == nil { + return true + } + return t.Time.IsZero() +} + +// Before reports whether the time instant t is before u. +func (t *MicroTime) Before(u *MicroTime) bool { + if t != nil && u != nil { + return t.Time.Before(u.Time) + } + return false +} + +// Equal reports whether the time instant t is equal to u. +func (t *MicroTime) Equal(u *MicroTime) bool { + if t == nil && u == nil { + return true + } + if t != nil && u != nil { + return t.Time.Equal(u.Time) + } + return false +} + +// BeforeTime reports whether the time instant t is before second-lever precision u. +func (t *MicroTime) BeforeTime(u *Time) bool { + if t != nil && u != nil { + return t.Time.Before(u.Time) + } + return false +} + +// EqualTime reports whether the time instant t is equal to second-lever precision u. +func (t *MicroTime) EqualTime(u *Time) bool { + if t == nil && u == nil { + return true + } + if t != nil && u != nil { + return t.Time.Equal(u.Time) + } + return false +} + +// UnixMicro returns the local time corresponding to the given Unix time +// by wrapping time.Unix. +func UnixMicro(sec int64, nsec int64) MicroTime { + return MicroTime{time.Unix(sec, nsec)} +} + +// UnmarshalJSON implements the json.Unmarshaller interface. +func (t *MicroTime) UnmarshalJSON(b []byte) error { + if len(b) == 4 && string(b) == "null" { + t.Time = time.Time{} + return nil + } + + var str string + err := json.Unmarshal(b, &str) + if err != nil { + return err + } + + pt, err := time.Parse(RFC3339Micro, str) + if err != nil { + return err + } + + t.Time = pt.Local() + return nil +} + +// UnmarshalQueryParameter converts from a URL query parameter value to an object +func (t *MicroTime) UnmarshalQueryParameter(str string) error { + if len(str) == 0 { + t.Time = time.Time{} + return nil + } + // Tolerate requests from older clients that used JSON serialization to build query params + if len(str) == 4 && str == "null" { + t.Time = time.Time{} + return nil + } + + pt, err := time.Parse(RFC3339Micro, str) + if err != nil { + return err + } + + t.Time = pt.Local() + return nil +} + +// MarshalJSON implements the json.Marshaler interface. +func (t MicroTime) MarshalJSON() ([]byte, error) { + if t.IsZero() { + // Encode unset/nil objects as JSON's "null". + return []byte("null"), nil + } + + return json.Marshal(t.UTC().Format(RFC3339Micro)) +} + +// OpenAPISchemaType is used by the kube-openapi generator when constructing +// the OpenAPI spec of this type. +// +// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators +func (_ MicroTime) OpenAPISchemaType() []string { return []string{"string"} } + +// OpenAPISchemaFormat is used by the kube-openapi generator when constructing +// the OpenAPI spec of this type. +func (_ MicroTime) OpenAPISchemaFormat() string { return "date-time" } + +// MarshalQueryParameter converts to a URL query parameter value +func (t MicroTime) MarshalQueryParameter() (string, error) { + if t.IsZero() { + // Encode unset/nil objects as an empty string + return "", nil + } + + return t.UTC().Format(RFC3339Micro), nil +} diff --git a/adaptor/pod/server/kubernetes/apimachinery/pkg/apis/meta/v1/time.go b/adaptor/pod/server/kubernetes/apimachinery/pkg/apis/meta/v1/time.go new file mode 100644 index 00000000..421770d4 --- /dev/null +++ b/adaptor/pod/server/kubernetes/apimachinery/pkg/apis/meta/v1/time.go @@ -0,0 +1,182 @@ +/* +Copyright 2014 The Kubernetes 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 v1 + +import ( + "encoding/json" + "time" +) + +// Time is a wrapper around time.Time which supports correct +// marshaling to YAML and JSON. Wrappers are provided for many +// of the factory methods that the time package offers. +// +// +protobuf.options.marshal=false +// +protobuf.as=Timestamp +// +protobuf.options.(gogoproto.goproto_stringer)=false +type Time struct { + time.Time `protobuf:"-"` +} + +// DeepCopyInto creates a deep-copy of the Time value. The underlying time.Time +// type is effectively immutable in the time API, so it is safe to +// copy-by-assign, despite the presence of (unexported) Pointer fields. +func (t *Time) DeepCopyInto(out *Time) { + *out = *t +} + +// NewTime returns a wrapped instance of the provided time +func NewTime(time time.Time) Time { + return Time{time} +} + +// Date returns the Time corresponding to the supplied parameters +// by wrapping time.Date. +func Date(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) Time { + return Time{time.Date(year, month, day, hour, min, sec, nsec, loc)} +} + +// Now returns the current local time. +func Now() Time { + return Time{time.Now()} +} + +// IsZero returns true if the value is nil or time is zero. +func (t *Time) IsZero() bool { + if t == nil { + return true + } + return t.Time.IsZero() +} + +// Before reports whether the time instant t is before u. +func (t *Time) Before(u *Time) bool { + if t != nil && u != nil { + return t.Time.Before(u.Time) + } + return false +} + +// Equal reports whether the time instant t is equal to u. +func (t *Time) Equal(u *Time) bool { + if t == nil && u == nil { + return true + } + if t != nil && u != nil { + return t.Time.Equal(u.Time) + } + return false +} + +// Unix returns the local time corresponding to the given Unix time +// by wrapping time.Unix. +func Unix(sec int64, nsec int64) Time { + return Time{time.Unix(sec, nsec)} +} + +// Rfc3339Copy returns a copy of the Time at second-level precision. +func (t Time) Rfc3339Copy() Time { + copied, _ := time.Parse(time.RFC3339, t.Format(time.RFC3339)) + return Time{copied} +} + +// UnmarshalJSON implements the json.Unmarshaller interface. +func (t *Time) UnmarshalJSON(b []byte) error { + if len(b) == 4 && string(b) == "null" { + t.Time = time.Time{} + return nil + } + + var str string + err := json.Unmarshal(b, &str) + if err != nil { + return err + } + + pt, err := time.Parse(time.RFC3339, str) + if err != nil { + return err + } + + t.Time = pt.Local() + return nil +} + +// UnmarshalQueryParameter converts from a URL query parameter value to an object +func (t *Time) UnmarshalQueryParameter(str string) error { + if len(str) == 0 { + t.Time = time.Time{} + return nil + } + // Tolerate requests from older clients that used JSON serialization to build query params + if len(str) == 4 && str == "null" { + t.Time = time.Time{} + return nil + } + + pt, err := time.Parse(time.RFC3339, str) + if err != nil { + return err + } + + t.Time = pt.Local() + return nil +} + +// MarshalJSON implements the json.Marshaler interface. +func (t Time) MarshalJSON() ([]byte, error) { + if t.IsZero() { + // Encode unset/nil objects as JSON's "null". + return []byte("null"), nil + } + buf := make([]byte, 0, len(time.RFC3339)+2) + buf = append(buf, '"') + // time cannot contain non escapable JSON characters + buf = t.UTC().AppendFormat(buf, time.RFC3339) + buf = append(buf, '"') + return buf, nil +} + +// ToUnstructured implements the value.UnstructuredConverter interface. +func (t Time) ToUnstructured() interface{} { + if t.IsZero() { + return nil + } + buf := make([]byte, 0, len(time.RFC3339)) + buf = t.UTC().AppendFormat(buf, time.RFC3339) + return string(buf) +} + +// OpenAPISchemaType is used by the kube-openapi generator when constructing +// the OpenAPI spec of this type. +// +// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators +func (_ Time) OpenAPISchemaType() []string { return []string{"string"} } + +// OpenAPISchemaFormat is used by the kube-openapi generator when constructing +// the OpenAPI spec of this type. +func (_ Time) OpenAPISchemaFormat() string { return "date-time" } + +// MarshalQueryParameter converts to a URL query parameter value +func (t Time) MarshalQueryParameter() (string, error) { + if t.IsZero() { + // Encode unset/nil objects as an empty string + return "", nil + } + + return t.UTC().Format(time.RFC3339), nil +} diff --git a/adaptor/pod/server/kubernetes/apimachinery/pkg/apis/meta/v1/types.go b/adaptor/pod/server/kubernetes/apimachinery/pkg/apis/meta/v1/types.go new file mode 100644 index 00000000..79e2ad48 --- /dev/null +++ b/adaptor/pod/server/kubernetes/apimachinery/pkg/apis/meta/v1/types.go @@ -0,0 +1,1436 @@ +/* +Copyright 2015 The Kubernetes 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 v1 contains API types that are common to all versions. +// +// The package contains two categories of types: +// - external (serialized) types that lack their own version (e.g TypeMeta) +// - internal (never-serialized) types that are needed by several different +// api groups, and so live here, to avoid duplication and/or import loops +// (e.g. LabelSelector). +// In the future, we will probably move these categories of objects into +// separate packages. +package v1 + +import ( + "fmt" + "strings" + + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" +) + +// TypeMeta describes an individual object in an API response or request +// with strings representing the type of the object and its API schema version. +// Structures that are versioned or persisted should inline TypeMeta. +// +// +k8s:deepcopy-gen=false +type TypeMeta struct { + // Kind is a string value representing the REST resource this object represents. + // Servers may infer this from the endpoint the client submits requests to. + // Cannot be updated. + // In CamelCase. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + // +optional + Kind string `json:"kind,omitempty" protobuf:"bytes,1,opt,name=kind"` + + // APIVersion defines the versioned schema of this representation of an object. + // Servers should convert recognized schemas to the latest internal value, and + // may reject unrecognized values. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + // +optional + APIVersion string `json:"apiVersion,omitempty" protobuf:"bytes,2,opt,name=apiVersion"` +} + +// ListMeta describes metadata that synthetic resources must have, including lists and +// various status objects. A resource may have only one of {ObjectMeta, ListMeta}. +type ListMeta struct { + // selfLink is a URL representing this object. + // Populated by the system. + // Read-only. + // + // DEPRECATED + // Kubernetes will stop propagating this field in 1.20 release and the field is planned + // to be removed in 1.21 release. + // +optional + SelfLink string `json:"selfLink,omitempty" protobuf:"bytes,1,opt,name=selfLink"` + + // String that identifies the server's internal version of this object that + // can be used by clients to determine when objects have changed. + // Value must be treated as opaque by clients and passed unmodified back to the server. + // Populated by the system. + // Read-only. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + // +optional + ResourceVersion string `json:"resourceVersion,omitempty" protobuf:"bytes,2,opt,name=resourceVersion"` + + // continue may be set if the user set a limit on the number of items returned, and indicates that + // the server has more data available. The value is opaque and may be used to issue another request + // to the endpoint that served this list to retrieve the next set of available objects. Continuing a + // consistent list may not be possible if the server configuration has changed or more than a few + // minutes have passed. The resourceVersion field returned when using this continue value will be + // identical to the value in the first response, unless you have received this token from an error + // message. + Continue string `json:"continue,omitempty" protobuf:"bytes,3,opt,name=continue"` + + // remainingItemCount is the number of subsequent items in the list which are not included in this + // list response. If the list request contained label or field selectors, then the number of + // remaining items is unknown and the field will be left unset and omitted during serialization. + // If the list is complete (either because it is not chunking or because this is the last chunk), + // then there are no more remaining items and this field will be left unset and omitted during + // serialization. + // Servers older than v1.15 do not set this field. + // The intended use of the remainingItemCount is *estimating* the size of a collection. Clients + // should not rely on the remainingItemCount to be set or to be exact. + // +optional + RemainingItemCount *int64 `json:"remainingItemCount,omitempty" protobuf:"bytes,4,opt,name=remainingItemCount"` +} + +// Field path constants that are specific to the internal API +// representation. +const ( + ObjectNameField = "metadata.name" +) + +// These are internal finalizer values for Kubernetes-like APIs, must be qualified name unless defined here +const ( + FinalizerOrphanDependents = "orphan" + FinalizerDeleteDependents = "foregroundDeletion" +) + +// ObjectMeta is metadata that all persisted resources must have, which includes all objects +// users must create. +type ObjectMeta struct { + // Name must be unique within a namespace. Is required when creating resources, although + // some resources may allow a client to request the generation of an appropriate name + // automatically. Name is primarily intended for creation idempotence and configuration + // definition. + // Cannot be updated. + // More info: http://kubernetes.io/docs/user-guide/identifiers#names + // +optional + Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` + + // GenerateName is an optional prefix, used by the server, to generate a unique + // name ONLY IF the Name field has not been provided. + // If this field is used, the name returned to the client will be different + // than the name passed. This value will also be combined with a unique suffix. + // The provided value has the same validation rules as the Name field, + // and may be truncated by the length of the suffix required to make the value + // unique on the server. + // + // If this field is specified and the generated name exists, the server will + // NOT return a 409 - instead, it will either return 201 Created or 500 with Reason + // ServerTimeout indicating a unique name could not be found in the time allotted, and the client + // should retry (optionally after the time indicated in the Retry-After header). + // + // Applied only if Name is not specified. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency + // +optional + GenerateName string `json:"generateName,omitempty" protobuf:"bytes,2,opt,name=generateName"` + + // Namespace defines the space within which each name must be unique. An empty namespace is + // equivalent to the "default" namespace, but "default" is the canonical representation. + // Not all objects are required to be scoped to a namespace - the value of this field for + // those objects will be empty. + // + // Must be a DNS_LABEL. + // Cannot be updated. + // More info: http://kubernetes.io/docs/user-guide/namespaces + // +optional + Namespace string `json:"namespace,omitempty" protobuf:"bytes,3,opt,name=namespace"` + + // SelfLink is a URL representing this object. + // Populated by the system. + // Read-only. + // + // DEPRECATED + // Kubernetes will stop propagating this field in 1.20 release and the field is planned + // to be removed in 1.21 release. + // +optional + SelfLink string `json:"selfLink,omitempty" protobuf:"bytes,4,opt,name=selfLink"` + + // UID is the unique in time and space value for this object. It is typically generated by + // the server on successful creation of a resource and is not allowed to change on PUT + // operations. + // + // Populated by the system. + // Read-only. + // More info: http://kubernetes.io/docs/user-guide/identifiers#uids + // +optional + UID types.UID `json:"uid,omitempty" protobuf:"bytes,5,opt,name=uid,casttype=k8s.io/kubernetes/pkg/types.UID"` + + // An opaque value that represents the internal version of this object that can + // be used by clients to determine when objects have changed. May be used for optimistic + // concurrency, change detection, and the watch operation on a resource or set of resources. + // Clients must treat these values as opaque and passed unmodified back to the server. + // They may only be valid for a particular resource or set of resources. + // + // Populated by the system. + // Read-only. + // Value must be treated as opaque by clients and . + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + // +optional + ResourceVersion string `json:"resourceVersion,omitempty" protobuf:"bytes,6,opt,name=resourceVersion"` + + // A sequence number representing a specific generation of the desired state. + // Populated by the system. Read-only. + // +optional + Generation int64 `json:"generation,omitempty" protobuf:"varint,7,opt,name=generation"` + + // CreationTimestamp is a timestamp representing the server time when this object was + // created. It is not guaranteed to be set in happens-before order across separate operations. + // Clients may not set this value. It is represented in RFC3339 form and is in UTC. + // + // Populated by the system. + // Read-only. + // Null for lists. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + CreationTimestamp Time `json:"creationTimestamp,omitempty" protobuf:"bytes,8,opt,name=creationTimestamp"` + + // DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This + // field is set by the server when a graceful deletion is requested by the user, and is not + // directly settable by a client. The resource is expected to be deleted (no longer visible + // from resource lists, and not reachable by name) after the time in this field, once the + // finalizers list is empty. As long as the finalizers list contains items, deletion is blocked. + // Once the deletionTimestamp is set, this value may not be unset or be set further into the + // future, although it may be shortened or the resource may be deleted prior to this time. + // For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react + // by sending a graceful termination signal to the containers in the pod. After that 30 seconds, + // the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, + // remove the pod from the API. In the presence of network partitions, this object may still + // exist after this timestamp, until an administrator or automated process can determine the + // resource is fully terminated. + // If not set, graceful deletion of the object has not been requested. + // + // Populated by the system when a graceful deletion is requested. + // Read-only. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + DeletionTimestamp *Time `json:"deletionTimestamp,omitempty" protobuf:"bytes,9,opt,name=deletionTimestamp"` + + // Number of seconds allowed for this object to gracefully terminate before + // it will be removed from the system. Only set when deletionTimestamp is also set. + // May only be shortened. + // Read-only. + // +optional + DeletionGracePeriodSeconds *int64 `json:"deletionGracePeriodSeconds,omitempty" protobuf:"varint,10,opt,name=deletionGracePeriodSeconds"` + + // Map of string keys and values that can be used to organize and categorize + // (scope and select) objects. May match selectors of replication controllers + // and services. + // More info: http://kubernetes.io/docs/user-guide/labels + // +optional + Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"` + + // Annotations is an unstructured key value map stored with a resource that may be + // set by external tools to store and retrieve arbitrary metadata. They are not + // queryable and should be preserved when modifying objects. + // More info: http://kubernetes.io/docs/user-guide/annotations + // +optional + Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"` + + // List of objects depended by this object. If ALL objects in the list have + // been deleted, this object will be garbage collected. If this object is managed by a controller, + // then an entry in this list will point to this controller, with the controller field set to true. + // There cannot be more than one managing controller. + // +optional + // +patchMergeKey=uid + // +patchStrategy=merge + OwnerReferences []OwnerReference `json:"ownerReferences,omitempty" patchStrategy:"merge" patchMergeKey:"uid" protobuf:"bytes,13,rep,name=ownerReferences"` + + // Must be empty before the object is deleted from the registry. Each entry + // is an identifier for the responsible component that will remove the entry + // from the list. If the deletionTimestamp of the object is non-nil, entries + // in this list can only be removed. + // Finalizers may be processed and removed in any order. Order is NOT enforced + // because it introduces significant risk of stuck finalizers. + // finalizers is a shared field, any actor with permission can reorder it. + // If the finalizer list is processed in order, then this can lead to a situation + // in which the component responsible for the first finalizer in the list is + // waiting for a signal (field value, external system, or other) produced by a + // component responsible for a finalizer later in the list, resulting in a deadlock. + // Without enforced ordering finalizers are free to order amongst themselves and + // are not vulnerable to ordering changes in the list. + // +optional + // +patchStrategy=merge + Finalizers []string `json:"finalizers,omitempty" patchStrategy:"merge" protobuf:"bytes,14,rep,name=finalizers"` + + // The name of the cluster which the object belongs to. + // This is used to distinguish resources with same name and namespace in different clusters. + // This field is not set anywhere right now and apiserver is going to ignore it if set in create or update request. + // +optional + ClusterName string `json:"clusterName,omitempty" protobuf:"bytes,15,opt,name=clusterName"` + + // ManagedFields maps workflow-id and version to the set of fields + // that are managed by that workflow. This is mostly for internal + // housekeeping, and users typically shouldn't need to set or + // understand this field. A workflow can be the user's name, a + // controller's name, or the name of a specific apply path like + // "ci-cd". The set of fields is always in the version that the + // workflow used when modifying the object. + // + // +optional + ManagedFields []ManagedFieldsEntry `json:"managedFields,omitempty" protobuf:"bytes,17,rep,name=managedFields"` +} + +const ( + // NamespaceDefault means the object is in the default namespace which is applied when not specified by clients + NamespaceDefault = "default" + // NamespaceAll is the default argument to specify on a context when you want to list or filter resources across all namespaces + NamespaceAll = "" + // NamespaceNone is the argument for a context when there is no namespace. + NamespaceNone = "" + // NamespaceSystem is the system namespace where we place system components. + NamespaceSystem = "kube-system" + // NamespacePublic is the namespace where we place public info (ConfigMaps) + NamespacePublic = "kube-public" +) + +// OwnerReference contains enough information to let you identify an owning +// object. An owning object must be in the same namespace as the dependent, or +// be cluster-scoped, so there is no namespace field. +type OwnerReference struct { + // API version of the referent. + APIVersion string `json:"apiVersion" protobuf:"bytes,5,opt,name=apiVersion"` + // Kind of the referent. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + Kind string `json:"kind" protobuf:"bytes,1,opt,name=kind"` + // Name of the referent. + // More info: http://kubernetes.io/docs/user-guide/identifiers#names + Name string `json:"name" protobuf:"bytes,3,opt,name=name"` + // UID of the referent. + // More info: http://kubernetes.io/docs/user-guide/identifiers#uids + UID types.UID `json:"uid" protobuf:"bytes,4,opt,name=uid,casttype=k8s.io/apimachinery/pkg/types.UID"` + // If true, this reference points to the managing controller. + // +optional + Controller *bool `json:"controller,omitempty" protobuf:"varint,6,opt,name=controller"` + // If true, AND if the owner has the "foregroundDeletion" finalizer, then + // the owner cannot be deleted from the key-value store until this + // reference is removed. + // Defaults to false. + // To set this field, a user needs "delete" permission of the owner, + // otherwise 422 (Unprocessable Entity) will be returned. + // +optional + BlockOwnerDeletion *bool `json:"blockOwnerDeletion,omitempty" protobuf:"varint,7,opt,name=blockOwnerDeletion"` +} + +// +k8s:conversion-gen:explicit-from=net/url.Values +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ListOptions is the query options to a standard REST list call. +type ListOptions struct { + TypeMeta `json:",inline"` + + // A selector to restrict the list of returned objects by their labels. + // Defaults to everything. + // +optional + LabelSelector string `json:"labelSelector,omitempty" protobuf:"bytes,1,opt,name=labelSelector"` + // A selector to restrict the list of returned objects by their fields. + // Defaults to everything. + // +optional + FieldSelector string `json:"fieldSelector,omitempty" protobuf:"bytes,2,opt,name=fieldSelector"` + + // +k8s:deprecated=includeUninitialized,protobuf=6 + + // Watch for changes to the described resources and return them as a stream of + // add, update, and remove notifications. Specify resourceVersion. + // +optional + Watch bool `json:"watch,omitempty" protobuf:"varint,3,opt,name=watch"` + // allowWatchBookmarks requests watch events with type "BOOKMARK". + // Servers that do not implement bookmarks may ignore this flag and + // bookmarks are sent at the server's discretion. Clients should not + // assume bookmarks are returned at any specific interval, nor may they + // assume the server will send any BOOKMARK event during a session. + // If this is not a watch, this field is ignored. + // If the feature gate WatchBookmarks is not enabled in apiserver, + // this field is ignored. + // +optional + AllowWatchBookmarks bool `json:"allowWatchBookmarks,omitempty" protobuf:"varint,9,opt,name=allowWatchBookmarks"` + + // resourceVersion sets a constraint on what resource versions a request may be served from. + // See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for + // details. + // + // Defaults to unset + // +optional + ResourceVersion string `json:"resourceVersion,omitempty" protobuf:"bytes,4,opt,name=resourceVersion"` + + // resourceVersionMatch determines how resourceVersion is applied to list calls. + // It is highly recommended that resourceVersionMatch be set for list calls where + // resourceVersion is set + // See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for + // details. + // + // Defaults to unset + // +optional + ResourceVersionMatch ResourceVersionMatch `json:"resourceVersionMatch,omitempty" protobuf:"bytes,10,opt,name=resourceVersionMatch,casttype=ResourceVersionMatch"` + // Timeout for the list/watch call. + // This limits the duration of the call, regardless of any activity or inactivity. + // +optional + TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty" protobuf:"varint,5,opt,name=timeoutSeconds"` + + // limit is a maximum number of responses to return for a list call. If more items exist, the + // server will set the `continue` field on the list metadata to a value that can be used with the + // same initial query to retrieve the next set of results. Setting a limit may return fewer than + // the requested amount of items (up to zero items) in the event all requested objects are + // filtered out and clients should only use the presence of the continue field to determine whether + // more results are available. Servers may choose not to support the limit argument and will return + // all of the available results. If limit is specified and the continue field is empty, clients may + // assume that no more results are available. This field is not supported if watch is true. + // + // The server guarantees that the objects returned when using continue will be identical to issuing + // a single list call without a limit - that is, no objects created, modified, or deleted after the + // first request is issued will be included in any subsequent continued requests. This is sometimes + // referred to as a consistent snapshot, and ensures that a client that is using limit to receive + // smaller chunks of a very large result can ensure they see all possible objects. If objects are + // updated during a chunked list the version of the object that was present at the time the first list + // result was calculated is returned. + Limit int64 `json:"limit,omitempty" protobuf:"varint,7,opt,name=limit"` + // The continue option should be set when retrieving more results from the server. Since this value is + // server defined, clients may only use the continue value from a previous query result with identical + // query parameters (except for the value of continue) and the server may reject a continue value it + // does not recognize. If the specified continue value is no longer valid whether due to expiration + // (generally five to fifteen minutes) or a configuration change on the server, the server will + // respond with a 410 ResourceExpired error together with a continue token. If the client needs a + // consistent list, it must restart their list without the continue field. Otherwise, the client may + // send another list request with the token received with the 410 error, the server will respond with + // a list starting from the next key, but from the latest snapshot, which is inconsistent from the + // previous list results - objects that are created, modified, or deleted after the first list request + // will be included in the response, as long as their keys are after the "next key". + // + // This field is not supported when watch is true. Clients may start a watch from the last + // resourceVersion value returned by the server and not miss any modifications. + Continue string `json:"continue,omitempty" protobuf:"bytes,8,opt,name=continue"` +} + +// resourceVersionMatch specifies how the resourceVersion parameter is applied. resourceVersionMatch +// may only be set if resourceVersion is also set. +// +// "NotOlderThan" matches data at least as new as the provided resourceVersion. +// "Exact" matches data at the exact resourceVersion provided. +// +// See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for +// details. +type ResourceVersionMatch string + +const ( + // ResourceVersionMatchNotOlderThan matches data at least as new as the provided + // resourceVersion. + ResourceVersionMatchNotOlderThan ResourceVersionMatch = "NotOlderThan" + // ResourceVersionMatchExact matches data at the exact resourceVersion + // provided. + ResourceVersionMatchExact ResourceVersionMatch = "Exact" +) + +// +k8s:conversion-gen:explicit-from=net/url.Values +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// GetOptions is the standard query options to the standard REST get call. +type GetOptions struct { + TypeMeta `json:",inline"` + // resourceVersion sets a constraint on what resource versions a request may be served from. + // See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for + // details. + // + // Defaults to unset + // +optional + ResourceVersion string `json:"resourceVersion,omitempty" protobuf:"bytes,1,opt,name=resourceVersion"` + // +k8s:deprecated=includeUninitialized,protobuf=2 +} + +// DeletionPropagation decides if a deletion will propagate to the dependents of +// the object, and how the garbage collector will handle the propagation. +type DeletionPropagation string + +const ( + // Orphans the dependents. + DeletePropagationOrphan DeletionPropagation = "Orphan" + // Deletes the object from the key-value store, the garbage collector will + // delete the dependents in the background. + DeletePropagationBackground DeletionPropagation = "Background" + // The object exists in the key-value store until the garbage collector + // deletes all the dependents whose ownerReference.blockOwnerDeletion=true + // from the key-value store. API sever will put the "foregroundDeletion" + // finalizer on the object, and sets its deletionTimestamp. This policy is + // cascading, i.e., the dependents will be deleted with Foreground. + DeletePropagationForeground DeletionPropagation = "Foreground" +) + +const ( + // DryRunAll means to complete all processing stages, but don't + // persist changes to storage. + DryRunAll = "All" +) + +// +k8s:conversion-gen:explicit-from=net/url.Values +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// DeleteOptions may be provided when deleting an API object. +type DeleteOptions struct { + TypeMeta `json:",inline"` + + // The duration in seconds before the object should be deleted. Value must be non-negative integer. + // The value zero indicates delete immediately. If this value is nil, the default grace period for the + // specified type will be used. + // Defaults to a per object value if not specified. zero means delete immediately. + // +optional + GracePeriodSeconds *int64 `json:"gracePeriodSeconds,omitempty" protobuf:"varint,1,opt,name=gracePeriodSeconds"` + + // Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be + // returned. + // +k8s:conversion-gen=false + // +optional + Preconditions *Preconditions `json:"preconditions,omitempty" protobuf:"bytes,2,opt,name=preconditions"` + + // Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. + // Should the dependent objects be orphaned. If true/false, the "orphan" + // finalizer will be added to/removed from the object's finalizers list. + // Either this field or PropagationPolicy may be set, but not both. + // +optional + OrphanDependents *bool `json:"orphanDependents,omitempty" protobuf:"varint,3,opt,name=orphanDependents"` + + // Whether and how garbage collection will be performed. + // Either this field or OrphanDependents may be set, but not both. + // The default policy is decided by the existing finalizer set in the + // metadata.finalizers and the resource-specific default policy. + // Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - + // allow the garbage collector to delete the dependents in the background; + // 'Foreground' - a cascading policy that deletes all dependents in the + // foreground. + // +optional + PropagationPolicy *DeletionPropagation `json:"propagationPolicy,omitempty" protobuf:"varint,4,opt,name=propagationPolicy"` + + // When present, indicates that modifications should not be + // persisted. An invalid or unrecognized dryRun directive will + // result in an error response and no further processing of the + // request. Valid values are: + // - All: all dry run stages will be processed + // +optional + DryRun []string `json:"dryRun,omitempty" protobuf:"bytes,5,rep,name=dryRun"` +} + +// +k8s:conversion-gen:explicit-from=net/url.Values +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CreateOptions may be provided when creating an API object. +type CreateOptions struct { + TypeMeta `json:",inline"` + + // When present, indicates that modifications should not be + // persisted. An invalid or unrecognized dryRun directive will + // result in an error response and no further processing of the + // request. Valid values are: + // - All: all dry run stages will be processed + // +optional + DryRun []string `json:"dryRun,omitempty" protobuf:"bytes,1,rep,name=dryRun"` + // +k8s:deprecated=includeUninitialized,protobuf=2 + + // fieldManager is a name associated with the actor or entity + // that is making these changes. The value must be less than or + // 128 characters long, and only contain printable characters, + // as defined by https://golang.org/pkg/unicode/#IsPrint. + // +optional + FieldManager string `json:"fieldManager,omitempty" protobuf:"bytes,3,name=fieldManager"` +} + +// +k8s:conversion-gen:explicit-from=net/url.Values +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PatchOptions may be provided when patching an API object. +// PatchOptions is meant to be a superset of UpdateOptions. +type PatchOptions struct { + TypeMeta `json:",inline"` + + // When present, indicates that modifications should not be + // persisted. An invalid or unrecognized dryRun directive will + // result in an error response and no further processing of the + // request. Valid values are: + // - All: all dry run stages will be processed + // +optional + DryRun []string `json:"dryRun,omitempty" protobuf:"bytes,1,rep,name=dryRun"` + + // Force is going to "force" Apply requests. It means user will + // re-acquire conflicting fields owned by other people. Force + // flag must be unset for non-apply patch requests. + // +optional + Force *bool `json:"force,omitempty" protobuf:"varint,2,opt,name=force"` + + // fieldManager is a name associated with the actor or entity + // that is making these changes. The value must be less than or + // 128 characters long, and only contain printable characters, + // as defined by https://golang.org/pkg/unicode/#IsPrint. This + // field is required for apply requests + // (application/apply-patch) but optional for non-apply patch + // types (JsonPatch, MergePatch, StrategicMergePatch). + // +optional + FieldManager string `json:"fieldManager,omitempty" protobuf:"bytes,3,name=fieldManager"` +} + +// ApplyOptions may be provided when applying an API object. +// FieldManager is required for apply requests. +// ApplyOptions is equivalent to PatchOptions. It is provided as a convenience with documentation +// that speaks specifically to how the options fields relate to apply. +type ApplyOptions struct { + TypeMeta `json:",inline"` + + // When present, indicates that modifications should not be + // persisted. An invalid or unrecognized dryRun directive will + // result in an error response and no further processing of the + // request. Valid values are: + // - All: all dry run stages will be processed + // +optional + DryRun []string `json:"dryRun,omitempty" protobuf:"bytes,1,rep,name=dryRun"` + + // Force is going to "force" Apply requests. It means user will + // re-acquire conflicting fields owned by other people. + Force bool `json:"force" protobuf:"varint,2,opt,name=force"` + + // fieldManager is a name associated with the actor or entity + // that is making these changes. The value must be less than or + // 128 characters long, and only contain printable characters, + // as defined by https://golang.org/pkg/unicode/#IsPrint. This + // field is required. + FieldManager string `json:"fieldManager" protobuf:"bytes,3,name=fieldManager"` +} + +func (o ApplyOptions) ToPatchOptions() PatchOptions { + return PatchOptions{DryRun: o.DryRun, Force: &o.Force, FieldManager: o.FieldManager} +} + +// +k8s:conversion-gen:explicit-from=net/url.Values +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// UpdateOptions may be provided when updating an API object. +// All fields in UpdateOptions should also be present in PatchOptions. +type UpdateOptions struct { + TypeMeta `json:",inline"` + + // When present, indicates that modifications should not be + // persisted. An invalid or unrecognized dryRun directive will + // result in an error response and no further processing of the + // request. Valid values are: + // - All: all dry run stages will be processed + // +optional + DryRun []string `json:"dryRun,omitempty" protobuf:"bytes,1,rep,name=dryRun"` + + // fieldManager is a name associated with the actor or entity + // that is making these changes. The value must be less than or + // 128 characters long, and only contain printable characters, + // as defined by https://golang.org/pkg/unicode/#IsPrint. + // +optional + FieldManager string `json:"fieldManager,omitempty" protobuf:"bytes,2,name=fieldManager"` +} + +// Preconditions must be fulfilled before an operation (update, delete, etc.) is carried out. +type Preconditions struct { + // Specifies the target UID. + // +optional + UID *types.UID `json:"uid,omitempty" protobuf:"bytes,1,opt,name=uid,casttype=k8s.io/apimachinery/pkg/types.UID"` + // Specifies the target ResourceVersion + // +optional + ResourceVersion *string `json:"resourceVersion,omitempty" protobuf:"bytes,2,opt,name=resourceVersion"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Status is a return value for calls that don't return other objects. +type Status struct { + TypeMeta `json:",inline"` + // Standard list metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + // +optional + ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Status of the operation. + // One of: "Success" or "Failure". + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status + // +optional + Status string `json:"status,omitempty" protobuf:"bytes,2,opt,name=status"` + // A human-readable description of the status of this operation. + // +optional + Message string `json:"message,omitempty" protobuf:"bytes,3,opt,name=message"` + // A machine-readable description of why this operation is in the + // "Failure" status. If this value is empty there + // is no information available. A Reason clarifies an HTTP status + // code but does not override it. + // +optional + Reason StatusReason `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason,casttype=StatusReason"` + // Extended data associated with the reason. Each reason may define its + // own extended details. This field is optional and the data returned + // is not guaranteed to conform to any schema except that defined by + // the reason type. + // +optional + Details *StatusDetails `json:"details,omitempty" protobuf:"bytes,5,opt,name=details"` + // Suggested HTTP return code for this status, 0 if not set. + // +optional + Code int32 `json:"code,omitempty" protobuf:"varint,6,opt,name=code"` +} + +// StatusDetails is a set of additional properties that MAY be set by the +// server to provide additional information about a response. The Reason +// field of a Status object defines what attributes will be set. Clients +// must ignore fields that do not match the defined type of each attribute, +// and should assume that any attribute may be empty, invalid, or under +// defined. +type StatusDetails struct { + // The name attribute of the resource associated with the status StatusReason + // (when there is a single name which can be described). + // +optional + Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` + // The group attribute of the resource associated with the status StatusReason. + // +optional + Group string `json:"group,omitempty" protobuf:"bytes,2,opt,name=group"` + // The kind attribute of the resource associated with the status StatusReason. + // On some operations may differ from the requested resource Kind. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + // +optional + Kind string `json:"kind,omitempty" protobuf:"bytes,3,opt,name=kind"` + // UID of the resource. + // (when there is a single resource which can be described). + // More info: http://kubernetes.io/docs/user-guide/identifiers#uids + // +optional + UID types.UID `json:"uid,omitempty" protobuf:"bytes,6,opt,name=uid,casttype=k8s.io/apimachinery/pkg/types.UID"` + // The Causes array includes more details associated with the StatusReason + // failure. Not all StatusReasons may provide detailed causes. + // +optional + Causes []StatusCause `json:"causes,omitempty" protobuf:"bytes,4,rep,name=causes"` + // If specified, the time in seconds before the operation should be retried. Some errors may indicate + // the client must take an alternate action - for those errors this field may indicate how long to wait + // before taking the alternate action. + // +optional + RetryAfterSeconds int32 `json:"retryAfterSeconds,omitempty" protobuf:"varint,5,opt,name=retryAfterSeconds"` +} + +// Values of Status.Status +const ( + StatusSuccess = "Success" + StatusFailure = "Failure" +) + +// StatusReason is an enumeration of possible failure causes. Each StatusReason +// must map to a single HTTP status code, but multiple reasons may map +// to the same HTTP status code. +// TODO: move to apiserver +type StatusReason string + +const ( + // StatusReasonUnknown means the server has declined to indicate a specific reason. + // The details field may contain other information about this error. + // Status code 500. + StatusReasonUnknown StatusReason = "" + + // StatusReasonUnauthorized means the server can be reached and understood the request, but requires + // the user to present appropriate authorization credentials (identified by the WWW-Authenticate header) + // in order for the action to be completed. If the user has specified credentials on the request, the + // server considers them insufficient. + // Status code 401 + StatusReasonUnauthorized StatusReason = "Unauthorized" + + // StatusReasonForbidden means the server can be reached and understood the request, but refuses + // to take any further action. It is the result of the server being configured to deny access for some reason + // to the requested resource by the client. + // Details (optional): + // "kind" string - the kind attribute of the forbidden resource + // on some operations may differ from the requested + // resource. + // "id" string - the identifier of the forbidden resource + // Status code 403 + StatusReasonForbidden StatusReason = "Forbidden" + + // StatusReasonNotFound means one or more resources required for this operation + // could not be found. + // Details (optional): + // "kind" string - the kind attribute of the missing resource + // on some operations may differ from the requested + // resource. + // "id" string - the identifier of the missing resource + // Status code 404 + StatusReasonNotFound StatusReason = "NotFound" + + // StatusReasonAlreadyExists means the resource you are creating already exists. + // Details (optional): + // "kind" string - the kind attribute of the conflicting resource + // "id" string - the identifier of the conflicting resource + // Status code 409 + StatusReasonAlreadyExists StatusReason = "AlreadyExists" + + // StatusReasonConflict means the requested operation cannot be completed + // due to a conflict in the operation. The client may need to alter the + // request. Each resource may define custom details that indicate the + // nature of the conflict. + // Status code 409 + StatusReasonConflict StatusReason = "Conflict" + + // StatusReasonGone means the item is no longer available at the server and no + // forwarding address is known. + // Status code 410 + StatusReasonGone StatusReason = "Gone" + + // StatusReasonInvalid means the requested create or update operation cannot be + // completed due to invalid data provided as part of the request. The client may + // need to alter the request. When set, the client may use the StatusDetails + // message field as a summary of the issues encountered. + // Details (optional): + // "kind" string - the kind attribute of the invalid resource + // "id" string - the identifier of the invalid resource + // "causes" - one or more StatusCause entries indicating the data in the + // provided resource that was invalid. The code, message, and + // field attributes will be set. + // Status code 422 + StatusReasonInvalid StatusReason = "Invalid" + + // StatusReasonServerTimeout means the server can be reached and understood the request, + // but cannot complete the action in a reasonable time. The client should retry the request. + // This is may be due to temporary server load or a transient communication issue with + // another server. Status code 500 is used because the HTTP spec provides no suitable + // server-requested client retry and the 5xx class represents actionable errors. + // Details (optional): + // "kind" string - the kind attribute of the resource being acted on. + // "id" string - the operation that is being attempted. + // "retryAfterSeconds" int32 - the number of seconds before the operation should be retried + // Status code 500 + StatusReasonServerTimeout StatusReason = "ServerTimeout" + + // StatusReasonTimeout means that the request could not be completed within the given time. + // Clients can get this response only when they specified a timeout param in the request, + // or if the server cannot complete the operation within a reasonable amount of time. + // The request might succeed with an increased value of timeout param. The client *should* + // wait at least the number of seconds specified by the retryAfterSeconds field. + // Details (optional): + // "retryAfterSeconds" int32 - the number of seconds before the operation should be retried + // Status code 504 + StatusReasonTimeout StatusReason = "Timeout" + + // StatusReasonTooManyRequests means the server experienced too many requests within a + // given window and that the client must wait to perform the action again. A client may + // always retry the request that led to this error, although the client should wait at least + // the number of seconds specified by the retryAfterSeconds field. + // Details (optional): + // "retryAfterSeconds" int32 - the number of seconds before the operation should be retried + // Status code 429 + StatusReasonTooManyRequests StatusReason = "TooManyRequests" + + // StatusReasonBadRequest means that the request itself was invalid, because the request + // doesn't make any sense, for example deleting a read-only object. This is different than + // StatusReasonInvalid above which indicates that the API call could possibly succeed, but the + // data was invalid. API calls that return BadRequest can never succeed. + // Status code 400 + StatusReasonBadRequest StatusReason = "BadRequest" + + // StatusReasonMethodNotAllowed means that the action the client attempted to perform on the + // resource was not supported by the code - for instance, attempting to delete a resource that + // can only be created. API calls that return MethodNotAllowed can never succeed. + // Status code 405 + StatusReasonMethodNotAllowed StatusReason = "MethodNotAllowed" + + // StatusReasonNotAcceptable means that the accept types indicated by the client were not acceptable + // to the server - for instance, attempting to receive protobuf for a resource that supports only json and yaml. + // API calls that return NotAcceptable can never succeed. + // Status code 406 + StatusReasonNotAcceptable StatusReason = "NotAcceptable" + + // StatusReasonRequestEntityTooLarge means that the request entity is too large. + // Status code 413 + StatusReasonRequestEntityTooLarge StatusReason = "RequestEntityTooLarge" + + // StatusReasonUnsupportedMediaType means that the content type sent by the client is not acceptable + // to the server - for instance, attempting to send protobuf for a resource that supports only json and yaml. + // API calls that return UnsupportedMediaType can never succeed. + // Status code 415 + StatusReasonUnsupportedMediaType StatusReason = "UnsupportedMediaType" + + // StatusReasonInternalError indicates that an internal error occurred, it is unexpected + // and the outcome of the call is unknown. + // Details (optional): + // "causes" - The original error + // Status code 500 + StatusReasonInternalError StatusReason = "InternalError" + + // StatusReasonExpired indicates that the request is invalid because the content you are requesting + // has expired and is no longer available. It is typically associated with watches that can't be + // serviced. + // Status code 410 (gone) + StatusReasonExpired StatusReason = "Expired" + + // StatusReasonServiceUnavailable means that the request itself was valid, + // but the requested service is unavailable at this time. + // Retrying the request after some time might succeed. + // Status code 503 + StatusReasonServiceUnavailable StatusReason = "ServiceUnavailable" +) + +// StatusCause provides more information about an api.Status failure, including +// cases when multiple errors are encountered. +type StatusCause struct { + // A machine-readable description of the cause of the error. If this value is + // empty there is no information available. + // +optional + Type CauseType `json:"reason,omitempty" protobuf:"bytes,1,opt,name=reason,casttype=CauseType"` + // A human-readable description of the cause of the error. This field may be + // presented as-is to a reader. + // +optional + Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"` + // The field of the resource that has caused this error, as named by its JSON + // serialization. May include dot and postfix notation for nested attributes. + // Arrays are zero-indexed. Fields may appear more than once in an array of + // causes due to fields having multiple errors. + // Optional. + // + // Examples: + // "name" - the field "name" on the current resource + // "items[0].name" - the field "name" on the first array entry in "items" + // +optional + Field string `json:"field,omitempty" protobuf:"bytes,3,opt,name=field"` +} + +// CauseType is a machine readable value providing more detail about what +// occurred in a status response. An operation may have multiple causes for a +// status (whether Failure or Success). +type CauseType string + +const ( + // CauseTypeFieldValueNotFound is used to report failure to find a requested value + // (e.g. looking up an ID). + CauseTypeFieldValueNotFound CauseType = "FieldValueNotFound" + // CauseTypeFieldValueRequired is used to report required values that are not + // provided (e.g. empty strings, null values, or empty arrays). + CauseTypeFieldValueRequired CauseType = "FieldValueRequired" + // CauseTypeFieldValueDuplicate is used to report collisions of values that must be + // unique (e.g. unique IDs). + CauseTypeFieldValueDuplicate CauseType = "FieldValueDuplicate" + // CauseTypeFieldValueInvalid is used to report malformed values (e.g. failed regex + // match). + CauseTypeFieldValueInvalid CauseType = "FieldValueInvalid" + // CauseTypeFieldValueNotSupported is used to report valid (as per formatting rules) + // values that can not be handled (e.g. an enumerated string). + CauseTypeFieldValueNotSupported CauseType = "FieldValueNotSupported" + // CauseTypeUnexpectedServerResponse is used to report when the server responded to the client + // without the expected return type. The presence of this cause indicates the error may be + // due to an intervening proxy or the server software malfunctioning. + CauseTypeUnexpectedServerResponse CauseType = "UnexpectedServerResponse" + // FieldManagerConflict is used to report when another client claims to manage this field, + // It should only be returned for a request using server-side apply. + CauseTypeFieldManagerConflict CauseType = "FieldManagerConflict" + // CauseTypeResourceVersionTooLarge is used to report that the requested resource version + // is newer than the data observed by the API server, so the request cannot be served. + CauseTypeResourceVersionTooLarge CauseType = "ResourceVersionTooLarge" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// List holds a list of objects, which may not be known by the server. +type List struct { + TypeMeta `json:",inline"` + // Standard list metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + // +optional + ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // List of objects + Items []runtime.RawExtension `json:"items" protobuf:"bytes,2,rep,name=items"` +} + +// APIVersions lists the versions that are available, to allow clients to +// discover the API at /api, which is the root path of the legacy v1 API. +// +// +protobuf.options.(gogoproto.goproto_stringer)=false +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type APIVersions struct { + TypeMeta `json:",inline"` + // versions are the api versions that are available. + Versions []string `json:"versions" protobuf:"bytes,1,rep,name=versions"` + // a map of client CIDR to server address that is serving this group. + // This is to help clients reach servers in the most network-efficient way possible. + // Clients can use the appropriate server address as per the CIDR that they match. + // In case of multiple matches, clients should use the longest matching CIDR. + // The server returns only those CIDRs that it thinks that the client can match. + // For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. + // Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP. + ServerAddressByClientCIDRs []ServerAddressByClientCIDR `json:"serverAddressByClientCIDRs" protobuf:"bytes,2,rep,name=serverAddressByClientCIDRs"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// APIGroupList is a list of APIGroup, to allow clients to discover the API at +// /apis. +type APIGroupList struct { + TypeMeta `json:",inline"` + // groups is a list of APIGroup. + Groups []APIGroup `json:"groups" protobuf:"bytes,1,rep,name=groups"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// APIGroup contains the name, the supported versions, and the preferred version +// of a group. +type APIGroup struct { + TypeMeta `json:",inline"` + // name is the name of the group. + Name string `json:"name" protobuf:"bytes,1,opt,name=name"` + // versions are the versions supported in this group. + Versions []GroupVersionForDiscovery `json:"versions" protobuf:"bytes,2,rep,name=versions"` + // preferredVersion is the version preferred by the API server, which + // probably is the storage version. + // +optional + PreferredVersion GroupVersionForDiscovery `json:"preferredVersion,omitempty" protobuf:"bytes,3,opt,name=preferredVersion"` + // a map of client CIDR to server address that is serving this group. + // This is to help clients reach servers in the most network-efficient way possible. + // Clients can use the appropriate server address as per the CIDR that they match. + // In case of multiple matches, clients should use the longest matching CIDR. + // The server returns only those CIDRs that it thinks that the client can match. + // For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. + // Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP. + // +optional + ServerAddressByClientCIDRs []ServerAddressByClientCIDR `json:"serverAddressByClientCIDRs,omitempty" protobuf:"bytes,4,rep,name=serverAddressByClientCIDRs"` +} + +// ServerAddressByClientCIDR helps the client to determine the server address that they should use, depending on the clientCIDR that they match. +type ServerAddressByClientCIDR struct { + // The CIDR with which clients can match their IP to figure out the server address that they should use. + ClientCIDR string `json:"clientCIDR" protobuf:"bytes,1,opt,name=clientCIDR"` + // Address of this server, suitable for a client that matches the above CIDR. + // This can be a hostname, hostname:port, IP or IP:port. + ServerAddress string `json:"serverAddress" protobuf:"bytes,2,opt,name=serverAddress"` +} + +// GroupVersion contains the "group/version" and "version" string of a version. +// It is made a struct to keep extensibility. +type GroupVersionForDiscovery struct { + // groupVersion specifies the API group and version in the form "group/version" + GroupVersion string `json:"groupVersion" protobuf:"bytes,1,opt,name=groupVersion"` + // version specifies the version in the form of "version". This is to save + // the clients the trouble of splitting the GroupVersion. + Version string `json:"version" protobuf:"bytes,2,opt,name=version"` +} + +// APIResource specifies the name of a resource and whether it is namespaced. +type APIResource struct { + // name is the plural name of the resource. + Name string `json:"name" protobuf:"bytes,1,opt,name=name"` + // singularName is the singular name of the resource. This allows clients to handle plural and singular opaquely. + // The singularName is more correct for reporting status on a single item and both singular and plural are allowed + // from the kubectl CLI interface. + SingularName string `json:"singularName" protobuf:"bytes,6,opt,name=singularName"` + // namespaced indicates if a resource is namespaced or not. + Namespaced bool `json:"namespaced" protobuf:"varint,2,opt,name=namespaced"` + // group is the preferred group of the resource. Empty implies the group of the containing resource list. + // For subresources, this may have a different value, for example: Scale". + Group string `json:"group,omitempty" protobuf:"bytes,8,opt,name=group"` + // version is the preferred version of the resource. Empty implies the version of the containing resource list + // For subresources, this may have a different value, for example: v1 (while inside a v1beta1 version of the core resource's group)". + Version string `json:"version,omitempty" protobuf:"bytes,9,opt,name=version"` + // kind is the kind for the resource (e.g. 'Foo' is the kind for a resource 'foo') + Kind string `json:"kind" protobuf:"bytes,3,opt,name=kind"` + // verbs is a list of supported kube verbs (this includes get, list, watch, create, + // update, patch, delete, deletecollection, and proxy) + Verbs Verbs `json:"verbs" protobuf:"bytes,4,opt,name=verbs"` + // shortNames is a list of suggested short names of the resource. + ShortNames []string `json:"shortNames,omitempty" protobuf:"bytes,5,rep,name=shortNames"` + // categories is a list of the grouped resources this resource belongs to (e.g. 'all') + Categories []string `json:"categories,omitempty" protobuf:"bytes,7,rep,name=categories"` + // The hash value of the storage version, the version this resource is + // converted to when written to the data store. Value must be treated + // as opaque by clients. Only equality comparison on the value is valid. + // This is an alpha feature and may change or be removed in the future. + // The field is populated by the apiserver only if the + // StorageVersionHash feature gate is enabled. + // This field will remain optional even if it graduates. + // +optional + StorageVersionHash string `json:"storageVersionHash,omitempty" protobuf:"bytes,10,opt,name=storageVersionHash"` +} + +// Verbs masks the value so protobuf can generate +// +// +protobuf.nullable=true +// +protobuf.options.(gogoproto.goproto_stringer)=false +type Verbs []string + +func (vs Verbs) String() string { + return fmt.Sprintf("%v", []string(vs)) +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// APIResourceList is a list of APIResource, it is used to expose the name of the +// resources supported in a specific group and version, and if the resource +// is namespaced. +type APIResourceList struct { + TypeMeta `json:",inline"` + // groupVersion is the group and version this APIResourceList is for. + GroupVersion string `json:"groupVersion" protobuf:"bytes,1,opt,name=groupVersion"` + // resources contains the name of the resources and if they are namespaced. + APIResources []APIResource `json:"resources" protobuf:"bytes,2,rep,name=resources"` +} + +// RootPaths lists the paths available at root. +// For example: "/healthz", "/apis". +type RootPaths struct { + // paths are the paths available at root. + Paths []string `json:"paths" protobuf:"bytes,1,rep,name=paths"` +} + +// TODO: remove me when watch is refactored +func LabelSelectorQueryParam(version string) string { + return "labelSelector" +} + +// TODO: remove me when watch is refactored +func FieldSelectorQueryParam(version string) string { + return "fieldSelector" +} + +// String returns available api versions as a human-friendly version string. +func (apiVersions APIVersions) String() string { + return strings.Join(apiVersions.Versions, ",") +} + +func (apiVersions APIVersions) GoString() string { + return apiVersions.String() +} + +// Patch is provided to give a concrete name and type to the Kubernetes PATCH request body. +type Patch struct{} + +// Note: +// There are two different styles of label selectors used in versioned types: +// an older style which is represented as just a string in versioned types, and a +// newer style that is structured. LabelSelector is an internal representation for the +// latter style. + +// A label selector is a label query over a set of resources. The result of matchLabels and +// matchExpressions are ANDed. An empty label selector matches all objects. A null +// label selector matches no objects. +// +structType=atomic +type LabelSelector struct { + // matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + // map is equivalent to an element of matchExpressions, whose key field is "key", the + // operator is "In", and the values array contains only "value". The requirements are ANDed. + // +optional + MatchLabels map[string]string `json:"matchLabels,omitempty" protobuf:"bytes,1,rep,name=matchLabels"` + // matchExpressions is a list of label selector requirements. The requirements are ANDed. + // +optional + MatchExpressions []LabelSelectorRequirement `json:"matchExpressions,omitempty" protobuf:"bytes,2,rep,name=matchExpressions"` +} + +// A label selector requirement is a selector that contains values, a key, and an operator that +// relates the key and values. +type LabelSelectorRequirement struct { + // key is the label key that the selector applies to. + // +patchMergeKey=key + // +patchStrategy=merge + Key string `json:"key" patchStrategy:"merge" patchMergeKey:"key" protobuf:"bytes,1,opt,name=key"` + // operator represents a key's relationship to a set of values. + // Valid operators are In, NotIn, Exists and DoesNotExist. + Operator LabelSelectorOperator `json:"operator" protobuf:"bytes,2,opt,name=operator,casttype=LabelSelectorOperator"` + // values is an array of string values. If the operator is In or NotIn, + // the values array must be non-empty. If the operator is Exists or DoesNotExist, + // the values array must be empty. This array is replaced during a strategic + // merge patch. + // +optional + Values []string `json:"values,omitempty" protobuf:"bytes,3,rep,name=values"` +} + +// A label selector operator is the set of operators that can be used in a selector requirement. +type LabelSelectorOperator string + +const ( + LabelSelectorOpIn LabelSelectorOperator = "In" + LabelSelectorOpNotIn LabelSelectorOperator = "NotIn" + LabelSelectorOpExists LabelSelectorOperator = "Exists" + LabelSelectorOpDoesNotExist LabelSelectorOperator = "DoesNotExist" +) + +// ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource +// that the fieldset applies to. +type ManagedFieldsEntry struct { + // Manager is an identifier of the workflow managing these fields. + Manager string `json:"manager,omitempty" protobuf:"bytes,1,opt,name=manager"` + // Operation is the type of operation which lead to this ManagedFieldsEntry being created. + // The only valid values for this field are 'Apply' and 'Update'. + Operation ManagedFieldsOperationType `json:"operation,omitempty" protobuf:"bytes,2,opt,name=operation,casttype=ManagedFieldsOperationType"` + // APIVersion defines the version of this resource that this field set + // applies to. The format is "group/version" just like the top-level + // APIVersion field. It is necessary to track the version of a field + // set because it cannot be automatically converted. + APIVersion string `json:"apiVersion,omitempty" protobuf:"bytes,3,opt,name=apiVersion"` + // Time is timestamp of when these fields were set. It should always be empty if Operation is 'Apply' + // +optional + Time *Time `json:"time,omitempty" protobuf:"bytes,4,opt,name=time"` + + // Fields is tombstoned to show why 5 is a reserved protobuf tag. + //Fields *Fields `json:"fields,omitempty" protobuf:"bytes,5,opt,name=fields,casttype=Fields"` + + // FieldsType is the discriminator for the different fields format and version. + // There is currently only one possible value: "FieldsV1" + FieldsType string `json:"fieldsType,omitempty" protobuf:"bytes,6,opt,name=fieldsType"` + // FieldsV1 holds the first JSON version format as described in the "FieldsV1" type. + // +optional + FieldsV1 *FieldsV1 `json:"fieldsV1,omitempty" protobuf:"bytes,7,opt,name=fieldsV1"` +} + +// ManagedFieldsOperationType is the type of operation which lead to a ManagedFieldsEntry being created. +type ManagedFieldsOperationType string + +const ( + ManagedFieldsOperationApply ManagedFieldsOperationType = "Apply" + ManagedFieldsOperationUpdate ManagedFieldsOperationType = "Update" +) + +// FieldsV1 stores a set of fields in a data structure like a Trie, in JSON format. +// +// Each key is either a '.' representing the field itself, and will always map to an empty set, +// or a string representing a sub-field or item. The string will follow one of these four formats: +// 'f:', where is the name of a field in a struct, or key in a map +// 'v:', where is the exact json formatted value of a list item +// 'i:', where is position of a item in a list +// 'k:', where is a map of a list item's key fields to their unique values +// If a key maps to an empty Fields value, the field that key represents is part of the set. +// +// The exact format is defined in sigs.k8s.io/structured-merge-diff +// +protobuf.options.(gogoproto.goproto_stringer)=false +type FieldsV1 struct { + // Raw is the underlying serialization of this object. + Raw []byte `json:"-" protobuf:"bytes,1,opt,name=Raw"` +} + +func (f FieldsV1) String() string { + return string(f.Raw) +} + +// TODO: Table does not generate to protobuf because of the interface{} - fix protobuf +// generation to support a meta type that can accept any valid JSON. This can be introduced +// in a v1 because clients a) receive an error if they try to access proto today, and b) +// once introduced they would be able to gracefully switch over to using it. + +// Table is a tabular representation of a set of API resources. The server transforms the +// object into a set of preferred columns for quickly reviewing the objects. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +protobuf=false +type Table struct { + TypeMeta `json:",inline"` + // Standard list metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + // +optional + ListMeta `json:"metadata,omitempty"` + + // columnDefinitions describes each column in the returned items array. The number of cells per row + // will always match the number of column definitions. + ColumnDefinitions []TableColumnDefinition `json:"columnDefinitions"` + // rows is the list of items in the table. + Rows []TableRow `json:"rows"` +} + +// TableColumnDefinition contains information about a column returned in the Table. +// +protobuf=false +type TableColumnDefinition struct { + // name is a human readable name for the column. + Name string `json:"name"` + // type is an OpenAPI type definition for this column, such as number, integer, string, or + // array. + // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more. + Type string `json:"type"` + // format is an optional OpenAPI type modifier for this column. A format modifies the type and + // imposes additional rules, like date or time formatting for a string. The 'name' format is applied + // to the primary identifier column which has type 'string' to assist in clients identifying column + // is the resource name. + // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more. + Format string `json:"format"` + // description is a human readable description of this column. + Description string `json:"description"` + // priority is an integer defining the relative importance of this column compared to others. Lower + // numbers are considered higher priority. Columns that may be omitted in limited space scenarios + // should be given a higher priority. + Priority int32 `json:"priority"` +} + +// TableRow is an individual row in a table. +// +protobuf=false +type TableRow struct { + // cells will be as wide as the column definitions array and may contain strings, numbers (float64 or + // int64), booleans, simple maps, lists, or null. See the type field of the column definition for a + // more detailed description. + Cells []interface{} `json:"cells"` + // conditions describe additional status of a row that are relevant for a human user. These conditions + // apply to the row, not to the object, and will be specific to table output. The only defined + // condition type is 'Completed', for a row that indicates a resource that has run to completion and + // can be given less visual priority. + // +optional + Conditions []TableRowCondition `json:"conditions,omitempty"` + // This field contains the requested additional information about each object based on the includeObject + // policy when requesting the Table. If "None", this field is empty, if "Object" this will be the + // default serialization of the object for the current API version, and if "Metadata" (the default) will + // contain the object metadata. Check the returned kind and apiVersion of the object before parsing. + // The media type of the object will always match the enclosing list - if this as a JSON table, these + // will be JSON encoded objects. + // +optional + Object runtime.RawExtension `json:"object,omitempty"` +} + +// TableRowCondition allows a row to be marked with additional information. +// +protobuf=false +type TableRowCondition struct { + // Type of row condition. The only defined value is 'Completed' indicating that the + // object this row represents has reached a completed state and may be given less visual + // priority than other rows. Clients are not required to honor any conditions but should + // be consistent where possible about handling the conditions. + Type RowConditionType `json:"type"` + // Status of the condition, one of True, False, Unknown. + Status ConditionStatus `json:"status"` + // (brief) machine readable reason for the condition's last transition. + // +optional + Reason string `json:"reason,omitempty"` + // Human readable message indicating details about last transition. + // +optional + Message string `json:"message,omitempty"` +} + +type RowConditionType string + +// These are valid conditions of a row. This list is not exhaustive and new conditions may be +// included by other resources. +const ( + // RowCompleted means the underlying resource has reached completion and may be given less + // visual priority than other resources. + RowCompleted RowConditionType = "Completed" +) + +type ConditionStatus string + +// These are valid condition statuses. "ConditionTrue" means a resource is in the condition. +// "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes +// can't decide if a resource is in the condition or not. In the future, we could add other +// intermediate conditions, e.g. ConditionDegraded. +const ( + ConditionTrue ConditionStatus = "True" + ConditionFalse ConditionStatus = "False" + ConditionUnknown ConditionStatus = "Unknown" +) + +// IncludeObjectPolicy controls which portion of the object is returned with a Table. +type IncludeObjectPolicy string + +const ( + // IncludeNone returns no object. + IncludeNone IncludeObjectPolicy = "None" + // IncludeMetadata serializes the object containing only its metadata field. + IncludeMetadata IncludeObjectPolicy = "Metadata" + // IncludeObject contains the full object. + IncludeObject IncludeObjectPolicy = "Object" +) + +// TableOptions are used when a Table is requested by the caller. +// +k8s:conversion-gen:explicit-from=net/url.Values +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type TableOptions struct { + TypeMeta `json:",inline"` + + // NoHeaders is only exposed for internal callers. It is not included in our OpenAPI definitions + // and may be removed as a field in a future release. + NoHeaders bool `json:"-"` + + // includeObject decides whether to include each object along with its columnar information. + // Specifying "None" will return no object, specifying "Object" will return the full object contents, and + // specifying "Metadata" (the default) will return the object's metadata in the PartialObjectMetadata kind + // in version v1beta1 of the meta.k8s.io API group. + IncludeObject IncludeObjectPolicy `json:"includeObject,omitempty" protobuf:"bytes,1,opt,name=includeObject,casttype=IncludeObjectPolicy"` +} + +// PartialObjectMetadata is a generic representation of any object with ObjectMeta. It allows clients +// to get access to a particular ObjectMeta schema without knowing the details of the version. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type PartialObjectMetadata struct { + TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` +} + +// PartialObjectMetadataList contains a list of objects containing only their metadata +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type PartialObjectMetadataList struct { + TypeMeta `json:",inline"` + // Standard list metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + // +optional + ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // items contains each of the included items. + Items []PartialObjectMetadata `json:"items" protobuf:"bytes,2,rep,name=items"` +} + +// Condition contains details for one aspect of the current state of this API Resource. +// --- +// This struct is intended for direct use as an array at the field path .status.conditions. For example, +// type FooStatus struct{ +// // Represents the observations of a foo's current state. +// // Known .status.conditions.type are: "Available", "Progressing", and "Degraded" +// // +patchMergeKey=type +// // +patchStrategy=merge +// // +listType=map +// // +listMapKey=type +// Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` +// +// // other fields +// } +type Condition struct { + // type of condition in CamelCase or in foo.example.com/CamelCase. + // --- + // Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be + // useful (see .node.status.conditions), the ability to deconflict is important. + // The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$` + // +kubebuilder:validation:MaxLength=316 + Type string `json:"type" protobuf:"bytes,1,opt,name=type"` + // status of the condition, one of True, False, Unknown. + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:Enum=True;False;Unknown + Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status"` + // observedGeneration represents the .metadata.generation that the condition was set based upon. + // For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + // with respect to the current state of the instance. + // +optional + // +kubebuilder:validation:Minimum=0 + ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"` + // lastTransitionTime is the last time the condition transitioned from one status to another. + // This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:Type=string + // +kubebuilder:validation:Format=date-time + LastTransitionTime Time `json:"lastTransitionTime" protobuf:"bytes,4,opt,name=lastTransitionTime"` + // reason contains a programmatic identifier indicating the reason for the condition's last transition. + // Producers of specific condition types may define expected values and meanings for this field, + // and whether the values are considered a guaranteed API. + // The value should be a CamelCase string. + // This field may not be empty. + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MaxLength=1024 + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:Pattern=`^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$` + Reason string `json:"reason" protobuf:"bytes,5,opt,name=reason"` + // message is a human readable message indicating details about the transition. + // This may be an empty string. + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MaxLength=32768 + Message string `json:"message" protobuf:"bytes,6,opt,name=message"` +} diff --git a/adaptor/pod/server/kubernetes/client-go/kubernetes/clientset.go b/adaptor/pod/server/kubernetes/client-go/kubernetes/clientset.go index 29aa19f4..790dc861 100644 --- a/adaptor/pod/server/kubernetes/client-go/kubernetes/clientset.go +++ b/adaptor/pod/server/kubernetes/client-go/kubernetes/clientset.go @@ -21,7 +21,7 @@ package kubernetes import ( "fmt" - corev1 "gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/client-go/kubernetes/typed/core/v1" + corev1 "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/client-go/kubernetes/typed/core/v1" discovery "k8s.io/client-go/discovery" admissionregistrationv1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1" admissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" diff --git a/adaptor/pod/server/kubernetes/client-go/kubernetes/typed/core/v1/pod.go b/adaptor/pod/server/kubernetes/client-go/kubernetes/typed/core/v1/pod.go index a52f7320..ebcdf585 100644 --- a/adaptor/pod/server/kubernetes/client-go/kubernetes/typed/core/v1/pod.go +++ b/adaptor/pod/server/kubernetes/client-go/kubernetes/typed/core/v1/pod.go @@ -1,21 +1,21 @@ package v1 import ( + "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "context" json "encoding/json" "errors" "flag" "fmt" "github.com/golang/glog" - "gitlink.org.cn/JCCE/PCM/adaptor/pod/server" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "strconv" "time" - v1 "gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/core/v1" + v1 "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/core/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" corev1 "k8s.io/client-go/applyconfigurations/core/v1" @@ -37,7 +37,7 @@ type PodInterface interface { Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.Pod, error) - List(ctx context.Context, opts metav1.ListOptions) (*v1.PodList, error) + List(ctx context.Context, pod *v1.Pod, opts metav1.ListOptions) (*v1.PodList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Pod, err error) Apply(ctx context.Context, pod *corev1.PodApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Pod, err error) @@ -76,19 +76,54 @@ func (c *pods) Get(ctx context.Context, name string, options metav1.GetOptions) } // List takes label and field selectors, and returns the list of Pods that match those selectors. -func (c *pods) List(ctx context.Context, opts metav1.ListOptions) (result *v1.PodList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second +func (c *pods) List(ctx context.Context, pod *v1.Pod, opts metav1.ListOptions) (result *v1.PodList, err error) { + + providerId := pod.Spec.ProviderId + regionId := pod.Spec.RegionId + accountName := pod.Spec.AccountName + provider := pbtenant.CloudProvider(providerId) + + requestPCM := &pbpod.ListPodReq{ + RequestSource: "huawei", + Provider: provider, + Namespace: "pcm", + } + + resp, err := server.ListPod(nil, requestPCM) + //trans PCM response pod set to Ali ContainerGroup set + var pods = make([]v1.Pod, len(resp.Pods)) + for k := range resp.Pods { + podId := resp.Pods[k].PodId + containerName := resp.Pods[k].ContainerName + containerImage := resp.Pods[k].ContainerImage + podName := resp.Pods[k].PodName + container := v1.Container{ + Name: containerName, + Image: containerImage, + } + var containers []v1.Container + containers = append(containers, container) + + podSpec := v1.PodSpec{ + ProviderId: providerId, + RegionId: regionId, + AccountName: accountName, + Containers: containers, + } + pod := v1.Pod{ + TypeMeta: metav1.TypeMeta{APIVersion: "core/V1", Kind: "Pod"}, + ObjectMeta: metav1.ObjectMeta{Name: podName, Namespace: "pcm", UID: types.UID(podId)}, + Spec: podSpec, + Status: v1.PodStatus{}, + } + pods[k] = pod + } + + result = &v1.PodList{ + TypeMeta: metav1.TypeMeta{}, + ListMeta: metav1.ListMeta{}, + Items: pods, } - result = &v1.PodList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("pods"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) return } @@ -234,14 +269,122 @@ func (c *pods) Create(ctx context.Context, pod *v1.Pod, opts metav1.CreateOption // Update takes the representation of a pod and updates it. Returns the server's representation of the pod, and an error, if there is any. func (c *pods) Update(ctx context.Context, pod *v1.Pod, opts metav1.UpdateOptions) (result *v1.Pod, err error) { result = &v1.Pod{} - err = c.client.Put(). - Namespace(c.ns). - Resource("pods"). - Name(pod.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(pod). - Do(ctx). - Into(result) + + provider := pbtenant.CloudProvider(pod.Spec.ProviderId) + var configFile string + flag.StringVar(&configFile, "confHuawei", "configs/config.yaml", "config.yaml") + flag.Parse() + defer glog.Flush() + + if err := tenanter.LoadCloudConfigsFromFile(configFile); err != nil { + if !errors.Is(err, tenanter.ErrLoadTenanterFileEmpty) { + glog.Fatalf("tenanter.LoadCloudConfigsFromFile error %+v", err) + } + glog.Warningf("tenanter.LoadCloudConfigsFromFile empty file path %s", configFile) + } + + glog.Infof("load tenant from file finished") + tenanters, err := tenanter.GetTenanters(provider) + var regionId int32 + var cpuPod string + var memoryPod string + + //华为(K8S)与其他厂商的CPU单位和格式有区别 + switch pod.Spec.ProviderId { + case 0: + regionId, _ = tenanter.GetAliRegionId(pod.Spec.RegionId) + cpuPod = strconv.FormatInt(pod.Spec.Containers[0].Resources.Limits.Cpu().MilliValue()/1000, 10) + memoryPod = strconv.FormatInt(pod.Spec.Containers[0].Resources.Limits.Memory().MilliValue()/1024/1024/1024/1000, 10) + case 1: + regionId, _ = tenanter.GetTencentRegionId(pod.Spec.RegionId) + cpuPod = strconv.FormatInt(pod.Spec.Containers[0].Resources.Limits.Cpu().MilliValue()/1000, 10) + memoryPod = strconv.FormatInt(pod.Spec.Containers[0].Resources.Limits.Memory().MilliValue()/1024/1024/1024/1000, 10) + case 2: + regionId, _ = tenanter.GetHuaweiRegionId(pod.Spec.RegionId) + cpuPod = pod.Spec.Containers[0].Resources.Limits.Cpu().String() + memoryPod = pod.Spec.Containers[0].Resources.Limits.Memory().String() + case 3: + regionId, _ = tenanter.GetK8SRegionId(pod.Spec.RegionId) + cpuPod = strconv.FormatInt(pod.Spec.Containers[0].Resources.Limits.Cpu().MilliValue()/1000, 10) + memoryPod = strconv.FormatInt(pod.Spec.Containers[0].Resources.Limits.Memory().MilliValue()/1024/1024/1024/1000, 10) + } + + requestPCM := &pbpod.UpdatePodReq{ + RequestSource: "huawei", + Provider: provider, + PcmId: string(pod.ObjectMeta.UID), + PodId: string(pod.ObjectMeta.UID), + AccountName: tenanters[0].AccountName(), + PodName: pod.Name, + RegionId: regionId, + ContainerImage: pod.Spec.Containers[0].Image, + ContainerName: pod.Spec.Containers[0].Name, + CpuPod: cpuPod, + MemoryPod: memoryPod, + Namespace: pod.ObjectMeta.Namespace, + } + + server.UpdatePod(nil, requestPCM) + + result = &v1.Pod{ + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{}, + Spec: v1.PodSpec{ + ProviderId: pod.Spec.ProviderId, + RegionId: pod.Spec.RegionId, + AccountName: pod.Spec.AccountName, + Volumes: nil, + InitContainers: nil, + Containers: pod.Spec.Containers, + EphemeralContainers: nil, + RestartPolicy: "", + TerminationGracePeriodSeconds: nil, + ActiveDeadlineSeconds: nil, + DNSPolicy: "", + NodeSelector: nil, + ServiceAccountName: "", + DeprecatedServiceAccount: "", + AutomountServiceAccountToken: nil, + NodeName: "", + HostNetwork: false, + HostPID: false, + HostIPC: false, + ShareProcessNamespace: nil, + SecurityContext: nil, + ImagePullSecrets: nil, + Hostname: "", + Subdomain: "", + Affinity: nil, + SchedulerName: "", + Tolerations: nil, + HostAliases: nil, + PriorityClassName: "", + Priority: nil, + DNSConfig: nil, + ReadinessGates: nil, + RuntimeClassName: nil, + EnableServiceLinks: nil, + PreemptionPolicy: nil, + Overhead: nil, + TopologySpreadConstraints: nil, + SetHostnameAsFQDN: nil, + }, + Status: v1.PodStatus{ + Phase: "", + Conditions: nil, + Message: "", + Reason: "", + NominatedNodeName: "", + HostIP: "", + PodIP: "", + PodIPs: nil, + StartTime: nil, + InitContainerStatuses: nil, + ContainerStatuses: nil, + QOSClass: "", + EphemeralContainerStatuses: nil, + }, + } return } diff --git a/adaptor/pod/server/pod.go b/adaptor/pod/server/pod.go index 603aafe5..93b719ca 100644 --- a/adaptor/pod/server/pod.go +++ b/adaptor/pod/server/pod.go @@ -6,10 +6,10 @@ import ( "fmt" "sync" - "gitlink.org.cn/JCCE/PCM/adaptor/pod/service" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/service" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "github.com/golang/glog" "github.com/pkg/errors" diff --git a/adaptor/pod/service/ali_eci.go b/adaptor/pod/service/ali_eci.go index ae7203ee..0ebfe211 100644 --- a/adaptor/pod/service/ali_eci.go +++ b/adaptor/pod/service/ali_eci.go @@ -9,10 +9,10 @@ import ( "strconv" "sync" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "github.com/pkg/errors" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" ) var aliClientMutex sync.Mutex diff --git a/adaptor/pod/service/huawei_cci.go b/adaptor/pod/service/huawei_cci.go index 32606ecd..b80042a5 100644 --- a/adaptor/pod/service/huawei_cci.go +++ b/adaptor/pod/service/huawei_cci.go @@ -12,16 +12,16 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" corev1 "k8s.io/api/core/v1" huaweicci "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd/api" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" "github.com/pkg/errors" - "gitlink.org.cn/JCCE/PCM/common/tenanter" ) var huaweiClientMutex sync.Mutex diff --git a/adaptor/pod/service/k8s.go b/adaptor/pod/service/k8s.go index 7df581c5..359ac080 100644 --- a/adaptor/pod/service/k8s.go +++ b/adaptor/pod/service/k8s.go @@ -1,13 +1,13 @@ package poder import ( + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "context" "fmt" "github.com/golang/glog" "github.com/pkg/errors" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/adaptor/pod/service/poder.go b/adaptor/pod/service/poder.go index 7e967385..4077f936 100644 --- a/adaptor/pod/service/poder.go +++ b/adaptor/pod/service/poder.go @@ -1,10 +1,10 @@ package poder import ( + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "context" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "github.com/golang/glog" "github.com/pkg/errors" diff --git a/adaptor/pod/service/tencent_eks.go b/adaptor/pod/service/tencent_eks.go index dc74f52a..b18d5de2 100644 --- a/adaptor/pod/service/tencent_eks.go +++ b/adaptor/pod/service/tencent_eks.go @@ -7,14 +7,14 @@ import ( "github.com/golang/glog" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" "github.com/pkg/errors" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" tencenteks "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" ) var tencentClientMutex sync.Mutex diff --git a/adaptor/vm/server/ecs/list.go b/adaptor/vm/server/ecs/list.go index b85eda37..214afa44 100644 --- a/adaptor/vm/server/ecs/list.go +++ b/adaptor/vm/server/ecs/list.go @@ -4,12 +4,12 @@ import ( "context" "sync" + "code.gitlink.org.cn/JCCE/PCM/adaptor/vm/service/ecser" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "github.com/golang/glog" "github.com/pkg/errors" - "gitlink.org.cn/JCCE/PCM/adaptor/vm/service/ecser" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" ) //CreateMultipleEcs 创建多云ECS diff --git a/adaptor/vm/server/ecs/list_test.go b/adaptor/vm/server/ecs/list_test.go index f7751056..15cda328 100644 --- a/adaptor/vm/server/ecs/list_test.go +++ b/adaptor/vm/server/ecs/list_test.go @@ -1,9 +1,9 @@ package ecs import ( + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "context" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "testing" ) diff --git a/adaptor/vm/server/ecs/main_test.go b/adaptor/vm/server/ecs/main_test.go index 99c514e2..bf941c56 100644 --- a/adaptor/vm/server/ecs/main_test.go +++ b/adaptor/vm/server/ecs/main_test.go @@ -1,8 +1,8 @@ package ecs import ( - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "os" "testing" ) diff --git a/adaptor/vm/service/ecser/ali.go b/adaptor/vm/service/ecser/ali.go index caef2e76..d2bcc5ec 100644 --- a/adaptor/vm/service/ecser/ali.go +++ b/adaptor/vm/service/ecser/ali.go @@ -4,6 +4,9 @@ import ( "context" "sync" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" openapi "github.com/alibabacloud-go/darabonba-openapi/client" string_ "github.com/alibabacloud-go/darabonba-string/client" aliecs "github.com/alibabacloud-go/ecs-20140526/v2/client" @@ -11,9 +14,6 @@ import ( "github.com/alibabacloud-go/tea/tea" "github.com/golang/glog" "github.com/pkg/errors" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" ) var aliClientMutex sync.Mutex diff --git a/adaptor/vm/service/ecser/aws.go b/adaptor/vm/service/ecser/aws.go index bfca04e8..bcec301a 100644 --- a/adaptor/vm/service/ecser/aws.go +++ b/adaptor/vm/service/ecser/aws.go @@ -10,10 +10,10 @@ package ecser // awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2" // "github.com/pkg/errors" // -// "gitlink.org.cn/JCCE/PCM/common/tenanter" +// "code.gitlink.org.cn/JCCE/PCM/common/tenanter" // -// "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" -// "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" +// "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" +// "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" //) // //type AwsEcs struct { diff --git a/adaptor/vm/service/ecser/ecser.go b/adaptor/vm/service/ecser/ecser.go index b1f2a27d..6872c99c 100644 --- a/adaptor/vm/service/ecser/ecser.go +++ b/adaptor/vm/service/ecser/ecser.go @@ -3,9 +3,9 @@ package ecser import ( "context" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "github.com/golang/glog" "github.com/pkg/errors" diff --git a/adaptor/vm/service/ecser/ecser_test.go b/adaptor/vm/service/ecser/ecser_test.go index fa514348..1b479a2f 100644 --- a/adaptor/vm/service/ecser/ecser_test.go +++ b/adaptor/vm/service/ecser/ecser_test.go @@ -1,10 +1,10 @@ package ecser import ( + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "context" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "testing" ) diff --git a/adaptor/vm/service/ecser/harvester.go b/adaptor/vm/service/ecser/harvester.go index b415c201..7cef64b1 100644 --- a/adaptor/vm/service/ecser/harvester.go +++ b/adaptor/vm/service/ecser/harvester.go @@ -1,6 +1,9 @@ package ecser import ( + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "context" "fmt" "github.com/harvester/harvester/pkg/apis/harvesterhci.io/v1beta1" @@ -8,9 +11,6 @@ import ( "github.com/longhorn/longhorn-manager/util" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" k8smetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/adaptor/vm/service/ecser/huawei.go b/adaptor/vm/service/ecser/huawei.go index cec42fa1..8a01e1bf 100644 --- a/adaptor/vm/service/ecser/huawei.go +++ b/adaptor/vm/service/ecser/huawei.go @@ -4,6 +4,9 @@ import ( "context" "strconv" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" string_ "github.com/alibabacloud-go/darabonba-string/client" util "github.com/alibabacloud-go/tea-utils/service" "github.com/alibabacloud-go/tea/tea" @@ -16,9 +19,6 @@ import ( iammodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model" iamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region" "github.com/pkg/errors" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" ) type HuaweiEcs struct { diff --git a/adaptor/vm/service/ecser/main_test.go b/adaptor/vm/service/ecser/main_test.go index 21eb0e8a..dba1136f 100644 --- a/adaptor/vm/service/ecser/main_test.go +++ b/adaptor/vm/service/ecser/main_test.go @@ -1,8 +1,8 @@ package ecser import ( - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "os" "testing" ) diff --git a/adaptor/vm/service/ecser/tencent.go b/adaptor/vm/service/ecser/tencent.go index 8de62850..d0ac25a0 100644 --- a/adaptor/vm/service/ecser/tencent.go +++ b/adaptor/vm/service/ecser/tencent.go @@ -4,6 +4,9 @@ import ( "context" "strconv" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" string_ "github.com/alibabacloud-go/darabonba-string/client" util "github.com/alibabacloud-go/tea-utils/service" "github.com/alibabacloud-go/tea/tea" @@ -12,9 +15,6 @@ import ( "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" ) type TencentCvm struct { diff --git a/common/server/server.go b/common/server/server.go index 68d52bb9..c2065787 100644 --- a/common/server/server.go +++ b/common/server/server.go @@ -1,10 +1,10 @@ package server import ( + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/demo" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" "context" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/demo" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" ) type Server struct { diff --git a/common/server/server_ecs.go b/common/server/server_ecs.go index d89e7eb1..7b46c678 100644 --- a/common/server/server_ecs.go +++ b/common/server/server_ecs.go @@ -3,8 +3,8 @@ package server import ( "context" - "gitlink.org.cn/JCCE/PCM/adaptor/vm/server/ecs" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "code.gitlink.org.cn/JCCE/PCM/adaptor/vm/server/ecs" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" "github.com/golang/glog" "google.golang.org/grpc/codes" diff --git a/common/server/server_pod.go b/common/server/server_pod.go index 6e24b11f..457e1665 100644 --- a/common/server/server_pod.go +++ b/common/server/server_pod.go @@ -1,10 +1,10 @@ package server import ( + "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server" "context" - "gitlink.org.cn/JCCE/PCM/adaptor/pod/server" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" "github.com/golang/glog" "google.golang.org/grpc/codes" diff --git a/common/tenanter/main_test.go b/common/tenanter/main_test.go index 51cda479..2e0db2d8 100644 --- a/common/tenanter/main_test.go +++ b/common/tenanter/main_test.go @@ -1,7 +1,7 @@ package tenanter import ( - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "os" "testing" ) diff --git a/common/tenanter/region.go b/common/tenanter/region.go index 71dff562..4ef4bdb5 100644 --- a/common/tenanter/region.go +++ b/common/tenanter/region.go @@ -3,7 +3,7 @@ package tenanter import ( "strings" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "github.com/pkg/errors" ) diff --git a/common/tenanter/region_test.go b/common/tenanter/region_test.go index 7314a417..1bd8d745 100644 --- a/common/tenanter/region_test.go +++ b/common/tenanter/region_test.go @@ -3,7 +3,7 @@ package tenanter import ( "testing" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" ) func TestGetAllRegionIds(t *testing.T) { diff --git a/common/tenanter/tenanter.go b/common/tenanter/tenanter.go index 2a2a785f..12b67887 100644 --- a/common/tenanter/tenanter.go +++ b/common/tenanter/tenanter.go @@ -1,10 +1,10 @@ package tenanter import ( + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "encoding/json" "flag" "github.com/golang/glog" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" "io/ioutil" "os" "sync" diff --git a/examples/pcm_ali.go b/examples/pcm_ali.go index e72ab41c..67115fc5 100644 --- a/examples/pcm_ali.go +++ b/examples/pcm_ali.go @@ -1,8 +1,8 @@ package main import ( + pcm_pod_ali "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/ali" "github.com/alibabacloud-go/tea/tea" - pcm_pod_ali "gitlink.org.cn/JCCE/PCM/adaptor/pod/server/ali" "os" ) diff --git a/examples/pcm_huawei.go b/examples/pcm_huawei.go index c4c23eb7..60efe586 100644 --- a/examples/pcm_huawei.go +++ b/examples/pcm_huawei.go @@ -1,11 +1,11 @@ package main import ( + corev1 "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/core/v1" + "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/client-go/kubernetes" "context" "fmt" "github.com/pkg/errors" - corev1 "gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/api/core/v1" - "gitlink.org.cn/JCCE/PCM/adaptor/pod/server/kubernetes/client-go/kubernetes" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/clientcmd" @@ -55,19 +55,19 @@ func CreatePod(client *kubernetes.Clientset) (*corev1.Pod, error) { Kind: "Pod", }, ObjectMeta: metav1.ObjectMeta{ - Name: "hw-sdk-hwk8s", + Name: "hw-sdk-hwk8s01", Namespace: "pcm", Labels: map[string]string{"name": "test_api"}, }, Spec: corev1.PodSpec{ - ProviderId: 3, + ProviderId: 0, //ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3 - RegionId: "ap-guangzhou", + RegionId: "cn-hangzhou", RestartPolicy: corev1.RestartPolicyAlways, Containers: []corev1.Container{ { - Name: "sdk-hwk8s-container", - Image: "library/nginx:stable-alpine-perl", + Name: "sdk-hwk8s01-container", + Image: "registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/alpine:3.5", Resources: corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceCPU: resource.MustParse("1000m"), @@ -101,19 +101,23 @@ func UpdatePod(client *kubernetes.Clientset) error { Kind: "Pod", }, ObjectMeta: metav1.ObjectMeta{ - Name: "hw-sdk-test", + Name: "hw-sdk-test002", Namespace: "pcm", + UID: "eci-bp123wba1qv9xymntd24", Labels: map[string]string{"name": "test_api222"}, }, Spec: corev1.PodSpec{ + ProviderId: 0, + //ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3 + RegionId: "cn-hangzhou", RestartPolicy: corev1.RestartPolicyAlways, Containers: []corev1.Container{ { - Name: "pcm-sdk-huawei-container2", + Name: "pcm-sdk-huawei-contai", Image: "nginx:latest", Resources: corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ - corev1.ResourceCPU: resource.MustParse("500m"), + corev1.ResourceCPU: resource.MustParse("2000m"), corev1.ResourceMemory: resource.MustParse("1Gi"), }, }, @@ -134,9 +138,15 @@ func DeletePod(client *kubernetes.Clientset) error { // ListPod 查询Pod func ListPod(client *kubernetes.Clientset) (*corev1.PodList, error) { + pod := corev1.Pod{ + Spec: corev1.PodSpec{ + ProviderId: 0, + //ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3 + //RegionId: "ap-guangzhou", + }, + } - podList, _ := client.CoreV1().Pods("pcm").List(context.TODO(), metav1.ListOptions{}) - println(podList.Items[0].Name) + podList, _ := client.CoreV1().Pods("pcm").List(context.TODO(), &pod, metav1.ListOptions{}) return podList, nil } func main() { @@ -156,26 +166,26 @@ func main() { } cs, err := kubernetes.NewForConfig(cciConfig) - fmt.Println("start to create Pod") - _, err = CreatePod(cs) - if err != nil { - panic(err) - } - fmt.Println("Pod created") - // + //fmt.Println("start to create Pod") + //_, err = CreatePod(cs) + //if err != nil { + // panic(err) + //} + //fmt.Println("Pod created") + //fmt.Println("start to get Pod details") //_, err = ListPod(cs) //if err != nil { // panic(err) //} //fmt.Println("Pod details got") - // - //fmt.Println("start to update Pod") - //err = UpdatePod(cs) - //if err != nil { - // panic(err) - //} - //fmt.Println("Pod updated") + + fmt.Println("start to update Pod") + err = UpdatePod(cs) + if err != nil { + panic(err) + } + fmt.Println("Pod updated") // //fmt.Println("start to delete Pod") //err = DeletePod(cs) diff --git a/go.mod b/go.mod index 020dd019..83f1d436 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module gitlink.org.cn/JCCE/PCM +module code.gitlink.org.cn/JCCE/PCM go 1.17 @@ -12,7 +12,6 @@ require ( github.com/bitly/go-simplejson v0.5.0 github.com/docker/docker v20.10.6+incompatible github.com/go-yaml/yaml v2.1.0+incompatible - github.com/gogo/protobuf v1.3.2 github.com/golang/glog v1.0.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.0 github.com/harvester/harvester v1.0.0 @@ -58,6 +57,7 @@ require ( github.com/go-openapi/jsonreference v0.19.5 // indirect github.com/go-openapi/spec v0.20.3 // indirect github.com/go-openapi/swag v0.19.14 // indirect + github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.7 // indirect diff --git a/idl/demo/demo.proto b/idl/demo/demo.proto index 66ce8254..ca8c9c0f 100644 --- a/idl/demo/demo.proto +++ b/idl/demo/demo.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package demo; -option go_package = "gitlink.org.cn/JCCE/PCM/lan_trans/gen/idl/demo"; +option go_package = "code.gitlink.org.cn/JCCE/PCM/lan_trans/gen/idl/demo"; import "google/api/annotations.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; diff --git a/idl/pbecs/ecs.proto b/idl/pbecs/ecs.proto index 7445c471..1e018fa3 100644 --- a/idl/pbecs/ecs.proto +++ b/idl/pbecs/ecs.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package pbecs; -option go_package = "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs"; +option go_package = "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs"; import "idl/pbtenant/tenant.proto"; import "google/api/annotations.proto"; diff --git a/idl/pbpod/pod.proto b/idl/pbpod/pod.proto index 207ea234..b3dd4d0f 100644 --- a/idl/pbpod/pod.proto +++ b/idl/pbpod/pod.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package pbpod; -option go_package = "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"; +option go_package = "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"; import "idl/pbtenant/tenant.proto"; import "google/api/annotations.proto"; diff --git a/idl/pbtenant/tenant.proto b/idl/pbtenant/tenant.proto index ce41b832..8b157e2e 100644 --- a/idl/pbtenant/tenant.proto +++ b/idl/pbtenant/tenant.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package pbtenant; -option go_package = "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"; +option go_package = "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"; import "google/api/annotations.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; @@ -173,7 +173,7 @@ service TenantService { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = { description : "所有云租户的认证服务" external_docs : { - url : "https://gitlink.org.cn/JCCE/PCM" + url : "https://code.gitlink.org.cn/JCCE/PCM" description: "Find out more about PCM" } }; diff --git a/lan_trans/idl/pbecs/ecs.pb.go b/lan_trans/idl/pbecs/ecs.pb.go index 7df1be7a..2b7c6d14 100644 --- a/lan_trans/idl/pbecs/ecs.pb.go +++ b/lan_trans/idl/pbecs/ecs.pb.go @@ -7,7 +7,7 @@ package pbecs import ( - pbtenant "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + pbtenant "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" diff --git a/lan_trans/idl/pbpod/pod.pb.go b/lan_trans/idl/pbpod/pod.pb.go index 9db7c7a4..f0ece565 100644 --- a/lan_trans/idl/pbpod/pod.pb.go +++ b/lan_trans/idl/pbpod/pod.pb.go @@ -7,7 +7,7 @@ package pbpod import ( - pbtenant "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + pbtenant "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" diff --git a/main.go b/main.go index d5ceec95..c72b22cb 100644 --- a/main.go +++ b/main.go @@ -1,13 +1,13 @@ package main import ( + "code.gitlink.org.cn/JCCE/PCM/common/server" + "code.gitlink.org.cn/JCCE/PCM/common/tenanter" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/demo" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" "context" "flag" - "gitlink.org.cn/JCCE/PCM/common/server" - "gitlink.org.cn/JCCE/PCM/common/tenanter" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/demo" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" - "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" "net" "net/http"