diff --git a/.gitignore b/.gitignore index a680f60..fa319fa 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,3 @@ log/ /adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenative/ /adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenativeclient/ /adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/internal/server/ -/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/internal/svc/ diff --git a/adaptor/PCM-CORE/api/etc/pcmcore-api.yaml b/adaptor/PCM-CORE/api/etc/pcmcore-api.yaml index 176954b..fc19678 100644 --- a/adaptor/PCM-CORE/api/etc/pcmcore-api.yaml +++ b/adaptor/PCM-CORE/api/etc/pcmcore-api.yaml @@ -5,7 +5,7 @@ Port: 8999 #pay success notify order-mq for kq(kafka pub sub) KqProducerConf: Brokers: - - localhost:9092 + - 10.101.15.174:31895 HpcTopic: Schedule-Hpc-Topic CloudTopic: Schedule-Cloud-Topic AiTopic: Schedule-Ai-Topic @@ -14,16 +14,18 @@ DB: DataSource: root:uJpLd6u-J?HC1@(106.53.150.192:3306)/pcm Redis: - Host: localhost:6379 + Host: 10.101.15.170:30169 + Pass: redisPW123 Cache: - - Host: localhost:6379 + - Host: 10.101.15.170:30169 + Pass: redisPW123 # hpc kq HpcConsumerConf: Name: ScheduleHpc Brokers: - - localhost:9092 + - 10.101.15.174:31895 Group: Schedule-Hpc-group Topic: Schedule-Hpc-Topic Offset: first @@ -34,7 +36,7 @@ HpcConsumerConf: CloudConsumerConf: Name: ScheduleCloud Brokers: - - localhost:9092 + - 10.101.15.174:31895 Group: Schedule-Cloud-group Topic: Schedule-Cloud-Topic Offset: first @@ -43,24 +45,28 @@ CloudConsumerConf: # k8s rpc K8sNativeConf: - Endpoints: - - 127.0.0.1:2200 - NonBlock: true + Etcd: + Hosts: + - 10.101.15.170:31890 + Key: kubenative.rpc + User: root + Pass: I9wLvrRufj #rpc THRpcConf: - Endpoints: - - 127.0.0.1:2002 - NonBlock: true Etcd: Hosts: - - 127.0.0.1:2379 + - 10.101.15.170:31890 Key: hpcth.rpc + User: root + Pass: I9wLvrRufj #rpc ACRpcConf: Etcd: Hosts: - - 10.233.37.242:31890 + - 10.101.15.170:31890 Key: hpcac.rpc + User: root + Pass: I9wLvrRufj diff --git a/adaptor/PCM-CORE/api/internal/mqs/kq/ScheduleCloud.go b/adaptor/PCM-CORE/api/internal/mqs/kq/ScheduleCloud.go index 97ec26f..b2be0e1 100644 --- a/adaptor/PCM-CORE/api/internal/mqs/kq/ScheduleCloud.go +++ b/adaptor/PCM-CORE/api/internal/mqs/kq/ScheduleCloud.go @@ -27,16 +27,21 @@ func NewScheduleCloudMq(ctx context.Context, svcCtx *svc.ServiceContext) *Schedu func (l *ScheduleCloudMq) Consume(_, val string) error { var req *types.ScheduleTaskReq - json.Unmarshal([]byte(val), req) + json.Unmarshal([]byte(val), &req) var task model.Task task = model.Task{ Type: 1, + ServiceName: "kubeNative", Status: "pending", Description: req.Description, Name: req.Name, } // 保存作业信息到数据库并获取id - l.svcCtx.TaskModel.Insert(l.ctx, &task) + result, err := l.svcCtx.TaskModel.Insert(l.ctx, &task) + if err != nil { + return err + } + id, _ := result.LastInsertId() // 构建提交作业到云算的结构体 bytes, err := json.Marshal(req.Metadata) if err != nil { @@ -53,6 +58,7 @@ func (l *ScheduleCloudMq) Consume(_, val string) error { var clouds []model.Cloud for _, dataSet := range applyResp.DataSet { clouds = append(clouds, model.Cloud{ + TaskId: id, ApiVersion: dataSet.ApiVersion, Name: dataSet.Name, Kind: dataSet.Kind, diff --git a/adaptor/PCM-CORE/api/internal/svc/servicecontext.go b/adaptor/PCM-CORE/api/internal/svc/servicecontext.go index 9a8a326..d896d16 100644 --- a/adaptor/PCM-CORE/api/internal/svc/servicecontext.go +++ b/adaptor/PCM-CORE/api/internal/svc/servicecontext.go @@ -59,6 +59,6 @@ func NewServiceContext(c config.Config) *ServiceContext { ScheduleAiClient: kq.NewPusher(c.KqProducerConf.Brokers, c.KqProducerConf.AiTopic), KubeNativeRpc: kubenativeclient.NewKubeNative(zrpc.MustNewClient(c.K8sNativeConf)), ACRpc: hpcacclient.NewHpcAC(zrpc.MustNewClient(c.ACRpcConf)), - THRpc: hpcthclient.NewHpcTH(zrpc.MustNewClient(c.THRpcConf)), + //THRpc: hpcthclient.NewHpcTH(zrpc.MustNewClient(c.THRpcConf)), } } diff --git a/adaptor/PCM-HPC/PCM-TH/rpc/etc/hpc-th-template.yaml b/adaptor/PCM-HPC/PCM-TH/rpc/etc/hpc-th-template.yaml deleted file mode 100644 index e5017d2..0000000 --- a/adaptor/PCM-HPC/PCM-TH/rpc/etc/hpc-th-template.yaml +++ /dev/null @@ -1,6 +0,0 @@ -Name: hpcth.rpc -ListenOn: 0.0.0.0:8881 -Etcd: - Hosts: - - localhost:2379 - Key: hpcth.rpc \ No newline at end of file diff --git a/adaptor/PCM-HPC/PCM-TH/rpc/etc/hpcth.yaml b/adaptor/PCM-HPC/PCM-TH/rpc/etc/hpcth.yaml new file mode 100644 index 0000000..7a8385a --- /dev/null +++ b/adaptor/PCM-HPC/PCM-TH/rpc/etc/hpcth.yaml @@ -0,0 +1,8 @@ +Name: hpcth.rpc +ListenOn: 0.0.0.0:8881 +Etcd: + Hosts: + - 10.101.15.170:31890 + Key: hpcth.rpc + User: root + Pass: I9wLvrRufj \ No newline at end of file diff --git a/adaptor/PCM-HPC/PCM-TH/rpc/hpcth.go b/adaptor/PCM-HPC/PCM-TH/rpc/hpcth.go index 68528c2..60e9a63 100644 --- a/adaptor/PCM-HPC/PCM-TH/rpc/hpcth.go +++ b/adaptor/PCM-HPC/PCM-TH/rpc/hpcth.go @@ -16,7 +16,7 @@ import ( "google.golang.org/grpc/reflection" ) -var configFile = flag.String("f", "adaptor/PCM-HPC/PCM-TH/rpc/etc/hpc-th-template.yaml", "the config file") +var configFile = flag.String("f", "adaptor/PCM-HPC/PCM-TH/rpc/etc/hpcth.yaml", "the config file") func main() { flag.Parse() diff --git a/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/etc/kubenative.yaml b/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/etc/kubenative.yaml index ca88f08..d1583d8 100644 --- a/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/etc/kubenative.yaml +++ b/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/etc/kubenative.yaml @@ -1,9 +1,11 @@ Name: kubenative.rpc ListenOn: 0.0.0.0:2200 -#Etcd: -# Hosts: -# - 127.0.0.1:2379 -# Key: kubenative.rpc +Etcd: + Hosts: + - 10.101.15.170:31890 + Key: kubenative.rpc + User: root + Pass: I9wLvrRufj KubeConfig: Server: 10.101.15.3:6443 diff --git a/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/internal/server/kubenativeserver.go b/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/internal/server/kubenativeserver.go new file mode 100644 index 0000000..7f1fe3e --- /dev/null +++ b/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/internal/server/kubenativeserver.go @@ -0,0 +1,43 @@ +// Code generated by goctl. DO NOT EDIT. +// Source: kubenative.proto + +package server + +import ( + "context" + + "PCM/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/internal/logic" + "PCM/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/internal/svc" + "PCM/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenative" +) + +type KubeNativeServer struct { + svcCtx *svc.ServiceContext + kubenative.UnimplementedKubeNativeServer +} + +func NewKubeNativeServer(svcCtx *svc.ServiceContext) *KubeNativeServer { + return &KubeNativeServer{ + svcCtx: svcCtx, + } +} + +func (s *KubeNativeServer) ApplyYaml(ctx context.Context, in *kubenative.ApplyReq) (*kubenative.ApplyResp, error) { + l := logic.NewApplyYamlLogic(ctx, s.svcCtx) + return l.ApplyYaml(in) +} + +func (s *KubeNativeServer) DeleteYaml(ctx context.Context, in *kubenative.ApplyReq) (*kubenative.Resp, error) { + l := logic.NewDeleteYamlLogic(ctx, s.svcCtx) + return l.DeleteYaml(in) +} + +func (s *KubeNativeServer) Get(ctx context.Context, in *kubenative.GetReq) (*kubenative.Resp, error) { + l := logic.NewGetLogic(ctx, s.svcCtx) + return l.Get(in) +} + +func (s *KubeNativeServer) List(ctx context.Context, in *kubenative.ListReq) (*kubenative.Resp, error) { + l := logic.NewListLogic(ctx, s.svcCtx) + return l.List(in) +} diff --git a/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/internal/svc/servicecontext.go b/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/internal/svc/servicecontext.go new file mode 100644 index 0000000..9405bcc --- /dev/null +++ b/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/internal/svc/servicecontext.go @@ -0,0 +1,35 @@ +package svc + +import ( + "PCM/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/internal/config" + "k8s.io/client-go/dynamic" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" + "k8s.io/client-go/util/flowcontrol" +) + +type ServiceContext struct { + Config config.Config + DynamicClient dynamic.Interface + ClientSet *kubernetes.Clientset +} + +func NewServiceContext(c config.Config) *ServiceContext { + + restConfig := &rest.Config{ + Host: c.KubeConfig.Server, + RateLimiter: flowcontrol.NewTokenBucketRateLimiter(1000, 1000), + BearerToken: c.KubeConfig.Token, + TLSClientConfig: rest.TLSClientConfig{ + Insecure: true, + }, + } + dynamicClient, _ := dynamic.NewForConfig(restConfig) + clientSet, _ := kubernetes.NewForConfig(restConfig) + + return &ServiceContext{ + Config: c, + DynamicClient: dynamicClient, + ClientSet: clientSet, + } +} diff --git a/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenative/kubenative.pb.go b/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenative/kubenative.pb.go new file mode 100644 index 0000000..6ca6bad --- /dev/null +++ b/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenative/kubenative.pb.go @@ -0,0 +1,544 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.19.4 +// source: kubenative.proto + +package kubenative + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type GetReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + YamlString string `protobuf:"bytes,1,opt,name=yamlString,proto3" json:"yamlString,omitempty"` +} + +func (x *GetReq) Reset() { + *x = GetReq{} + if protoimpl.UnsafeEnabled { + mi := &file_kubenative_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetReq) ProtoMessage() {} + +func (x *GetReq) ProtoReflect() protoreflect.Message { + mi := &file_kubenative_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetReq.ProtoReflect.Descriptor instead. +func (*GetReq) Descriptor() ([]byte, []int) { + return file_kubenative_proto_rawDescGZIP(), []int{0} +} + +func (x *GetReq) GetYamlString() string { + if x != nil { + return x.YamlString + } + return "" +} + +type ListReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + YamlString string `protobuf:"bytes,1,opt,name=yamlString,proto3" json:"yamlString,omitempty"` +} + +func (x *ListReq) Reset() { + *x = ListReq{} + if protoimpl.UnsafeEnabled { + mi := &file_kubenative_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListReq) ProtoMessage() {} + +func (x *ListReq) ProtoReflect() protoreflect.Message { + mi := &file_kubenative_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListReq.ProtoReflect.Descriptor instead. +func (*ListReq) Descriptor() ([]byte, []int) { + return file_kubenative_proto_rawDescGZIP(), []int{1} +} + +func (x *ListReq) GetYamlString() string { + if x != nil { + return x.YamlString + } + return "" +} + +type ApplyReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + YamlString string `protobuf:"bytes,1,opt,name=yamlString,proto3" json:"yamlString,omitempty"` // @gotags: copier:"yamlString", json:"yaml_string" +} + +func (x *ApplyReq) Reset() { + *x = ApplyReq{} + if protoimpl.UnsafeEnabled { + mi := &file_kubenative_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ApplyReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApplyReq) ProtoMessage() {} + +func (x *ApplyReq) ProtoReflect() protoreflect.Message { + mi := &file_kubenative_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ApplyReq.ProtoReflect.Descriptor instead. +func (*ApplyReq) Descriptor() ([]byte, []int) { + return file_kubenative_proto_rawDescGZIP(), []int{2} +} + +func (x *ApplyReq) GetYamlString() string { + if x != nil { + return x.YamlString + } + return "" +} + +type Resp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` // @gotags: copier:"Code", json:"code" + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` // @gotags: copier:"Msg", json:"msg" + Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` // @gotags: copier:"Data", json:"data" +} + +func (x *Resp) Reset() { + *x = Resp{} + if protoimpl.UnsafeEnabled { + mi := &file_kubenative_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Resp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Resp) ProtoMessage() {} + +func (x *Resp) ProtoReflect() protoreflect.Message { + mi := &file_kubenative_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Resp.ProtoReflect.Descriptor instead. +func (*Resp) Descriptor() ([]byte, []int) { + return file_kubenative_proto_rawDescGZIP(), []int{3} +} + +func (x *Resp) GetCode() string { + if x != nil { + return x.Code + } + return "" +} + +func (x *Resp) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +func (x *Resp) GetData() string { + if x != nil { + return x.Data + } + return "" +} + +type ApplyResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` // @gotags: copier:"Code", json:"code" + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` // @gotags: copier:"Msg", json:"msg" + DataSet []*DataSet `protobuf:"bytes,3,rep,name=dataSet,proto3" json:"dataSet,omitempty"` // @gotags: copier:"Data", json:"dataSet" +} + +func (x *ApplyResp) Reset() { + *x = ApplyResp{} + if protoimpl.UnsafeEnabled { + mi := &file_kubenative_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ApplyResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApplyResp) ProtoMessage() {} + +func (x *ApplyResp) ProtoReflect() protoreflect.Message { + mi := &file_kubenative_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ApplyResp.ProtoReflect.Descriptor instead. +func (*ApplyResp) Descriptor() ([]byte, []int) { + return file_kubenative_proto_rawDescGZIP(), []int{4} +} + +func (x *ApplyResp) GetCode() string { + if x != nil { + return x.Code + } + return "" +} + +func (x *ApplyResp) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +func (x *ApplyResp) GetDataSet() []*DataSet { + if x != nil { + return x.DataSet + } + return nil +} + +type DataSet struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ApiVersion string `protobuf:"bytes,1,opt,name=apiVersion,proto3" json:"apiVersion,omitempty"` + Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"` + Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *DataSet) Reset() { + *x = DataSet{} + if protoimpl.UnsafeEnabled { + mi := &file_kubenative_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DataSet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DataSet) ProtoMessage() {} + +func (x *DataSet) ProtoReflect() protoreflect.Message { + mi := &file_kubenative_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DataSet.ProtoReflect.Descriptor instead. +func (*DataSet) Descriptor() ([]byte, []int) { + return file_kubenative_proto_rawDescGZIP(), []int{5} +} + +func (x *DataSet) GetApiVersion() string { + if x != nil { + return x.ApiVersion + } + return "" +} + +func (x *DataSet) GetKind() string { + if x != nil { + return x.Kind + } + return "" +} + +func (x *DataSet) GetNamespace() string { + if x != nil { + return x.Namespace + } + return "" +} + +func (x *DataSet) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +var File_kubenative_proto protoreflect.FileDescriptor + +var file_kubenative_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x6b, 0x75, 0x62, 0x65, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x0a, 0x6b, 0x75, 0x62, 0x65, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x22, 0x28, + 0x0a, 0x06, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x79, 0x61, 0x6d, 0x6c, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x79, 0x61, + 0x6d, 0x6c, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x29, 0x0a, 0x07, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x79, 0x61, 0x6d, 0x6c, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x79, 0x61, 0x6d, 0x6c, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x22, 0x2a, 0x0a, 0x08, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x12, + 0x1e, 0x0a, 0x0a, 0x79, 0x61, 0x6d, 0x6c, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x79, 0x61, 0x6d, 0x6c, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, + 0x40, 0x0a, 0x04, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, + 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x12, 0x0a, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x22, 0x60, 0x0a, 0x09, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, + 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, + 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6d, 0x73, 0x67, 0x12, 0x2d, 0x0a, 0x07, 0x64, 0x61, 0x74, 0x61, 0x53, 0x65, 0x74, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6b, 0x75, 0x62, 0x65, 0x6e, 0x61, 0x74, 0x69, + 0x76, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x53, 0x65, 0x74, 0x52, 0x07, 0x64, 0x61, 0x74, 0x61, + 0x53, 0x65, 0x74, 0x22, 0x6f, 0x0a, 0x07, 0x44, 0x61, 0x74, 0x61, 0x53, 0x65, 0x74, 0x12, 0x1e, + 0x0a, 0x0a, 0x61, 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, + 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, + 0x6e, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x32, 0xd8, 0x01, 0x0a, 0x0a, 0x6b, 0x75, 0x62, 0x65, 0x4e, 0x61, 0x74, + 0x69, 0x76, 0x65, 0x12, 0x38, 0x0a, 0x09, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x59, 0x61, 0x6d, 0x6c, + 0x12, 0x14, 0x2e, 0x6b, 0x75, 0x62, 0x65, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x41, 0x70, + 0x70, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x6b, 0x75, 0x62, 0x65, 0x6e, 0x61, 0x74, + 0x69, 0x76, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x34, 0x0a, + 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x14, 0x2e, 0x6b, 0x75, + 0x62, 0x65, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x52, 0x65, + 0x71, 0x1a, 0x10, 0x2e, 0x6b, 0x75, 0x62, 0x65, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x52, + 0x65, 0x73, 0x70, 0x12, 0x2b, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x12, 0x2e, 0x6b, 0x75, 0x62, + 0x65, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x10, + 0x2e, 0x6b, 0x75, 0x62, 0x65, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, + 0x12, 0x2d, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x13, 0x2e, 0x6b, 0x75, 0x62, 0x65, 0x6e, + 0x61, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, + 0x6b, 0x75, 0x62, 0x65, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x42, + 0x0d, 0x5a, 0x0b, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_kubenative_proto_rawDescOnce sync.Once + file_kubenative_proto_rawDescData = file_kubenative_proto_rawDesc +) + +func file_kubenative_proto_rawDescGZIP() []byte { + file_kubenative_proto_rawDescOnce.Do(func() { + file_kubenative_proto_rawDescData = protoimpl.X.CompressGZIP(file_kubenative_proto_rawDescData) + }) + return file_kubenative_proto_rawDescData +} + +var file_kubenative_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_kubenative_proto_goTypes = []interface{}{ + (*GetReq)(nil), // 0: kubenative.GetReq + (*ListReq)(nil), // 1: kubenative.ListReq + (*ApplyReq)(nil), // 2: kubenative.ApplyReq + (*Resp)(nil), // 3: kubenative.Resp + (*ApplyResp)(nil), // 4: kubenative.ApplyResp + (*DataSet)(nil), // 5: kubenative.DataSet +} +var file_kubenative_proto_depIdxs = []int32{ + 5, // 0: kubenative.ApplyResp.dataSet:type_name -> kubenative.DataSet + 2, // 1: kubenative.kubeNative.ApplyYaml:input_type -> kubenative.ApplyReq + 2, // 2: kubenative.kubeNative.DeleteYaml:input_type -> kubenative.ApplyReq + 0, // 3: kubenative.kubeNative.Get:input_type -> kubenative.GetReq + 1, // 4: kubenative.kubeNative.List:input_type -> kubenative.ListReq + 4, // 5: kubenative.kubeNative.ApplyYaml:output_type -> kubenative.ApplyResp + 3, // 6: kubenative.kubeNative.DeleteYaml:output_type -> kubenative.Resp + 3, // 7: kubenative.kubeNative.Get:output_type -> kubenative.Resp + 3, // 8: kubenative.kubeNative.List:output_type -> kubenative.Resp + 5, // [5:9] is the sub-list for method output_type + 1, // [1:5] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_kubenative_proto_init() } +func file_kubenative_proto_init() { + if File_kubenative_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_kubenative_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kubenative_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kubenative_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ApplyReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kubenative_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Resp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kubenative_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ApplyResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kubenative_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataSet); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_kubenative_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_kubenative_proto_goTypes, + DependencyIndexes: file_kubenative_proto_depIdxs, + MessageInfos: file_kubenative_proto_msgTypes, + }.Build() + File_kubenative_proto = out.File + file_kubenative_proto_rawDesc = nil + file_kubenative_proto_goTypes = nil + file_kubenative_proto_depIdxs = nil +} diff --git a/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenative/kubenative_grpc.pb.go b/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenative/kubenative_grpc.pb.go new file mode 100644 index 0000000..a118b81 --- /dev/null +++ b/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenative/kubenative_grpc.pb.go @@ -0,0 +1,213 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.19.4 +// source: kubenative.proto + +package kubenative + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// KubeNativeClient is the client API for KubeNative service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type KubeNativeClient interface { + ApplyYaml(ctx context.Context, in *ApplyReq, opts ...grpc.CallOption) (*ApplyResp, error) + DeleteYaml(ctx context.Context, in *ApplyReq, opts ...grpc.CallOption) (*Resp, error) + Get(ctx context.Context, in *GetReq, opts ...grpc.CallOption) (*Resp, error) + List(ctx context.Context, in *ListReq, opts ...grpc.CallOption) (*Resp, error) +} + +type kubeNativeClient struct { + cc grpc.ClientConnInterface +} + +func NewKubeNativeClient(cc grpc.ClientConnInterface) KubeNativeClient { + return &kubeNativeClient{cc} +} + +func (c *kubeNativeClient) ApplyYaml(ctx context.Context, in *ApplyReq, opts ...grpc.CallOption) (*ApplyResp, error) { + out := new(ApplyResp) + err := c.cc.Invoke(ctx, "/kubenative.kubeNative/ApplyYaml", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kubeNativeClient) DeleteYaml(ctx context.Context, in *ApplyReq, opts ...grpc.CallOption) (*Resp, error) { + out := new(Resp) + err := c.cc.Invoke(ctx, "/kubenative.kubeNative/DeleteYaml", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kubeNativeClient) Get(ctx context.Context, in *GetReq, opts ...grpc.CallOption) (*Resp, error) { + out := new(Resp) + err := c.cc.Invoke(ctx, "/kubenative.kubeNative/Get", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kubeNativeClient) List(ctx context.Context, in *ListReq, opts ...grpc.CallOption) (*Resp, error) { + out := new(Resp) + err := c.cc.Invoke(ctx, "/kubenative.kubeNative/List", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// KubeNativeServer is the server API for KubeNative service. +// All implementations must embed UnimplementedKubeNativeServer +// for forward compatibility +type KubeNativeServer interface { + ApplyYaml(context.Context, *ApplyReq) (*ApplyResp, error) + DeleteYaml(context.Context, *ApplyReq) (*Resp, error) + Get(context.Context, *GetReq) (*Resp, error) + List(context.Context, *ListReq) (*Resp, error) + mustEmbedUnimplementedKubeNativeServer() +} + +// UnimplementedKubeNativeServer must be embedded to have forward compatible implementations. +type UnimplementedKubeNativeServer struct { +} + +func (UnimplementedKubeNativeServer) ApplyYaml(context.Context, *ApplyReq) (*ApplyResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method ApplyYaml not implemented") +} +func (UnimplementedKubeNativeServer) DeleteYaml(context.Context, *ApplyReq) (*Resp, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteYaml not implemented") +} +func (UnimplementedKubeNativeServer) Get(context.Context, *GetReq) (*Resp, error) { + return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") +} +func (UnimplementedKubeNativeServer) List(context.Context, *ListReq) (*Resp, error) { + return nil, status.Errorf(codes.Unimplemented, "method List not implemented") +} +func (UnimplementedKubeNativeServer) mustEmbedUnimplementedKubeNativeServer() {} + +// UnsafeKubeNativeServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to KubeNativeServer will +// result in compilation errors. +type UnsafeKubeNativeServer interface { + mustEmbedUnimplementedKubeNativeServer() +} + +func RegisterKubeNativeServer(s grpc.ServiceRegistrar, srv KubeNativeServer) { + s.RegisterService(&KubeNative_ServiceDesc, srv) +} + +func _KubeNative_ApplyYaml_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ApplyReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KubeNativeServer).ApplyYaml(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kubenative.kubeNative/ApplyYaml", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KubeNativeServer).ApplyYaml(ctx, req.(*ApplyReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _KubeNative_DeleteYaml_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ApplyReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KubeNativeServer).DeleteYaml(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kubenative.kubeNative/DeleteYaml", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KubeNativeServer).DeleteYaml(ctx, req.(*ApplyReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _KubeNative_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KubeNativeServer).Get(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kubenative.kubeNative/Get", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KubeNativeServer).Get(ctx, req.(*GetReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _KubeNative_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KubeNativeServer).List(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kubenative.kubeNative/List", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KubeNativeServer).List(ctx, req.(*ListReq)) + } + return interceptor(ctx, in, info, handler) +} + +// KubeNative_ServiceDesc is the grpc.ServiceDesc for KubeNative service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var KubeNative_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "kubenative.kubeNative", + HandlerType: (*KubeNativeServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ApplyYaml", + Handler: _KubeNative_ApplyYaml_Handler, + }, + { + MethodName: "DeleteYaml", + Handler: _KubeNative_DeleteYaml_Handler, + }, + { + MethodName: "Get", + Handler: _KubeNative_Get_Handler, + }, + { + MethodName: "List", + Handler: _KubeNative_List_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "kubenative.proto", +} diff --git a/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenativeclient/kubenative.go b/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenativeclient/kubenative.go new file mode 100644 index 0000000..536f4dd --- /dev/null +++ b/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenativeclient/kubenative.go @@ -0,0 +1,59 @@ +// Code generated by goctl. DO NOT EDIT. +// Source: kubenative.proto + +package kubenativeclient + +import ( + "context" + + "PCM/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenative" + + "github.com/zeromicro/go-zero/zrpc" + "google.golang.org/grpc" +) + +type ( + ApplyReq = kubenative.ApplyReq + ApplyResp = kubenative.ApplyResp + DataSet = kubenative.DataSet + GetReq = kubenative.GetReq + ListReq = kubenative.ListReq + Resp = kubenative.Resp + + KubeNative interface { + ApplyYaml(ctx context.Context, in *ApplyReq, opts ...grpc.CallOption) (*ApplyResp, error) + DeleteYaml(ctx context.Context, in *ApplyReq, opts ...grpc.CallOption) (*Resp, error) + Get(ctx context.Context, in *GetReq, opts ...grpc.CallOption) (*Resp, error) + List(ctx context.Context, in *ListReq, opts ...grpc.CallOption) (*Resp, error) + } + + defaultKubeNative struct { + cli zrpc.Client + } +) + +func NewKubeNative(cli zrpc.Client) KubeNative { + return &defaultKubeNative{ + cli: cli, + } +} + +func (m *defaultKubeNative) ApplyYaml(ctx context.Context, in *ApplyReq, opts ...grpc.CallOption) (*ApplyResp, error) { + client := kubenative.NewKubeNativeClient(m.cli.Conn()) + return client.ApplyYaml(ctx, in, opts...) +} + +func (m *defaultKubeNative) DeleteYaml(ctx context.Context, in *ApplyReq, opts ...grpc.CallOption) (*Resp, error) { + client := kubenative.NewKubeNativeClient(m.cli.Conn()) + return client.DeleteYaml(ctx, in, opts...) +} + +func (m *defaultKubeNative) Get(ctx context.Context, in *GetReq, opts ...grpc.CallOption) (*Resp, error) { + client := kubenative.NewKubeNativeClient(m.cli.Conn()) + return client.Get(ctx, in, opts...) +} + +func (m *defaultKubeNative) List(ctx context.Context, in *ListReq, opts ...grpc.CallOption) (*Resp, error) { + client := kubenative.NewKubeNativeClient(m.cli.Conn()) + return client.List(ctx, in, opts...) +}