Merge pull request 'Huawei SDK update&module url update' (#14) from github_branch into master
This commit is contained in:
commit
2676a7b361
|
@ -1,15 +1,16 @@
|
||||||
package ali
|
package ali
|
||||||
|
|
||||||
import (
|
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"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
|
||||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"gitlink.org.cn/JCCE/PCM/adaptor/pod/server"
|
"strconv"
|
||||||
"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"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateContainerGroup invokes the eci.CreateContainerGroup API synchronously
|
// CreateContainerGroup invokes the eci.CreateContainerGroup API synchronously
|
||||||
|
@ -32,21 +33,26 @@ func CreateContainerGroup(request *CreateContainerGroupRequest) (response *Creat
|
||||||
glog.Infof("load tenant from file finished")
|
glog.Infof("load tenant from file finished")
|
||||||
tenanters, err := tenanter.GetTenanters(provider)
|
tenanters, err := tenanter.GetTenanters(provider)
|
||||||
var regionId int32
|
var regionId int32
|
||||||
|
var cpuPod string
|
||||||
|
var memoryPod string
|
||||||
|
container := *request.Container
|
||||||
|
containerImage := container[0].Image
|
||||||
|
containerName := container[0].Name
|
||||||
|
cpuPodFloat, _ := container[0].Cpu.GetValue()
|
||||||
|
memoryPodFloat, _ := container[0].Memory.GetValue()
|
||||||
switch request.ProviderId {
|
switch request.ProviderId {
|
||||||
case 0:
|
case 0:
|
||||||
regionId, _ = tenanter.GetAliRegionId(request.RegionId)
|
regionId, _ = tenanter.GetAliRegionId(request.RegionId)
|
||||||
case 1:
|
case 1:
|
||||||
regionId, _ = tenanter.GetTencentRegionId(request.RegionId)
|
regionId, _ = tenanter.GetTencentRegionId(request.RegionId)
|
||||||
case 2:
|
case 2:
|
||||||
|
//华为的CPU和内存数量要进行转换
|
||||||
regionId, _ = tenanter.GetHuaweiRegionId(request.RegionId)
|
regionId, _ = tenanter.GetHuaweiRegionId(request.RegionId)
|
||||||
|
cpuPod = strconv.FormatFloat(cpuPodFloat*1000, 'f', 0, 64)
|
||||||
|
memoryPod = strconv.FormatFloat(memoryPodFloat, 'f', 0, 64)
|
||||||
case 3:
|
case 3:
|
||||||
regionId, _ = tenanter.GetK8SRegionId(request.RegionId)
|
regionId, _ = tenanter.GetK8SRegionId(request.RegionId)
|
||||||
}
|
}
|
||||||
container := *request.Container
|
|
||||||
containerImage := container[0].Image
|
|
||||||
containerName := container[0].Name
|
|
||||||
containerPod := container[0].Cpu
|
|
||||||
memoryPod := container[0].Memory
|
|
||||||
|
|
||||||
requestPCM := &pbpod.CreatePodReq{
|
requestPCM := &pbpod.CreatePodReq{
|
||||||
RequestSource: "ali",
|
RequestSource: "ali",
|
||||||
|
@ -56,8 +62,8 @@ func CreateContainerGroup(request *CreateContainerGroupRequest) (response *Creat
|
||||||
RegionId: regionId,
|
RegionId: regionId,
|
||||||
ContainerImage: containerImage,
|
ContainerImage: containerImage,
|
||||||
ContainerName: containerName,
|
ContainerName: containerName,
|
||||||
CpuPod: string(containerPod),
|
CpuPod: cpuPod + "m",
|
||||||
MemoryPod: string(memoryPod),
|
MemoryPod: memoryPod + "Gi",
|
||||||
SecurityGroupId: "sg-6qlun7hd",
|
SecurityGroupId: "sg-6qlun7hd",
|
||||||
SubnetId: "subnet-mnwfg2fk",
|
SubnetId: "subnet-mnwfg2fk",
|
||||||
VpcId: "vpc-rkwt40g5",
|
VpcId: "vpc-rkwt40g5",
|
||||||
|
|
|
@ -16,15 +16,15 @@
|
||||||
package ali
|
package ali
|
||||||
|
|
||||||
import (
|
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"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
|
||||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
|
||||||
"github.com/golang/glog"
|
"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
|
// DeleteContainerGroup invokes the eci.DeleteContainerGroup API synchronously
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package ali
|
package ali
|
||||||
|
|
||||||
import (
|
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/requests"
|
||||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
|
"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
|
// DescribeContainerGroups invokes the eci.DescribeContainerGroups API synchronously
|
||||||
|
|
|
@ -16,15 +16,15 @@
|
||||||
package ali
|
package ali
|
||||||
|
|
||||||
import (
|
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"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
|
||||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
|
||||||
"github.com/golang/glog"
|
"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
|
// UpdateContainerGroup invokes the eci.UpdateContainerGroup API synchronously
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
Copyright 2017 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 (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IsAnAPIObject allows clients to preemptively get a reference to an API object and pass it to places that
|
||||||
|
// intend only to get a reference to that object. This simplifies the event recording interface.
|
||||||
|
func (obj *ObjectReference) SetGroupVersionKind(gvk schema.GroupVersionKind) {
|
||||||
|
obj.APIVersion, obj.Kind = gvk.ToAPIVersionAndKind()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj *ObjectReference) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return schema.FromAPIVersionAndKind(obj.APIVersion, obj.Kind)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj *ObjectReference) GetObjectKind() schema.ObjectKind { return obj }
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
|
||||||
|
import (
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GroupName is the group name use in this package
|
||||||
|
const GroupName = ""
|
||||||
|
|
||||||
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
|
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
|
||||||
|
|
||||||
|
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||||
|
func Resource(resource string) schema.GroupResource {
|
||||||
|
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// We only register manually written functions here. The registration of the
|
||||||
|
// generated functions takes place in the generated files. The separation
|
||||||
|
// makes the code compile even when the generated files are missing.
|
||||||
|
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||||
|
AddToScheme = SchemeBuilder.AddToScheme
|
||||||
|
)
|
||||||
|
|
||||||
|
// Adds the list of known types to the given scheme.
|
||||||
|
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||||
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
|
&Pod{},
|
||||||
|
&PodList{},
|
||||||
|
&PodStatusResult{},
|
||||||
|
&PodTemplate{},
|
||||||
|
&PodTemplateList{},
|
||||||
|
&ReplicationController{},
|
||||||
|
&ReplicationControllerList{},
|
||||||
|
&Service{},
|
||||||
|
&ServiceProxyOptions{},
|
||||||
|
&ServiceList{},
|
||||||
|
&Endpoints{},
|
||||||
|
&EndpointsList{},
|
||||||
|
&Node{},
|
||||||
|
&NodeList{},
|
||||||
|
&NodeProxyOptions{},
|
||||||
|
&Binding{},
|
||||||
|
&Event{},
|
||||||
|
&EventList{},
|
||||||
|
&List{},
|
||||||
|
&LimitRange{},
|
||||||
|
&LimitRangeList{},
|
||||||
|
&ResourceQuota{},
|
||||||
|
&ResourceQuotaList{},
|
||||||
|
&Namespace{},
|
||||||
|
&NamespaceList{},
|
||||||
|
&Secret{},
|
||||||
|
&SecretList{},
|
||||||
|
&ServiceAccount{},
|
||||||
|
&ServiceAccountList{},
|
||||||
|
&PersistentVolume{},
|
||||||
|
&PersistentVolumeList{},
|
||||||
|
&PersistentVolumeClaim{},
|
||||||
|
&PersistentVolumeClaimList{},
|
||||||
|
&PodAttachOptions{},
|
||||||
|
&PodLogOptions{},
|
||||||
|
&PodExecOptions{},
|
||||||
|
&PodPortForwardOptions{},
|
||||||
|
&PodProxyOptions{},
|
||||||
|
&ComponentStatus{},
|
||||||
|
&ComponentStatusList{},
|
||||||
|
&SerializedReference{},
|
||||||
|
&RangeAllocation{},
|
||||||
|
&ConfigMap{},
|
||||||
|
&ConfigMapList{},
|
||||||
|
&EphemeralContainers{},
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add common types
|
||||||
|
scheme.AddKnownTypes(SchemeGroupVersion, &metav1.Status{})
|
||||||
|
|
||||||
|
// Add the watch version that applies
|
||||||
|
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
Copyright 2017 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 (
|
||||||
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Returns string version of ResourceName.
|
||||||
|
func (rn ResourceName) String() string {
|
||||||
|
return string(rn)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cpu returns the Cpu limit if specified.
|
||||||
|
func (rl *ResourceList) Cpu() *resource.Quantity {
|
||||||
|
return rl.Name(ResourceCPU, resource.DecimalSI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Memory returns the Memory limit if specified.
|
||||||
|
func (rl *ResourceList) Memory() *resource.Quantity {
|
||||||
|
return rl.Name(ResourceMemory, resource.BinarySI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Storage returns the Storage limit if specified.
|
||||||
|
func (rl *ResourceList) Storage() *resource.Quantity {
|
||||||
|
return rl.Name(ResourceStorage, resource.BinarySI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pods returns the list of pods
|
||||||
|
func (rl *ResourceList) Pods() *resource.Quantity {
|
||||||
|
return rl.Name(ResourcePods, resource.DecimalSI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageEphemeral returns the list of ephemeral storage volumes, if any
|
||||||
|
func (rl *ResourceList) StorageEphemeral() *resource.Quantity {
|
||||||
|
return rl.Name(ResourceEphemeralStorage, resource.BinarySI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name returns the resource with name if specified, otherwise it returns a nil quantity with default format.
|
||||||
|
func (rl *ResourceList) Name(name ResourceName, defaultFormat resource.Format) *resource.Quantity {
|
||||||
|
if val, ok := (*rl)[name]; ok {
|
||||||
|
return &val
|
||||||
|
}
|
||||||
|
return &resource.Quantity{Format: defaultFormat}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -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
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,685 @@
|
||||||
|
/*
|
||||||
|
Copyright 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by client-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package kubernetes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
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"
|
||||||
|
internalv1alpha1 "k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1"
|
||||||
|
appsv1 "k8s.io/client-go/kubernetes/typed/apps/v1"
|
||||||
|
appsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1"
|
||||||
|
appsv1beta2 "k8s.io/client-go/kubernetes/typed/apps/v1beta2"
|
||||||
|
authenticationv1 "k8s.io/client-go/kubernetes/typed/authentication/v1"
|
||||||
|
authenticationv1beta1 "k8s.io/client-go/kubernetes/typed/authentication/v1beta1"
|
||||||
|
authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1"
|
||||||
|
authorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1"
|
||||||
|
autoscalingv1 "k8s.io/client-go/kubernetes/typed/autoscaling/v1"
|
||||||
|
autoscalingv2beta1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1"
|
||||||
|
autoscalingv2beta2 "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2"
|
||||||
|
batchv1 "k8s.io/client-go/kubernetes/typed/batch/v1"
|
||||||
|
batchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1"
|
||||||
|
certificatesv1 "k8s.io/client-go/kubernetes/typed/certificates/v1"
|
||||||
|
certificatesv1beta1 "k8s.io/client-go/kubernetes/typed/certificates/v1beta1"
|
||||||
|
coordinationv1 "k8s.io/client-go/kubernetes/typed/coordination/v1"
|
||||||
|
coordinationv1beta1 "k8s.io/client-go/kubernetes/typed/coordination/v1beta1"
|
||||||
|
discoveryv1 "k8s.io/client-go/kubernetes/typed/discovery/v1"
|
||||||
|
discoveryv1beta1 "k8s.io/client-go/kubernetes/typed/discovery/v1beta1"
|
||||||
|
eventsv1 "k8s.io/client-go/kubernetes/typed/events/v1"
|
||||||
|
eventsv1beta1 "k8s.io/client-go/kubernetes/typed/events/v1beta1"
|
||||||
|
extensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
|
||||||
|
flowcontrolv1alpha1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1alpha1"
|
||||||
|
flowcontrolv1beta1 "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1"
|
||||||
|
networkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1"
|
||||||
|
networkingv1beta1 "k8s.io/client-go/kubernetes/typed/networking/v1beta1"
|
||||||
|
nodev1 "k8s.io/client-go/kubernetes/typed/node/v1"
|
||||||
|
nodev1alpha1 "k8s.io/client-go/kubernetes/typed/node/v1alpha1"
|
||||||
|
nodev1beta1 "k8s.io/client-go/kubernetes/typed/node/v1beta1"
|
||||||
|
policyv1 "k8s.io/client-go/kubernetes/typed/policy/v1"
|
||||||
|
policyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1"
|
||||||
|
rbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1"
|
||||||
|
rbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1"
|
||||||
|
rbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1"
|
||||||
|
schedulingv1 "k8s.io/client-go/kubernetes/typed/scheduling/v1"
|
||||||
|
schedulingv1alpha1 "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1"
|
||||||
|
schedulingv1beta1 "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1"
|
||||||
|
storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1"
|
||||||
|
storagev1alpha1 "k8s.io/client-go/kubernetes/typed/storage/v1alpha1"
|
||||||
|
storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1"
|
||||||
|
rest "k8s.io/client-go/rest"
|
||||||
|
flowcontrol "k8s.io/client-go/util/flowcontrol"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Interface interface {
|
||||||
|
Discovery() discovery.DiscoveryInterface
|
||||||
|
AdmissionregistrationV1() admissionregistrationv1.AdmissionregistrationV1Interface
|
||||||
|
AdmissionregistrationV1beta1() admissionregistrationv1beta1.AdmissionregistrationV1beta1Interface
|
||||||
|
InternalV1alpha1() internalv1alpha1.InternalV1alpha1Interface
|
||||||
|
AppsV1() appsv1.AppsV1Interface
|
||||||
|
AppsV1beta1() appsv1beta1.AppsV1beta1Interface
|
||||||
|
AppsV1beta2() appsv1beta2.AppsV1beta2Interface
|
||||||
|
AuthenticationV1() authenticationv1.AuthenticationV1Interface
|
||||||
|
AuthenticationV1beta1() authenticationv1beta1.AuthenticationV1beta1Interface
|
||||||
|
AuthorizationV1() authorizationv1.AuthorizationV1Interface
|
||||||
|
AuthorizationV1beta1() authorizationv1beta1.AuthorizationV1beta1Interface
|
||||||
|
AutoscalingV1() autoscalingv1.AutoscalingV1Interface
|
||||||
|
AutoscalingV2beta1() autoscalingv2beta1.AutoscalingV2beta1Interface
|
||||||
|
AutoscalingV2beta2() autoscalingv2beta2.AutoscalingV2beta2Interface
|
||||||
|
BatchV1() batchv1.BatchV1Interface
|
||||||
|
BatchV1beta1() batchv1beta1.BatchV1beta1Interface
|
||||||
|
CertificatesV1() certificatesv1.CertificatesV1Interface
|
||||||
|
CertificatesV1beta1() certificatesv1beta1.CertificatesV1beta1Interface
|
||||||
|
CoordinationV1beta1() coordinationv1beta1.CoordinationV1beta1Interface
|
||||||
|
CoordinationV1() coordinationv1.CoordinationV1Interface
|
||||||
|
CoreV1() corev1.CoreV1Interface
|
||||||
|
DiscoveryV1() discoveryv1.DiscoveryV1Interface
|
||||||
|
DiscoveryV1beta1() discoveryv1beta1.DiscoveryV1beta1Interface
|
||||||
|
EventsV1() eventsv1.EventsV1Interface
|
||||||
|
EventsV1beta1() eventsv1beta1.EventsV1beta1Interface
|
||||||
|
ExtensionsV1beta1() extensionsv1beta1.ExtensionsV1beta1Interface
|
||||||
|
FlowcontrolV1alpha1() flowcontrolv1alpha1.FlowcontrolV1alpha1Interface
|
||||||
|
FlowcontrolV1beta1() flowcontrolv1beta1.FlowcontrolV1beta1Interface
|
||||||
|
NetworkingV1() networkingv1.NetworkingV1Interface
|
||||||
|
NetworkingV1beta1() networkingv1beta1.NetworkingV1beta1Interface
|
||||||
|
NodeV1() nodev1.NodeV1Interface
|
||||||
|
NodeV1alpha1() nodev1alpha1.NodeV1alpha1Interface
|
||||||
|
NodeV1beta1() nodev1beta1.NodeV1beta1Interface
|
||||||
|
PolicyV1() policyv1.PolicyV1Interface
|
||||||
|
PolicyV1beta1() policyv1beta1.PolicyV1beta1Interface
|
||||||
|
RbacV1() rbacv1.RbacV1Interface
|
||||||
|
RbacV1beta1() rbacv1beta1.RbacV1beta1Interface
|
||||||
|
RbacV1alpha1() rbacv1alpha1.RbacV1alpha1Interface
|
||||||
|
SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1Interface
|
||||||
|
SchedulingV1beta1() schedulingv1beta1.SchedulingV1beta1Interface
|
||||||
|
SchedulingV1() schedulingv1.SchedulingV1Interface
|
||||||
|
StorageV1beta1() storagev1beta1.StorageV1beta1Interface
|
||||||
|
StorageV1() storagev1.StorageV1Interface
|
||||||
|
StorageV1alpha1() storagev1alpha1.StorageV1alpha1Interface
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clientset contains the clients for groups. Each group has exactly one
|
||||||
|
// version included in a Clientset.
|
||||||
|
type Clientset struct {
|
||||||
|
*discovery.DiscoveryClient
|
||||||
|
admissionregistrationV1 *admissionregistrationv1.AdmissionregistrationV1Client
|
||||||
|
admissionregistrationV1beta1 *admissionregistrationv1beta1.AdmissionregistrationV1beta1Client
|
||||||
|
internalV1alpha1 *internalv1alpha1.InternalV1alpha1Client
|
||||||
|
appsV1 *appsv1.AppsV1Client
|
||||||
|
appsV1beta1 *appsv1beta1.AppsV1beta1Client
|
||||||
|
appsV1beta2 *appsv1beta2.AppsV1beta2Client
|
||||||
|
authenticationV1 *authenticationv1.AuthenticationV1Client
|
||||||
|
authenticationV1beta1 *authenticationv1beta1.AuthenticationV1beta1Client
|
||||||
|
authorizationV1 *authorizationv1.AuthorizationV1Client
|
||||||
|
authorizationV1beta1 *authorizationv1beta1.AuthorizationV1beta1Client
|
||||||
|
autoscalingV1 *autoscalingv1.AutoscalingV1Client
|
||||||
|
autoscalingV2beta1 *autoscalingv2beta1.AutoscalingV2beta1Client
|
||||||
|
autoscalingV2beta2 *autoscalingv2beta2.AutoscalingV2beta2Client
|
||||||
|
batchV1 *batchv1.BatchV1Client
|
||||||
|
batchV1beta1 *batchv1beta1.BatchV1beta1Client
|
||||||
|
certificatesV1 *certificatesv1.CertificatesV1Client
|
||||||
|
certificatesV1beta1 *certificatesv1beta1.CertificatesV1beta1Client
|
||||||
|
coordinationV1beta1 *coordinationv1beta1.CoordinationV1beta1Client
|
||||||
|
coordinationV1 *coordinationv1.CoordinationV1Client
|
||||||
|
coreV1 *corev1.CoreV1Client
|
||||||
|
discoveryV1 *discoveryv1.DiscoveryV1Client
|
||||||
|
discoveryV1beta1 *discoveryv1beta1.DiscoveryV1beta1Client
|
||||||
|
eventsV1 *eventsv1.EventsV1Client
|
||||||
|
eventsV1beta1 *eventsv1beta1.EventsV1beta1Client
|
||||||
|
extensionsV1beta1 *extensionsv1beta1.ExtensionsV1beta1Client
|
||||||
|
flowcontrolV1alpha1 *flowcontrolv1alpha1.FlowcontrolV1alpha1Client
|
||||||
|
flowcontrolV1beta1 *flowcontrolv1beta1.FlowcontrolV1beta1Client
|
||||||
|
networkingV1 *networkingv1.NetworkingV1Client
|
||||||
|
networkingV1beta1 *networkingv1beta1.NetworkingV1beta1Client
|
||||||
|
nodeV1 *nodev1.NodeV1Client
|
||||||
|
nodeV1alpha1 *nodev1alpha1.NodeV1alpha1Client
|
||||||
|
nodeV1beta1 *nodev1beta1.NodeV1beta1Client
|
||||||
|
policyV1 *policyv1.PolicyV1Client
|
||||||
|
policyV1beta1 *policyv1beta1.PolicyV1beta1Client
|
||||||
|
rbacV1 *rbacv1.RbacV1Client
|
||||||
|
rbacV1beta1 *rbacv1beta1.RbacV1beta1Client
|
||||||
|
rbacV1alpha1 *rbacv1alpha1.RbacV1alpha1Client
|
||||||
|
schedulingV1alpha1 *schedulingv1alpha1.SchedulingV1alpha1Client
|
||||||
|
schedulingV1beta1 *schedulingv1beta1.SchedulingV1beta1Client
|
||||||
|
schedulingV1 *schedulingv1.SchedulingV1Client
|
||||||
|
storageV1beta1 *storagev1beta1.StorageV1beta1Client
|
||||||
|
storageV1 *storagev1.StorageV1Client
|
||||||
|
storageV1alpha1 *storagev1alpha1.StorageV1alpha1Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdmissionregistrationV1 retrieves the AdmissionregistrationV1Client
|
||||||
|
func (c *Clientset) AdmissionregistrationV1() admissionregistrationv1.AdmissionregistrationV1Interface {
|
||||||
|
return c.admissionregistrationV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdmissionregistrationV1beta1 retrieves the AdmissionregistrationV1beta1Client
|
||||||
|
func (c *Clientset) AdmissionregistrationV1beta1() admissionregistrationv1beta1.AdmissionregistrationV1beta1Interface {
|
||||||
|
return c.admissionregistrationV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// InternalV1alpha1 retrieves the InternalV1alpha1Client
|
||||||
|
func (c *Clientset) InternalV1alpha1() internalv1alpha1.InternalV1alpha1Interface {
|
||||||
|
return c.internalV1alpha1
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppsV1 retrieves the AppsV1Client
|
||||||
|
func (c *Clientset) AppsV1() appsv1.AppsV1Interface {
|
||||||
|
return c.appsV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppsV1beta1 retrieves the AppsV1beta1Client
|
||||||
|
func (c *Clientset) AppsV1beta1() appsv1beta1.AppsV1beta1Interface {
|
||||||
|
return c.appsV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppsV1beta2 retrieves the AppsV1beta2Client
|
||||||
|
func (c *Clientset) AppsV1beta2() appsv1beta2.AppsV1beta2Interface {
|
||||||
|
return c.appsV1beta2
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthenticationV1 retrieves the AuthenticationV1Client
|
||||||
|
func (c *Clientset) AuthenticationV1() authenticationv1.AuthenticationV1Interface {
|
||||||
|
return c.authenticationV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthenticationV1beta1 retrieves the AuthenticationV1beta1Client
|
||||||
|
func (c *Clientset) AuthenticationV1beta1() authenticationv1beta1.AuthenticationV1beta1Interface {
|
||||||
|
return c.authenticationV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthorizationV1 retrieves the AuthorizationV1Client
|
||||||
|
func (c *Clientset) AuthorizationV1() authorizationv1.AuthorizationV1Interface {
|
||||||
|
return c.authorizationV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthorizationV1beta1 retrieves the AuthorizationV1beta1Client
|
||||||
|
func (c *Clientset) AuthorizationV1beta1() authorizationv1beta1.AuthorizationV1beta1Interface {
|
||||||
|
return c.authorizationV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// AutoscalingV1 retrieves the AutoscalingV1Client
|
||||||
|
func (c *Clientset) AutoscalingV1() autoscalingv1.AutoscalingV1Interface {
|
||||||
|
return c.autoscalingV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// AutoscalingV2beta1 retrieves the AutoscalingV2beta1Client
|
||||||
|
func (c *Clientset) AutoscalingV2beta1() autoscalingv2beta1.AutoscalingV2beta1Interface {
|
||||||
|
return c.autoscalingV2beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// AutoscalingV2beta2 retrieves the AutoscalingV2beta2Client
|
||||||
|
func (c *Clientset) AutoscalingV2beta2() autoscalingv2beta2.AutoscalingV2beta2Interface {
|
||||||
|
return c.autoscalingV2beta2
|
||||||
|
}
|
||||||
|
|
||||||
|
// BatchV1 retrieves the BatchV1Client
|
||||||
|
func (c *Clientset) BatchV1() batchv1.BatchV1Interface {
|
||||||
|
return c.batchV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// BatchV1beta1 retrieves the BatchV1beta1Client
|
||||||
|
func (c *Clientset) BatchV1beta1() batchv1beta1.BatchV1beta1Interface {
|
||||||
|
return c.batchV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// CertificatesV1 retrieves the CertificatesV1Client
|
||||||
|
func (c *Clientset) CertificatesV1() certificatesv1.CertificatesV1Interface {
|
||||||
|
return c.certificatesV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// CertificatesV1beta1 retrieves the CertificatesV1beta1Client
|
||||||
|
func (c *Clientset) CertificatesV1beta1() certificatesv1beta1.CertificatesV1beta1Interface {
|
||||||
|
return c.certificatesV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// CoordinationV1beta1 retrieves the CoordinationV1beta1Client
|
||||||
|
func (c *Clientset) CoordinationV1beta1() coordinationv1beta1.CoordinationV1beta1Interface {
|
||||||
|
return c.coordinationV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// CoordinationV1 retrieves the CoordinationV1Client
|
||||||
|
func (c *Clientset) CoordinationV1() coordinationv1.CoordinationV1Interface {
|
||||||
|
return c.coordinationV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// CoreV1 retrieves the CoreV1Client
|
||||||
|
func (c *Clientset) CoreV1() corev1.CoreV1Interface {
|
||||||
|
return c.coreV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// DiscoveryV1 retrieves the DiscoveryV1Client
|
||||||
|
func (c *Clientset) DiscoveryV1() discoveryv1.DiscoveryV1Interface {
|
||||||
|
return c.discoveryV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// DiscoveryV1beta1 retrieves the DiscoveryV1beta1Client
|
||||||
|
func (c *Clientset) DiscoveryV1beta1() discoveryv1beta1.DiscoveryV1beta1Interface {
|
||||||
|
return c.discoveryV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// EventsV1 retrieves the EventsV1Client
|
||||||
|
func (c *Clientset) EventsV1() eventsv1.EventsV1Interface {
|
||||||
|
return c.eventsV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// EventsV1beta1 retrieves the EventsV1beta1Client
|
||||||
|
func (c *Clientset) EventsV1beta1() eventsv1beta1.EventsV1beta1Interface {
|
||||||
|
return c.eventsV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtensionsV1beta1 retrieves the ExtensionsV1beta1Client
|
||||||
|
func (c *Clientset) ExtensionsV1beta1() extensionsv1beta1.ExtensionsV1beta1Interface {
|
||||||
|
return c.extensionsV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// FlowcontrolV1alpha1 retrieves the FlowcontrolV1alpha1Client
|
||||||
|
func (c *Clientset) FlowcontrolV1alpha1() flowcontrolv1alpha1.FlowcontrolV1alpha1Interface {
|
||||||
|
return c.flowcontrolV1alpha1
|
||||||
|
}
|
||||||
|
|
||||||
|
// FlowcontrolV1beta1 retrieves the FlowcontrolV1beta1Client
|
||||||
|
func (c *Clientset) FlowcontrolV1beta1() flowcontrolv1beta1.FlowcontrolV1beta1Interface {
|
||||||
|
return c.flowcontrolV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// NetworkingV1 retrieves the NetworkingV1Client
|
||||||
|
func (c *Clientset) NetworkingV1() networkingv1.NetworkingV1Interface {
|
||||||
|
return c.networkingV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// NetworkingV1beta1 retrieves the NetworkingV1beta1Client
|
||||||
|
func (c *Clientset) NetworkingV1beta1() networkingv1beta1.NetworkingV1beta1Interface {
|
||||||
|
return c.networkingV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeV1 retrieves the NodeV1Client
|
||||||
|
func (c *Clientset) NodeV1() nodev1.NodeV1Interface {
|
||||||
|
return c.nodeV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeV1alpha1 retrieves the NodeV1alpha1Client
|
||||||
|
func (c *Clientset) NodeV1alpha1() nodev1alpha1.NodeV1alpha1Interface {
|
||||||
|
return c.nodeV1alpha1
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeV1beta1 retrieves the NodeV1beta1Client
|
||||||
|
func (c *Clientset) NodeV1beta1() nodev1beta1.NodeV1beta1Interface {
|
||||||
|
return c.nodeV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// PolicyV1 retrieves the PolicyV1Client
|
||||||
|
func (c *Clientset) PolicyV1() policyv1.PolicyV1Interface {
|
||||||
|
return c.policyV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// PolicyV1beta1 retrieves the PolicyV1beta1Client
|
||||||
|
func (c *Clientset) PolicyV1beta1() policyv1beta1.PolicyV1beta1Interface {
|
||||||
|
return c.policyV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// RbacV1 retrieves the RbacV1Client
|
||||||
|
func (c *Clientset) RbacV1() rbacv1.RbacV1Interface {
|
||||||
|
return c.rbacV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// RbacV1beta1 retrieves the RbacV1beta1Client
|
||||||
|
func (c *Clientset) RbacV1beta1() rbacv1beta1.RbacV1beta1Interface {
|
||||||
|
return c.rbacV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// RbacV1alpha1 retrieves the RbacV1alpha1Client
|
||||||
|
func (c *Clientset) RbacV1alpha1() rbacv1alpha1.RbacV1alpha1Interface {
|
||||||
|
return c.rbacV1alpha1
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchedulingV1alpha1 retrieves the SchedulingV1alpha1Client
|
||||||
|
func (c *Clientset) SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1Interface {
|
||||||
|
return c.schedulingV1alpha1
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchedulingV1beta1 retrieves the SchedulingV1beta1Client
|
||||||
|
func (c *Clientset) SchedulingV1beta1() schedulingv1beta1.SchedulingV1beta1Interface {
|
||||||
|
return c.schedulingV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchedulingV1 retrieves the SchedulingV1Client
|
||||||
|
func (c *Clientset) SchedulingV1() schedulingv1.SchedulingV1Interface {
|
||||||
|
return c.schedulingV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageV1beta1 retrieves the StorageV1beta1Client
|
||||||
|
func (c *Clientset) StorageV1beta1() storagev1beta1.StorageV1beta1Interface {
|
||||||
|
return c.storageV1beta1
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageV1 retrieves the StorageV1Client
|
||||||
|
func (c *Clientset) StorageV1() storagev1.StorageV1Interface {
|
||||||
|
return c.storageV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageV1alpha1 retrieves the StorageV1alpha1Client
|
||||||
|
func (c *Clientset) StorageV1alpha1() storagev1alpha1.StorageV1alpha1Interface {
|
||||||
|
return c.storageV1alpha1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Discovery retrieves the DiscoveryClient
|
||||||
|
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
||||||
|
if c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return c.DiscoveryClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewForConfig creates a new Clientset for the given config.
|
||||||
|
// If config's RateLimiter is not set and QPS and Burst are acceptable,
|
||||||
|
// NewForConfig will generate a rate-limiter in configShallowCopy.
|
||||||
|
func NewForConfig(c *rest.Config) (*Clientset, error) {
|
||||||
|
configShallowCopy := *c
|
||||||
|
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
|
||||||
|
if configShallowCopy.Burst <= 0 {
|
||||||
|
return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0")
|
||||||
|
}
|
||||||
|
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
|
||||||
|
}
|
||||||
|
var cs Clientset
|
||||||
|
var err error
|
||||||
|
cs.admissionregistrationV1, err = admissionregistrationv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.admissionregistrationV1beta1, err = admissionregistrationv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.internalV1alpha1, err = internalv1alpha1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.appsV1, err = appsv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.appsV1beta1, err = appsv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.appsV1beta2, err = appsv1beta2.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.authenticationV1, err = authenticationv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.authenticationV1beta1, err = authenticationv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.authorizationV1, err = authorizationv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.authorizationV1beta1, err = authorizationv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.autoscalingV1, err = autoscalingv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.autoscalingV2beta1, err = autoscalingv2beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.autoscalingV2beta2, err = autoscalingv2beta2.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.batchV1, err = batchv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.batchV1beta1, err = batchv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.certificatesV1, err = certificatesv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.certificatesV1beta1, err = certificatesv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.coordinationV1beta1, err = coordinationv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.coordinationV1, err = coordinationv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.coreV1, err = corev1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.discoveryV1, err = discoveryv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.discoveryV1beta1, err = discoveryv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.eventsV1, err = eventsv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.eventsV1beta1, err = eventsv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.extensionsV1beta1, err = extensionsv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.flowcontrolV1alpha1, err = flowcontrolv1alpha1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.flowcontrolV1beta1, err = flowcontrolv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.networkingV1, err = networkingv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.networkingV1beta1, err = networkingv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.nodeV1, err = nodev1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.nodeV1alpha1, err = nodev1alpha1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.nodeV1beta1, err = nodev1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.policyV1, err = policyv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.policyV1beta1, err = policyv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.rbacV1, err = rbacv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.rbacV1beta1, err = rbacv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.rbacV1alpha1, err = rbacv1alpha1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.schedulingV1alpha1, err = schedulingv1alpha1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.schedulingV1beta1, err = schedulingv1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.schedulingV1, err = schedulingv1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.storageV1beta1, err = storagev1beta1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.storageV1, err = storagev1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cs.storageV1alpha1, err = storagev1alpha1.NewForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &cs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewForConfigOrDie creates a new Clientset for the given config and
|
||||||
|
// panics if there is an error in the config.
|
||||||
|
func NewForConfigOrDie(c *rest.Config) *Clientset {
|
||||||
|
var cs Clientset
|
||||||
|
cs.admissionregistrationV1 = admissionregistrationv1.NewForConfigOrDie(c)
|
||||||
|
cs.admissionregistrationV1beta1 = admissionregistrationv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.internalV1alpha1 = internalv1alpha1.NewForConfigOrDie(c)
|
||||||
|
cs.appsV1 = appsv1.NewForConfigOrDie(c)
|
||||||
|
cs.appsV1beta1 = appsv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.appsV1beta2 = appsv1beta2.NewForConfigOrDie(c)
|
||||||
|
cs.authenticationV1 = authenticationv1.NewForConfigOrDie(c)
|
||||||
|
cs.authenticationV1beta1 = authenticationv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.authorizationV1 = authorizationv1.NewForConfigOrDie(c)
|
||||||
|
cs.authorizationV1beta1 = authorizationv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.autoscalingV1 = autoscalingv1.NewForConfigOrDie(c)
|
||||||
|
cs.autoscalingV2beta1 = autoscalingv2beta1.NewForConfigOrDie(c)
|
||||||
|
cs.autoscalingV2beta2 = autoscalingv2beta2.NewForConfigOrDie(c)
|
||||||
|
cs.batchV1 = batchv1.NewForConfigOrDie(c)
|
||||||
|
cs.batchV1beta1 = batchv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.certificatesV1 = certificatesv1.NewForConfigOrDie(c)
|
||||||
|
cs.certificatesV1beta1 = certificatesv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.coordinationV1beta1 = coordinationv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.coordinationV1 = coordinationv1.NewForConfigOrDie(c)
|
||||||
|
cs.coreV1 = corev1.NewForConfigOrDie(c)
|
||||||
|
cs.discoveryV1 = discoveryv1.NewForConfigOrDie(c)
|
||||||
|
cs.discoveryV1beta1 = discoveryv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.eventsV1 = eventsv1.NewForConfigOrDie(c)
|
||||||
|
cs.eventsV1beta1 = eventsv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.extensionsV1beta1 = extensionsv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.flowcontrolV1alpha1 = flowcontrolv1alpha1.NewForConfigOrDie(c)
|
||||||
|
cs.flowcontrolV1beta1 = flowcontrolv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.networkingV1 = networkingv1.NewForConfigOrDie(c)
|
||||||
|
cs.networkingV1beta1 = networkingv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.nodeV1 = nodev1.NewForConfigOrDie(c)
|
||||||
|
cs.nodeV1alpha1 = nodev1alpha1.NewForConfigOrDie(c)
|
||||||
|
cs.nodeV1beta1 = nodev1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.policyV1 = policyv1.NewForConfigOrDie(c)
|
||||||
|
cs.policyV1beta1 = policyv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.rbacV1 = rbacv1.NewForConfigOrDie(c)
|
||||||
|
cs.rbacV1beta1 = rbacv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.rbacV1alpha1 = rbacv1alpha1.NewForConfigOrDie(c)
|
||||||
|
cs.schedulingV1alpha1 = schedulingv1alpha1.NewForConfigOrDie(c)
|
||||||
|
cs.schedulingV1beta1 = schedulingv1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.schedulingV1 = schedulingv1.NewForConfigOrDie(c)
|
||||||
|
cs.storageV1beta1 = storagev1beta1.NewForConfigOrDie(c)
|
||||||
|
cs.storageV1 = storagev1.NewForConfigOrDie(c)
|
||||||
|
cs.storageV1alpha1 = storagev1alpha1.NewForConfigOrDie(c)
|
||||||
|
|
||||||
|
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
|
||||||
|
return &cs
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new Clientset for the given RESTClient.
|
||||||
|
func New(c rest.Interface) *Clientset {
|
||||||
|
var cs Clientset
|
||||||
|
cs.admissionregistrationV1 = admissionregistrationv1.New(c)
|
||||||
|
cs.admissionregistrationV1beta1 = admissionregistrationv1beta1.New(c)
|
||||||
|
cs.internalV1alpha1 = internalv1alpha1.New(c)
|
||||||
|
cs.appsV1 = appsv1.New(c)
|
||||||
|
cs.appsV1beta1 = appsv1beta1.New(c)
|
||||||
|
cs.appsV1beta2 = appsv1beta2.New(c)
|
||||||
|
cs.authenticationV1 = authenticationv1.New(c)
|
||||||
|
cs.authenticationV1beta1 = authenticationv1beta1.New(c)
|
||||||
|
cs.authorizationV1 = authorizationv1.New(c)
|
||||||
|
cs.authorizationV1beta1 = authorizationv1beta1.New(c)
|
||||||
|
cs.autoscalingV1 = autoscalingv1.New(c)
|
||||||
|
cs.autoscalingV2beta1 = autoscalingv2beta1.New(c)
|
||||||
|
cs.autoscalingV2beta2 = autoscalingv2beta2.New(c)
|
||||||
|
cs.batchV1 = batchv1.New(c)
|
||||||
|
cs.batchV1beta1 = batchv1beta1.New(c)
|
||||||
|
cs.certificatesV1 = certificatesv1.New(c)
|
||||||
|
cs.certificatesV1beta1 = certificatesv1beta1.New(c)
|
||||||
|
cs.coordinationV1beta1 = coordinationv1beta1.New(c)
|
||||||
|
cs.coordinationV1 = coordinationv1.New(c)
|
||||||
|
cs.coreV1 = corev1.New(c)
|
||||||
|
cs.discoveryV1 = discoveryv1.New(c)
|
||||||
|
cs.discoveryV1beta1 = discoveryv1beta1.New(c)
|
||||||
|
cs.eventsV1 = eventsv1.New(c)
|
||||||
|
cs.eventsV1beta1 = eventsv1beta1.New(c)
|
||||||
|
cs.extensionsV1beta1 = extensionsv1beta1.New(c)
|
||||||
|
cs.flowcontrolV1alpha1 = flowcontrolv1alpha1.New(c)
|
||||||
|
cs.flowcontrolV1beta1 = flowcontrolv1beta1.New(c)
|
||||||
|
cs.networkingV1 = networkingv1.New(c)
|
||||||
|
cs.networkingV1beta1 = networkingv1beta1.New(c)
|
||||||
|
cs.nodeV1 = nodev1.New(c)
|
||||||
|
cs.nodeV1alpha1 = nodev1alpha1.New(c)
|
||||||
|
cs.nodeV1beta1 = nodev1beta1.New(c)
|
||||||
|
cs.policyV1 = policyv1.New(c)
|
||||||
|
cs.policyV1beta1 = policyv1beta1.New(c)
|
||||||
|
cs.rbacV1 = rbacv1.New(c)
|
||||||
|
cs.rbacV1beta1 = rbacv1beta1.New(c)
|
||||||
|
cs.rbacV1alpha1 = rbacv1alpha1.New(c)
|
||||||
|
cs.schedulingV1alpha1 = schedulingv1alpha1.New(c)
|
||||||
|
cs.schedulingV1beta1 = schedulingv1beta1.New(c)
|
||||||
|
cs.schedulingV1 = schedulingv1.New(c)
|
||||||
|
cs.storageV1beta1 = storagev1beta1.New(c)
|
||||||
|
cs.storageV1 = storagev1.New(c)
|
||||||
|
cs.storageV1alpha1 = storagev1alpha1.New(c)
|
||||||
|
|
||||||
|
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
|
||||||
|
return &cs
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
Copyright 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by client-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
|
rest "k8s.io/client-go/rest"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CoreV1Interface interface {
|
||||||
|
RESTClient() rest.Interface
|
||||||
|
PodsGetter
|
||||||
|
}
|
||||||
|
|
||||||
|
// CoreV1Client is used to interact with features provided by the group.
|
||||||
|
type CoreV1Client struct {
|
||||||
|
restClient rest.Interface
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CoreV1Client) Pods(namespace string) PodInterface {
|
||||||
|
//TODO implement me
|
||||||
|
return newPods(c, namespace)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewForConfig creates a new CoreV1Client for the given config.
|
||||||
|
func NewForConfig(c *rest.Config) (*CoreV1Client, error) {
|
||||||
|
config := *c
|
||||||
|
if err := setConfigDefaults(&config); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
client, err := rest.RESTClientFor(&config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &CoreV1Client{client}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewForConfigOrDie creates a new CoreV1Client for the given config and
|
||||||
|
// panics if there is an error in the config.
|
||||||
|
func NewForConfigOrDie(c *rest.Config) *CoreV1Client {
|
||||||
|
client, err := NewForConfig(c)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return client
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new CoreV1Client for the given RESTClient.
|
||||||
|
func New(c rest.Interface) *CoreV1Client {
|
||||||
|
return &CoreV1Client{c}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setConfigDefaults(config *rest.Config) error {
|
||||||
|
gv := v1.SchemeGroupVersion
|
||||||
|
config.GroupVersion = &gv
|
||||||
|
config.APIPath = "/api"
|
||||||
|
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
|
||||||
|
|
||||||
|
if config.UserAgent == "" {
|
||||||
|
config.UserAgent = rest.DefaultKubernetesUserAgent()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RESTClient returns a RESTClient that is used to communicate
|
||||||
|
// with API server by this client implementation.
|
||||||
|
func (c *CoreV1Client) RESTClient() rest.Interface {
|
||||||
|
if c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return c.restClient
|
||||||
|
}
|
|
@ -0,0 +1,532 @@
|
||||||
|
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"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
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"
|
||||||
|
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
|
rest "k8s.io/client-go/rest"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PodsGetter has a method to return a PodInterface.
|
||||||
|
// A group's client should implement this interface.
|
||||||
|
type PodsGetter interface {
|
||||||
|
Pods(namespace string) PodInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
// PodInterface has methods to work with Pod resources.
|
||||||
|
type PodInterface interface {
|
||||||
|
Create(ctx context.Context, pod *v1.Pod, opts metav1.CreateOptions) (*v1.Pod, error)
|
||||||
|
Update(ctx context.Context, pod *v1.Pod, opts metav1.UpdateOptions) (*v1.Pod, error)
|
||||||
|
UpdateStatus(ctx context.Context, pod *v1.Pod, opts metav1.UpdateOptions) (*v1.Pod, error)
|
||||||
|
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, 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)
|
||||||
|
ApplyStatus(ctx context.Context, pod *corev1.PodApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Pod, err error)
|
||||||
|
GetEphemeralContainers(ctx context.Context, podName string, options metav1.GetOptions) (*v1.EphemeralContainers, error)
|
||||||
|
UpdateEphemeralContainers(ctx context.Context, podName string, ephemeralContainers *v1.EphemeralContainers, opts metav1.UpdateOptions) (*v1.EphemeralContainers, error)
|
||||||
|
|
||||||
|
PodExpansion
|
||||||
|
}
|
||||||
|
|
||||||
|
// pods implements PodInterface
|
||||||
|
type pods struct {
|
||||||
|
client rest.Interface
|
||||||
|
ns string
|
||||||
|
}
|
||||||
|
|
||||||
|
// newPods returns a Pods
|
||||||
|
func newPods(c *CoreV1Client, namespace string) *pods {
|
||||||
|
return &pods{
|
||||||
|
client: c.RESTClient(),
|
||||||
|
ns: namespace,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get takes name of the pod, and returns the corresponding pod object, and an error if there is any.
|
||||||
|
func (c *pods) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Pod, err error) {
|
||||||
|
result = &v1.Pod{}
|
||||||
|
err = c.client.Get().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("pods").
|
||||||
|
Name(name).
|
||||||
|
VersionedParams(&options, scheme.ParameterCodec).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// List takes label and field selectors, and returns the list of Pods that match those selectors.
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch returns a watch.Interface that watches the requested pods.
|
||||||
|
func (c *pods) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
||||||
|
var timeout time.Duration
|
||||||
|
if opts.TimeoutSeconds != nil {
|
||||||
|
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||||
|
}
|
||||||
|
opts.Watch = true
|
||||||
|
return c.client.Get().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("pods").
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Timeout(timeout).
|
||||||
|
Watch(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create takes the representation of a pod and creates it. Returns the server's representation of the pod, and an error, if there is any.
|
||||||
|
func (c *pods) Create(ctx context.Context, pod *v1.Pod, opts metav1.CreateOptions) (result *v1.Pod, err error) {
|
||||||
|
result = &v1.Pod{}
|
||||||
|
|
||||||
|
provider := pbtenant.CloudProvider(pod.Spec.ProviderId)
|
||||||
|
var configFile string
|
||||||
|
flag.StringVar(&configFile, "conf", "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.CreatePodReq{
|
||||||
|
RequestSource: "huawei",
|
||||||
|
Provider: provider,
|
||||||
|
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,
|
||||||
|
SecurityGroupId: "sg-6qlun7hd",
|
||||||
|
SubnetId: "subnet-mnwfg2fk",
|
||||||
|
VpcId: "vpc-rkwt40g5",
|
||||||
|
Namespace: pod.ObjectMeta.Namespace,
|
||||||
|
}
|
||||||
|
|
||||||
|
server.CreatePod(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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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{}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStatus was generated because the type contains a Status member.
|
||||||
|
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
||||||
|
func (c *pods) UpdateStatus(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).
|
||||||
|
SubResource("status").
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Body(pod).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete takes name of the pod and deletes it. Returns an error if one occurs.
|
||||||
|
func (c *pods) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
||||||
|
return c.client.Delete().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("pods").
|
||||||
|
Name(name).
|
||||||
|
Body(&opts).
|
||||||
|
Do(ctx).
|
||||||
|
Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteCollection deletes a collection of objects.
|
||||||
|
func (c *pods) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||||
|
var timeout time.Duration
|
||||||
|
if listOpts.TimeoutSeconds != nil {
|
||||||
|
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
|
||||||
|
}
|
||||||
|
return c.client.Delete().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("pods").
|
||||||
|
VersionedParams(&listOpts, scheme.ParameterCodec).
|
||||||
|
Timeout(timeout).
|
||||||
|
Body(&opts).
|
||||||
|
Do(ctx).
|
||||||
|
Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Patch applies the patch and returns the patched pod.
|
||||||
|
func (c *pods) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Pod, err error) {
|
||||||
|
result = &v1.Pod{}
|
||||||
|
err = c.client.Patch(pt).
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("pods").
|
||||||
|
Name(name).
|
||||||
|
SubResource(subresources...).
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Body(data).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply takes the given apply declarative configuration, applies it and returns the applied pod.
|
||||||
|
func (c *pods) Apply(ctx context.Context, pod *corev1.PodApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Pod, err error) {
|
||||||
|
if pod == nil {
|
||||||
|
return nil, fmt.Errorf("pod provided to Apply must not be nil")
|
||||||
|
}
|
||||||
|
patchOpts := opts.ToPatchOptions()
|
||||||
|
data, err := json.Marshal(pod)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
name := pod.Name
|
||||||
|
if name == nil {
|
||||||
|
return nil, fmt.Errorf("pod.Name must be provided to Apply")
|
||||||
|
}
|
||||||
|
result = &v1.Pod{}
|
||||||
|
err = c.client.Patch(types.ApplyPatchType).
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("pods").
|
||||||
|
Name(*name).
|
||||||
|
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||||
|
Body(data).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ApplyStatus was generated because the type contains a Status member.
|
||||||
|
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
||||||
|
func (c *pods) ApplyStatus(ctx context.Context, pod *corev1.PodApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Pod, err error) {
|
||||||
|
if pod == nil {
|
||||||
|
return nil, fmt.Errorf("pod provided to Apply must not be nil")
|
||||||
|
}
|
||||||
|
patchOpts := opts.ToPatchOptions()
|
||||||
|
data, err := json.Marshal(pod)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
name := pod.Name
|
||||||
|
if name == nil {
|
||||||
|
return nil, fmt.Errorf("pod.Name must be provided to Apply")
|
||||||
|
}
|
||||||
|
|
||||||
|
result = &v1.Pod{}
|
||||||
|
err = c.client.Patch(types.ApplyPatchType).
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("pods").
|
||||||
|
Name(*name).
|
||||||
|
SubResource("status").
|
||||||
|
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||||
|
Body(data).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEphemeralContainers takes name of the pod, and returns the corresponding v1.EphemeralContainers object, and an error if there is any.
|
||||||
|
func (c *pods) GetEphemeralContainers(ctx context.Context, podName string, options metav1.GetOptions) (result *v1.EphemeralContainers, err error) {
|
||||||
|
result = &v1.EphemeralContainers{}
|
||||||
|
err = c.client.Get().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("pods").
|
||||||
|
Name(podName).
|
||||||
|
SubResource("ephemeralcontainers").
|
||||||
|
VersionedParams(&options, scheme.ParameterCodec).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateEphemeralContainers takes the top resource name and the representation of a ephemeralContainers and updates it. Returns the server's representation of the ephemeralContainers, and an error, if there is any.
|
||||||
|
func (c *pods) UpdateEphemeralContainers(ctx context.Context, podName string, ephemeralContainers *v1.EphemeralContainers, opts metav1.UpdateOptions) (result *v1.EphemeralContainers, err error) {
|
||||||
|
result = &v1.EphemeralContainers{}
|
||||||
|
err = c.client.Put().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("pods").
|
||||||
|
Name(podName).
|
||||||
|
SubResource("ephemeralcontainers").
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Body(ephemeralContainers).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
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 (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
|
policy "k8s.io/api/policy/v1beta1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/util/net"
|
||||||
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
|
restclient "k8s.io/client-go/rest"
|
||||||
|
)
|
||||||
|
|
||||||
|
// The PodExpansion interface allows manually adding extra methods to the PodInterface.
|
||||||
|
type PodExpansion interface {
|
||||||
|
Bind(ctx context.Context, binding *v1.Binding, opts metav1.CreateOptions) error
|
||||||
|
Evict(ctx context.Context, eviction *policy.Eviction) error
|
||||||
|
GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request
|
||||||
|
ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored).
|
||||||
|
func (c *pods) Bind(ctx context.Context, binding *v1.Binding, opts metav1.CreateOptions) error {
|
||||||
|
return c.client.Post().Namespace(c.ns).Resource("pods").Name(binding.Name).VersionedParams(&opts, scheme.ParameterCodec).SubResource("binding").Body(binding).Do(ctx).Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *pods) Evict(ctx context.Context, eviction *policy.Eviction) error {
|
||||||
|
return c.client.Post().Namespace(c.ns).Resource("pods").Name(eviction.Name).SubResource("eviction").Body(eviction).Do(ctx).Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get constructs a request for getting the logs for a pod
|
||||||
|
func (c *pods) GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request {
|
||||||
|
return c.client.Get().Namespace(c.ns).Name(name).Resource("pods").SubResource("log").VersionedParams(opts, scheme.ParameterCodec)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyGet returns a response of the pod by calling it through the proxy.
|
||||||
|
func (c *pods) ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper {
|
||||||
|
request := c.client.Get().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("pods").
|
||||||
|
SubResource("proxy").
|
||||||
|
Name(net.JoinSchemeNamePort(scheme, name, port)).
|
||||||
|
Suffix(path)
|
||||||
|
for k, v := range params {
|
||||||
|
request = request.Param(k, v)
|
||||||
|
}
|
||||||
|
return request
|
||||||
|
}
|
|
@ -6,10 +6,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"gitlink.org.cn/JCCE/PCM/adaptor/pod/service"
|
"code.gitlink.org.cn/JCCE/PCM/adaptor/pod/service"
|
||||||
"gitlink.org.cn/JCCE/PCM/common/tenanter"
|
"code.gitlink.org.cn/JCCE/PCM/common/tenanter"
|
||||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"
|
"code.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/pbtenant"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
|
@ -9,10 +9,10 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"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"
|
"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
|
var aliClientMutex sync.Mutex
|
||||||
|
|
|
@ -12,16 +12,16 @@ import (
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"
|
"code.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/pbtenant"
|
||||||
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
huaweicci "k8s.io/client-go/kubernetes"
|
huaweicci "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
"k8s.io/client-go/tools/clientcmd/api"
|
"k8s.io/client-go/tools/clientcmd/api"
|
||||||
|
|
||||||
|
"code.gitlink.org.cn/JCCE/PCM/common/tenanter"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gitlink.org.cn/JCCE/PCM/common/tenanter"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var huaweiClientMutex sync.Mutex
|
var huaweiClientMutex sync.Mutex
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package poder
|
package poder
|
||||||
|
|
||||||
import (
|
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"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/pkg/errors"
|
"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"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package poder
|
package poder
|
||||||
|
|
||||||
import (
|
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"
|
"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/golang/glog"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
|
@ -7,14 +7,14 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"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/pkg/errors"
|
||||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
|
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
|
||||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
||||||
tencenteks "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525"
|
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
|
var tencentClientMutex sync.Mutex
|
||||||
|
|
|
@ -4,12 +4,12 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"sync"
|
"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/golang/glog"
|
||||||
"github.com/pkg/errors"
|
"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
|
//CreateMultipleEcs 创建多云ECS
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package ecs
|
package ecs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs"
|
||||||
|
"code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
||||||
"context"
|
"context"
|
||||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs"
|
|
||||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package ecs
|
package ecs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gitlink.org.cn/JCCE/PCM/common/tenanter"
|
"code.gitlink.org.cn/JCCE/PCM/common/tenanter"
|
||||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
"code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,6 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"sync"
|
"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"
|
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
|
||||||
string_ "github.com/alibabacloud-go/darabonba-string/client"
|
string_ "github.com/alibabacloud-go/darabonba-string/client"
|
||||||
aliecs "github.com/alibabacloud-go/ecs-20140526/v2/client"
|
aliecs "github.com/alibabacloud-go/ecs-20140526/v2/client"
|
||||||
|
@ -11,9 +14,6 @@ import (
|
||||||
"github.com/alibabacloud-go/tea/tea"
|
"github.com/alibabacloud-go/tea/tea"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/pkg/errors"
|
"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
|
var aliClientMutex sync.Mutex
|
||||||
|
|
|
@ -10,10 +10,10 @@ package ecser
|
||||||
// awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2"
|
// awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2"
|
||||||
// "github.com/pkg/errors"
|
// "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"
|
// "code.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/pbtenant"
|
||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//type AwsEcs struct {
|
//type AwsEcs struct {
|
||||||
|
|
|
@ -3,9 +3,9 @@ package ecser
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"gitlink.org.cn/JCCE/PCM/common/tenanter"
|
"code.gitlink.org.cn/JCCE/PCM/common/tenanter"
|
||||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs"
|
"code.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/pbtenant"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package ecser
|
package ecser
|
||||||
|
|
||||||
import (
|
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"
|
"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"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package ecser
|
package ecser
|
||||||
|
|
||||||
import (
|
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"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/harvester/harvester/pkg/apis/harvesterhci.io/v1beta1"
|
"github.com/harvester/harvester/pkg/apis/harvesterhci.io/v1beta1"
|
||||||
|
@ -8,9 +11,6 @@ import (
|
||||||
"github.com/longhorn/longhorn-manager/util"
|
"github.com/longhorn/longhorn-manager/util"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"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"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
k8smetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
k8smetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
|
@ -4,6 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"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"
|
string_ "github.com/alibabacloud-go/darabonba-string/client"
|
||||||
util "github.com/alibabacloud-go/tea-utils/service"
|
util "github.com/alibabacloud-go/tea-utils/service"
|
||||||
"github.com/alibabacloud-go/tea/tea"
|
"github.com/alibabacloud-go/tea/tea"
|
||||||
|
@ -16,9 +19,6 @@ import (
|
||||||
iammodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
iammodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||||
iamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
iamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||||
"github.com/pkg/errors"
|
"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 {
|
type HuaweiEcs struct {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package ecser
|
package ecser
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gitlink.org.cn/JCCE/PCM/common/tenanter"
|
"code.gitlink.org.cn/JCCE/PCM/common/tenanter"
|
||||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
"code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,6 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"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"
|
string_ "github.com/alibabacloud-go/darabonba-string/client"
|
||||||
util "github.com/alibabacloud-go/tea-utils/service"
|
util "github.com/alibabacloud-go/tea-utils/service"
|
||||||
"github.com/alibabacloud-go/tea/tea"
|
"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"
|
||||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
||||||
cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
|
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 {
|
type TencentCvm struct {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
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"
|
"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 {
|
type Server struct {
|
||||||
|
|
|
@ -3,8 +3,8 @@ package server
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"gitlink.org.cn/JCCE/PCM/adaptor/vm/server/ecs"
|
"code.gitlink.org.cn/JCCE/PCM/adaptor/vm/server/ecs"
|
||||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs"
|
"code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server"
|
||||||
"context"
|
"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"
|
"github.com/golang/glog"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package tenanter
|
package tenanter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
"code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,7 @@ package tenanter
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
"code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -12,7 +12,7 @@ var (
|
||||||
ErrNoExistAliRegionId = errors.New("region id not exist in ali")
|
ErrNoExistAliRegionId = errors.New("region id not exist in ali")
|
||||||
ErrNoExistTencentRegionId = errors.New("region id not exist in tencent")
|
ErrNoExistTencentRegionId = errors.New("region id not exist in tencent")
|
||||||
ErrNoExistHuaweiRegionId = errors.New("region id not exist in huawei")
|
ErrNoExistHuaweiRegionId = errors.New("region id not exist in huawei")
|
||||||
ErrNoExistAwsRegionId = errors.New("region id not exist in aws")
|
ErrNoExistK8SRegionId = errors.New("region id not exist in k8s")
|
||||||
)
|
)
|
||||||
|
|
||||||
type Region interface {
|
type Region interface {
|
||||||
|
@ -122,7 +122,7 @@ func GetTencentRegionId(regionName string) (int32, error) {
|
||||||
regionName = "tc_" + strings.ReplaceAll(regionName, "-", "_")
|
regionName = "tc_" + strings.ReplaceAll(regionName, "-", "_")
|
||||||
id, ok := pbtenant.TencentRegionId_value[regionName]
|
id, ok := pbtenant.TencentRegionId_value[regionName]
|
||||||
if !ok || regionName == "" {
|
if !ok || regionName == "" {
|
||||||
return 0, errors.WithMessagef(ErrNoExistAliRegionId, "input region id is %s", regionName)
|
return 0, errors.WithMessagef(ErrNoExistTencentRegionId, "input region id is %s", regionName)
|
||||||
}
|
}
|
||||||
return id, nil
|
return id, nil
|
||||||
}
|
}
|
||||||
|
@ -140,18 +140,18 @@ func GetHuaweiRegionName(regionId int32) (string, error) {
|
||||||
// GetHuaweiRegionId prefix huawei
|
// GetHuaweiRegionId prefix huawei
|
||||||
func GetHuaweiRegionId(regionName string) (int32, error) {
|
func GetHuaweiRegionId(regionName string) (int32, error) {
|
||||||
regionName = "hw_" + strings.ReplaceAll(regionName, "-", "_")
|
regionName = "hw_" + strings.ReplaceAll(regionName, "-", "_")
|
||||||
id, ok := pbtenant.AliRegionId_value[regionName]
|
id, ok := pbtenant.HuaweiRegionId_value[regionName]
|
||||||
if !ok || regionName == "" {
|
if !ok || regionName == "" {
|
||||||
return 0, errors.WithMessagef(ErrNoExistAliRegionId, "input region id is %s", regionName)
|
return 0, errors.WithMessagef(ErrNoExistHuaweiRegionId, "input region id is %s", regionName)
|
||||||
}
|
}
|
||||||
return id, nil
|
return id, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetK8SRegionName prefix ali_
|
// GetK8SRegionName prefix ali_
|
||||||
func GetK8SRegionName(regionId int32) (string, error) {
|
func GetK8SRegionName(regionId int32) (string, error) {
|
||||||
name, ok := pbtenant.AliRegionId_name[regionId]
|
name, ok := pbtenant.K8SRegionId_name[regionId]
|
||||||
if !ok || regionId == int32(pbtenant.AliRegionId_ali_all) {
|
if !ok || regionId == int32(pbtenant.K8SRegionId_k8s_all) {
|
||||||
return "", errors.WithMessagef(ErrNoExistAliRegionId, "input region id is %d", regionId)
|
return "", errors.WithMessagef(ErrNoExistK8SRegionId, "input region id is %d", regionId)
|
||||||
}
|
}
|
||||||
region := strings.ReplaceAll(name, "_", "-")
|
region := strings.ReplaceAll(name, "_", "-")
|
||||||
return region[4:], nil
|
return region[4:], nil
|
||||||
|
@ -161,13 +161,3 @@ func GetK8SRegionName(regionId int32) (string, error) {
|
||||||
func GetK8SRegionId(regionName string) (int32, error) {
|
func GetK8SRegionId(regionName string) (int32, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAwsRegionName prefix aws_
|
|
||||||
func GetAwsRegionName(regionId int32) (string, error) {
|
|
||||||
name, ok := pbtenant.AwsRegionId_name[regionId]
|
|
||||||
if !ok || regionId == int32(pbtenant.AwsRegionId_aws_all) {
|
|
||||||
return "", errors.WithMessagef(ErrNoExistAwsRegionId, "input region id is %d", regionId)
|
|
||||||
}
|
|
||||||
region := strings.ReplaceAll(name, "_", "-")
|
|
||||||
return region[4:], nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package tenanter
|
||||||
import (
|
import (
|
||||||
"testing"
|
"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) {
|
func TestGetAllRegionIds(t *testing.T) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package tenanter
|
package tenanter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"code.gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
|
@ -0,0 +1,186 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
//
|
||||||
|
//import (
|
||||||
|
// "context"
|
||||||
|
// "fmt"
|
||||||
|
// "github.com/pkg/errors"
|
||||||
|
// corev1 "k8s.io/api/core/v1"
|
||||||
|
// "k8s.io/apimachinery/pkg/api/resource"
|
||||||
|
// metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
// "k8s.io/client-go/kubernetes"
|
||||||
|
// huaweicci "k8s.io/client-go/kubernetes"
|
||||||
|
// "k8s.io/client-go/tools/clientcmd"
|
||||||
|
// "k8s.io/client-go/tools/clientcmd/api"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//const (
|
||||||
|
// apiVersion = "client.authentication.k8s.io/v1beta1"
|
||||||
|
// // 云容器实例 CCI,参考https://developer.huaweicloud.com/endpoint
|
||||||
|
// cciEndpoint = "https://cci.cn-east-3.myhuaweicloud.com"
|
||||||
|
// // 统一身份认证服务 IAM,参考https://developer.huaweicloud.com/endpoint
|
||||||
|
// iamEndpoint = "https://iam.cn-east-3.myhuaweicloud.com"
|
||||||
|
// // 地区和终端节点,参考https://developer.huaweicloud.com/endpoint
|
||||||
|
// projectName = "cn-east-3"
|
||||||
|
// // 获取AK/SK参考: https://support.huaweicloud.com/devg-cci/cci_kubectl_01.html#cci_kubectl_01__section17023744719
|
||||||
|
// ak = "ATQTIWUT9K66VRMMXKVY"
|
||||||
|
// sk = "Wa0aixDVuhZOfDZGWvgIJQBHnyiDlGdgDn1Ai5Yy"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//// NewClient 通过AK/SK认证创建Clientset
|
||||||
|
//func NewClient() (*kubernetes.Clientset, error) {
|
||||||
|
// config, err := clientcmd.BuildConfigFromFlags(cciEndpoint, "")
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// var optionArgs []string
|
||||||
|
// optionArgs = append(optionArgs, fmt.Sprintf("--iam-endpoint=%s", iamEndpoint))
|
||||||
|
// optionArgs = append(optionArgs, fmt.Sprintf("--project-name=%s", projectName))
|
||||||
|
// optionArgs = append(optionArgs, fmt.Sprintf("--token-only=false"))
|
||||||
|
// optionArgs = append(optionArgs, fmt.Sprintf("--ak=%s", ak))
|
||||||
|
// optionArgs = append(optionArgs, fmt.Sprintf("--sk=%s", sk))
|
||||||
|
// config.ExecProvider = &api.ExecConfig{
|
||||||
|
// Command: "cci-iam-authenticator",
|
||||||
|
// APIVersion: apiVersion,
|
||||||
|
// Args: append([]string{"token"}, optionArgs...),
|
||||||
|
// Env: make([]api.ExecEnvVar, 0),
|
||||||
|
// }
|
||||||
|
// return kubernetes.NewForConfig(config)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func CreatePod(client *kubernetes.Clientset) (*corev1.Pod, error) {
|
||||||
|
// cli, _ := NewClient()
|
||||||
|
//
|
||||||
|
// pod := corev1.Pod{
|
||||||
|
// TypeMeta: metav1.TypeMeta{
|
||||||
|
// APIVersion: "core/V1",
|
||||||
|
// Kind: "Pod",
|
||||||
|
// },
|
||||||
|
// ObjectMeta: metav1.ObjectMeta{
|
||||||
|
// Name: "hw-sdk-test",
|
||||||
|
// Namespace: "pcm",
|
||||||
|
// Labels: map[string]string{"name": "test_api"},
|
||||||
|
// },
|
||||||
|
// Spec: corev1.PodSpec{
|
||||||
|
// RestartPolicy: corev1.RestartPolicyAlways,
|
||||||
|
// Containers: []corev1.Container{
|
||||||
|
// {
|
||||||
|
// Name: "pcm-sdk-huawei-container",
|
||||||
|
// Image: "library/nginx:stable-alpine-perl",
|
||||||
|
// Resources: corev1.ResourceRequirements{
|
||||||
|
// Limits: map[corev1.ResourceName]resource.Quantity{
|
||||||
|
// corev1.ResourceCPU: resource.MustParse("500m"),
|
||||||
|
// corev1.ResourceMemory: resource.MustParse("1Gi"),
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// Status: corev1.PodStatus{},
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// resp, err := cli.CoreV1().Pods("pcm").Create(context.TODO(), &pod, metav1.CreateOptions{})
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, errors.Wrap(err, "Huaweiyun CreatePod error")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return &corev1.Pod{
|
||||||
|
// TypeMeta: resp.TypeMeta,
|
||||||
|
// ObjectMeta: resp.ObjectMeta,
|
||||||
|
// Spec: resp.Spec,
|
||||||
|
// Status: resp.Status,
|
||||||
|
// }, nil
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//// UpdatePod 删除Pod
|
||||||
|
//func UpdatePod(client *kubernetes.Clientset) error {
|
||||||
|
// pod := corev1.Pod{
|
||||||
|
// TypeMeta: metav1.TypeMeta{
|
||||||
|
// APIVersion: "core/V1",
|
||||||
|
// Kind: "Pod",
|
||||||
|
// },
|
||||||
|
// ObjectMeta: metav1.ObjectMeta{
|
||||||
|
// Name: "hw-sdk-test",
|
||||||
|
// Namespace: "pcm",
|
||||||
|
// Labels: map[string]string{"name": "test_api222"},
|
||||||
|
// },
|
||||||
|
// Spec: corev1.PodSpec{
|
||||||
|
// RestartPolicy: corev1.RestartPolicyAlways,
|
||||||
|
// Containers: []corev1.Container{
|
||||||
|
// {
|
||||||
|
// Name: "pcm-sdk-huawei-container2",
|
||||||
|
// Image: "library/nginx:stable-alpine-perl",
|
||||||
|
// Resources: corev1.ResourceRequirements{
|
||||||
|
// Limits: map[corev1.ResourceName]resource.Quantity{
|
||||||
|
// corev1.ResourceCPU: resource.MustParse("500m"),
|
||||||
|
// corev1.ResourceMemory: resource.MustParse("1Gi"),
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// Status: corev1.PodStatus{},
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.CoreV1().Pods("pcm").Update(context.TODO(), &pod, metav1.UpdateOptions{})
|
||||||
|
// return nil
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//// DeletePod 删除Pod
|
||||||
|
//func DeletePod(client *kubernetes.Clientset) error {
|
||||||
|
// return client.CoreV1().Pods("pcm").Delete(context.TODO(), "podName", metav1.DeleteOptions{})
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//// ListPod 查询Pod
|
||||||
|
//func ListPod(client *kubernetes.Clientset) (*corev1.PodList, error) {
|
||||||
|
//
|
||||||
|
// podList, _ := client.CoreV1().Pods("pcm").List(context.TODO(), metav1.ListOptions{})
|
||||||
|
// println(podList.Items[0].Name)
|
||||||
|
// return podList, nil
|
||||||
|
//}
|
||||||
|
//func main() {
|
||||||
|
// // 有多种认证方式,具体请参考
|
||||||
|
// //《使用cci-iam-authenticator进行认证并创建client》,https://support.huaweicloud.com/sdkreference-cci/cci_09_0004.html
|
||||||
|
// cciConfig, err := clientcmd.BuildConfigFromFlags(cciEndpoint, "")
|
||||||
|
// var optionArgs []string
|
||||||
|
// optionArgs = append(optionArgs, fmt.Sprintf("--iam-endpoint=%s", iamEndpoint))
|
||||||
|
// optionArgs = append(optionArgs, fmt.Sprintf("--project-name=%s", projectName))
|
||||||
|
// optionArgs = append(optionArgs, fmt.Sprintf("--ak=%s", ak))
|
||||||
|
// optionArgs = append(optionArgs, fmt.Sprintf("--sk=%s", sk))
|
||||||
|
// cciConfig.ExecProvider = &api.ExecConfig{
|
||||||
|
// Command: "cci-iam-authenticator",
|
||||||
|
// APIVersion: apiVersion,
|
||||||
|
// Args: append([]string{"token"}, optionArgs...),
|
||||||
|
// Env: make([]api.ExecEnvVar, 0),
|
||||||
|
// }
|
||||||
|
// cs, err := huaweicci.NewForConfig(cciConfig)
|
||||||
|
//
|
||||||
|
// //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 delete Pod")
|
||||||
|
// //err = DeletePod(cs)
|
||||||
|
// //if err != nil {
|
||||||
|
// // panic(err)
|
||||||
|
// //}
|
||||||
|
// //fmt.Println("Pod deleted")
|
||||||
|
//
|
||||||
|
//}
|
|
@ -1 +0,0 @@
|
||||||
package examples
|
|
|
@ -1,8 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
pcm_pod_ali "code.gitlink.org.cn/JCCE/PCM/adaptor/pod/server/ali"
|
||||||
"github.com/alibabacloud-go/tea/tea"
|
"github.com/alibabacloud-go/tea/tea"
|
||||||
pcm_pod_ali "gitlink.org.cn/JCCE/PCM/adaptor/pod/server/ali"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -30,9 +30,9 @@ func _main(args []*string) (_err error) {
|
||||||
|
|
||||||
createContainerGroupsRequest := pcm_pod_ali.CreateContainerGroupRequest{
|
createContainerGroupsRequest := pcm_pod_ali.CreateContainerGroupRequest{
|
||||||
RpcRequest: nil,
|
RpcRequest: nil,
|
||||||
//ali:cn-hangzhou tc:ap-shanghai hw: k8s
|
//ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3
|
||||||
RegionId: "cn-hangzhou",
|
RegionId: "cn-east-3",
|
||||||
ProviderId: 3,
|
ProviderId: 2,
|
||||||
Namespace: "pcm",
|
Namespace: "pcm",
|
||||||
ContainerGroupName: "sdk-alitohuawei",
|
ContainerGroupName: "sdk-alitohuawei",
|
||||||
Container: &containers,
|
Container: &containers,
|
|
@ -0,0 +1,197 @@
|
||||||
|
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"
|
||||||
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
"k8s.io/client-go/tools/clientcmd/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
apiVersion = "client.authentication.k8s.io/v1beta1"
|
||||||
|
// 云容器实例 CCI,参考https://developer.huaweicloud.com/endpoint
|
||||||
|
cciEndpoint = "https://cci.cn-east-3.myhuaweicloud.com"
|
||||||
|
// 统一身份认证服务 IAM,参考https://developer.huaweicloud.com/endpoint
|
||||||
|
iamEndpoint = "https://iam.cn-east-3.myhuaweicloud.com"
|
||||||
|
// 地区和终端节点,参考https://developer.huaweicloud.com/endpoint
|
||||||
|
projectName = "cn-east-3"
|
||||||
|
// 获取AK/SK参考: https://support.huaweicloud.com/devg-cci/cci_kubectl_01.html#cci_kubectl_01__section17023744719
|
||||||
|
ak = "ATQTIWUT9K66VRMMXKVY"
|
||||||
|
sk = "Wa0aixDVuhZOfDZGWvgIJQBHnyiDlGdgDn1Ai5Yy"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewClient 通过AK/SK认证创建Clientset
|
||||||
|
func NewClient() (*kubernetes.Clientset, error) {
|
||||||
|
config, err := clientcmd.BuildConfigFromFlags(cciEndpoint, "")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var optionArgs []string
|
||||||
|
optionArgs = append(optionArgs, fmt.Sprintf("--iam-endpoint=%s", iamEndpoint))
|
||||||
|
optionArgs = append(optionArgs, fmt.Sprintf("--project-name=%s", projectName))
|
||||||
|
optionArgs = append(optionArgs, fmt.Sprintf("--token-only=false"))
|
||||||
|
optionArgs = append(optionArgs, fmt.Sprintf("--ak=%s", ak))
|
||||||
|
optionArgs = append(optionArgs, fmt.Sprintf("--sk=%s", sk))
|
||||||
|
config.ExecProvider = &api.ExecConfig{
|
||||||
|
Command: "cci-iam-authenticator",
|
||||||
|
APIVersion: apiVersion,
|
||||||
|
Args: append([]string{"token"}, optionArgs...),
|
||||||
|
Env: make([]api.ExecEnvVar, 0),
|
||||||
|
}
|
||||||
|
return kubernetes.NewForConfig(config)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePod(client *kubernetes.Clientset) (*corev1.Pod, error) {
|
||||||
|
cli, _ := NewClient()
|
||||||
|
|
||||||
|
pod := corev1.Pod{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
APIVersion: "core/V1",
|
||||||
|
Kind: "Pod",
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "hw-sdk-hwk8s01",
|
||||||
|
Namespace: "pcm",
|
||||||
|
Labels: map[string]string{"name": "test_api"},
|
||||||
|
},
|
||||||
|
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: "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"),
|
||||||
|
corev1.ResourceMemory: resource.MustParse("2Gi"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Status: corev1.PodStatus{},
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := cli.CoreV1().Pods("pcm").Create(context.TODO(), &pod, metav1.CreateOptions{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "Huaweiyun CreatePod error")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &corev1.Pod{
|
||||||
|
TypeMeta: resp.TypeMeta,
|
||||||
|
ObjectMeta: resp.ObjectMeta,
|
||||||
|
Spec: resp.Spec,
|
||||||
|
Status: resp.Status,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePod 更新Pod
|
||||||
|
func UpdatePod(client *kubernetes.Clientset) error {
|
||||||
|
pod := corev1.Pod{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
APIVersion: "core/V1",
|
||||||
|
Kind: "Pod",
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
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-contai",
|
||||||
|
Image: "nginx:latest",
|
||||||
|
Resources: corev1.ResourceRequirements{
|
||||||
|
Limits: map[corev1.ResourceName]resource.Quantity{
|
||||||
|
corev1.ResourceCPU: resource.MustParse("2000m"),
|
||||||
|
corev1.ResourceMemory: resource.MustParse("1Gi"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Status: corev1.PodStatus{},
|
||||||
|
}
|
||||||
|
|
||||||
|
client.CoreV1().Pods("pcm").Update(context.TODO(), &pod, metav1.UpdateOptions{})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePod 删除Pod
|
||||||
|
func DeletePod(client *kubernetes.Clientset) error {
|
||||||
|
return client.CoreV1().Pods("pcm").Delete(context.TODO(), "podName", metav1.DeleteOptions{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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(), &pod, metav1.ListOptions{})
|
||||||
|
return podList, nil
|
||||||
|
}
|
||||||
|
func main() {
|
||||||
|
// 有多种认证方式,具体请参考
|
||||||
|
//《使用cci-iam-authenticator进行认证并创建client》,https://support.huaweicloud.com/sdkreference-cci/cci_09_0004.html
|
||||||
|
cciConfig, err := clientcmd.BuildConfigFromFlags(cciEndpoint, "")
|
||||||
|
var optionArgs []string
|
||||||
|
optionArgs = append(optionArgs, fmt.Sprintf("--iam-endpoint=%s", iamEndpoint))
|
||||||
|
optionArgs = append(optionArgs, fmt.Sprintf("--project-name=%s", projectName))
|
||||||
|
optionArgs = append(optionArgs, fmt.Sprintf("--ak=%s", ak))
|
||||||
|
optionArgs = append(optionArgs, fmt.Sprintf("--sk=%s", sk))
|
||||||
|
cciConfig.ExecProvider = &api.ExecConfig{
|
||||||
|
Command: "cci-iam-authenticator",
|
||||||
|
APIVersion: apiVersion,
|
||||||
|
Args: append([]string{"token"}, optionArgs...),
|
||||||
|
Env: make([]api.ExecEnvVar, 0),
|
||||||
|
}
|
||||||
|
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 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 delete Pod")
|
||||||
|
//err = DeletePod(cs)
|
||||||
|
//if err != nil {
|
||||||
|
// panic(err)
|
||||||
|
//}
|
||||||
|
//fmt.Println("Pod deleted")
|
||||||
|
|
||||||
|
}
|
3
go.mod
3
go.mod
|
@ -1,11 +1,10 @@
|
||||||
module gitlink.org.cn/JCCE/PCM
|
module code.gitlink.org.cn/JCCE/PCM
|
||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/alibabacloud-go/darabonba-openapi v0.1.4
|
github.com/alibabacloud-go/darabonba-openapi v0.1.4
|
||||||
github.com/alibabacloud-go/darabonba-string v1.0.0
|
github.com/alibabacloud-go/darabonba-string v1.0.0
|
||||||
github.com/alibabacloud-go/eci-20180808/v2 v2.0.2
|
|
||||||
github.com/alibabacloud-go/ecs-20140526/v2 v2.1.0
|
github.com/alibabacloud-go/ecs-20140526/v2 v2.1.0
|
||||||
github.com/alibabacloud-go/tea v1.1.15
|
github.com/alibabacloud-go/tea v1.1.15
|
||||||
github.com/alibabacloud-go/tea-utils v1.3.9
|
github.com/alibabacloud-go/tea-utils v1.3.9
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
package demo;
|
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 "google/api/annotations.proto";
|
||||||
import "protoc-gen-openapiv2/options/annotations.proto";
|
import "protoc-gen-openapiv2/options/annotations.proto";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
package pbecs;
|
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 "idl/pbtenant/tenant.proto";
|
||||||
import "google/api/annotations.proto";
|
import "google/api/annotations.proto";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
package pbpod;
|
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 "idl/pbtenant/tenant.proto";
|
||||||
import "google/api/annotations.proto";
|
import "google/api/annotations.proto";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
package pbtenant;
|
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 "google/api/annotations.proto";
|
||||||
import "protoc-gen-openapiv2/options/annotations.proto";
|
import "protoc-gen-openapiv2/options/annotations.proto";
|
||||||
|
@ -173,7 +173,7 @@ service TenantService {
|
||||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = {
|
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = {
|
||||||
description : "所有云租户的认证服务"
|
description : "所有云租户的认证服务"
|
||||||
external_docs : {
|
external_docs : {
|
||||||
url : "https://gitlink.org.cn/JCCE/PCM"
|
url : "https://code.gitlink.org.cn/JCCE/PCM"
|
||||||
description: "Find out more about PCM"
|
description: "Find out more about PCM"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
package pbecs
|
package pbecs
|
||||||
|
|
||||||
import (
|
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"
|
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
package pbpod
|
package pbpod
|
||||||
|
|
||||||
import (
|
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"
|
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
|
10
main.go
10
main.go
|
@ -1,13 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
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"
|
"context"
|
||||||
"flag"
|
"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"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue