From 25580b4694573993e48d586c553d38eeeeb179cf Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Sat, 14 Dec 2024 22:18:22 +0800 Subject: [PATCH] feat: prepare for dependency lang install/setup --- core/constants/dependency.go | 7 ++-- core/models/models/base.go | 2 +- core/models/models/dependency_config.go | 12 +++++++ core/models/models/dependency_setting.go | 12 ------- grpc/dependency_service.pb.go | 36 ++++++++------------ grpc/proto/services/dependency_service.proto | 1 + 6 files changed, 34 insertions(+), 36 deletions(-) create mode 100644 core/models/models/dependency_config.go delete mode 100644 core/models/models/dependency_setting.go diff --git a/core/constants/dependency.go b/core/constants/dependency.go index a4025c39f..ec40a8a4f 100644 --- a/core/constants/dependency.go +++ b/core/constants/dependency.go @@ -1,8 +1,11 @@ package constants const ( - DependencyTypePython = "python" - DependencyTypeNode = "node" + DependencyTypePython = "python" + DependencyTypeNode = "node" + DependencyTypeGo = "go" + DependencyTypeJava = "java" + DependencyTypeBrowser = "browser" ) const ( diff --git a/core/models/models/base.go b/core/models/models/base.go index c69ef38da..e6c223ab0 100644 --- a/core/models/models/base.go +++ b/core/models/models/base.go @@ -73,7 +73,7 @@ func GetModelInstances() []any { *new(DatabaseMetric), *new(Dependency), *new(DependencyLog), - *new(DependencySetting), + *new(DependencyConfig), *new(DependencyRepo), *new(Environment), *new(Git), diff --git a/core/models/models/dependency_config.go b/core/models/models/dependency_config.go new file mode 100644 index 000000000..a36000326 --- /dev/null +++ b/core/models/models/dependency_config.go @@ -0,0 +1,12 @@ +package models + +type DependencyConfig struct { + any `collection:"dependency_configs"` + BaseModel[DependencyConfig] `bson:",inline"` + Key string `json:"key" bson:"key"` + Name string `json:"name" bson:"name"` + Cmd string `json:"cmd" bson:"cmd"` + Proxy string `json:"proxy" bson:"proxy"` + SetupNodeIds []string `json:"setup_node_ids" bson:"setup_node_ids"` + SetupScriptPath string `json:"setup_script_path" bson:"setup_script_path"` +} diff --git a/core/models/models/dependency_setting.go b/core/models/models/dependency_setting.go deleted file mode 100644 index e0c57a9c4..000000000 --- a/core/models/models/dependency_setting.go +++ /dev/null @@ -1,12 +0,0 @@ -package models - -type DependencySetting struct { - any `collection:"dependency_settings"` - BaseModel[DependencySetting] `bson:",inline"` - Key string `json:"key" bson:"key"` - Name string `json:"name" bson:"name"` - Description string `json:"description" bson:"description"` - Enabled bool `json:"enabled" bson:"enabled"` - Cmd string `json:"cmd" bson:"cmd"` - Proxy string `json:"proxy" bson:"proxy"` -} diff --git a/grpc/dependency_service.pb.go b/grpc/dependency_service.pb.go index 37820374a..815767879 100644 --- a/grpc/dependency_service.pb.go +++ b/grpc/dependency_service.pb.go @@ -26,6 +26,7 @@ const ( DependencyServiceCode_SYNC DependencyServiceCode = 0 DependencyServiceCode_INSTALL DependencyServiceCode = 1 DependencyServiceCode_UNINSTALL DependencyServiceCode = 2 + DependencyServiceCode_SETUP DependencyServiceCode = 3 ) // Enum value maps for DependencyServiceCode. @@ -34,11 +35,13 @@ var ( 0: "SYNC", 1: "INSTALL", 2: "UNINSTALL", + 3: "SETUP", } DependencyServiceCode_value = map[string]int32{ "SYNC": 0, "INSTALL": 1, "UNINSTALL": 2, + "SETUP": 3, } ) @@ -310,9 +313,8 @@ type DependencyServiceUpdateLogsRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - NodeKey string `protobuf:"bytes,1,opt,name=node_key,json=nodeKey,proto3" json:"node_key,omitempty"` - DependencyId string `protobuf:"bytes,2,opt,name=dependency_id,json=dependencyId,proto3" json:"dependency_id,omitempty"` - Logs []string `protobuf:"bytes,3,rep,name=logs,proto3" json:"logs,omitempty"` + DependencyId string `protobuf:"bytes,1,opt,name=dependency_id,json=dependencyId,proto3" json:"dependency_id,omitempty"` + Logs []string `protobuf:"bytes,2,rep,name=logs,proto3" json:"logs,omitempty"` } func (x *DependencyServiceUpdateLogsRequest) Reset() { @@ -347,13 +349,6 @@ func (*DependencyServiceUpdateLogsRequest) Descriptor() ([]byte, []int) { return file_services_dependency_service_proto_rawDescGZIP(), []int{4} } -func (x *DependencyServiceUpdateLogsRequest) GetNodeKey() string { - if x != nil { - return x.NodeKey - } - return "" -} - func (x *DependencyServiceUpdateLogsRequest) GetDependencyId() string { if x != nil { return x.DependencyId @@ -402,18 +397,17 @@ var file_services_dependency_service_proto_rawDesc = []byte{ 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x52, 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x69, - 0x65, 0x73, 0x22, 0x78, 0x0a, 0x22, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, + 0x65, 0x73, 0x22, 0x5d, 0x0a, 0x22, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, - 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x6f, 0x64, 0x65, - 0x4b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, - 0x79, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x65, 0x70, 0x65, - 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x2a, 0x3d, 0x0a, 0x15, - 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x59, 0x4e, 0x43, 0x10, 0x00, 0x12, - 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, - 0x55, 0x4e, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x10, 0x02, 0x32, 0xfb, 0x01, 0x0a, 0x11, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x65, 0x70, 0x65, + 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x49, 0x64, 0x12, 0x12, 0x0a, + 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x6f, 0x67, + 0x73, 0x2a, 0x48, 0x0a, 0x15, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x59, + 0x4e, 0x43, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x10, + 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x4e, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x10, 0x02, + 0x12, 0x09, 0x0a, 0x05, 0x53, 0x45, 0x54, 0x55, 0x50, 0x10, 0x03, 0x32, 0xfb, 0x01, 0x0a, 0x11, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5c, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x25, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, diff --git a/grpc/proto/services/dependency_service.proto b/grpc/proto/services/dependency_service.proto index df5b11727..afa7f1589 100644 --- a/grpc/proto/services/dependency_service.proto +++ b/grpc/proto/services/dependency_service.proto @@ -18,6 +18,7 @@ enum DependencyServiceCode { SYNC = 0; INSTALL = 1; UNINSTALL = 2; + SETUP = 3; } message DependencyServiceConnectResponse {