From 857f12b8608dae82ce11a15903cb7b9122e9b5f0 Mon Sep 17 00:00:00 2001 From: Alek Kim Date: Wed, 11 Nov 2026 16:17:07 +0900 Subject: [PATCH] add protobuf definitions and build configuration --- .github/workflows/build.yml | 41 +++++ .gitignore | 1 + Makefile | 12 ++ c2o/operation.pb.go | 186 ++++++++++++++++++++ c2o/operation.proto | 14 ++ deployment.pb.go | 342 ++++++++++++++++++++++++++++++++++++ deployment.proto | 28 +++ go.mod | 5 + go.sum | 4 + 9 files changed, 633 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 c2o/operation.pb.go create mode 100644 c2o/operation.proto create mode 100644 deployment.pb.go create mode 100644 deployment.proto create mode 100644 go.mod create mode 100644 go.sum diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..73754f7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: Build protos +on: + pull_request: + branches: + - main + types: + - opened + - synchronize + - reopened + - edited + push: + tags: + - 'v*.*.*' + +jobs: + build: + name: Build Protobufs + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v7 + with: + go-version: '1.27' + + - name: Install protoc + run: | + sudo apt-get update + sudo apt-get install -y protobuf-compiler + + - name: Install protoc-gen-go + run: | + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + + - name: Generate Protobufs + run: | + make proto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1b45940 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +SHELL := /bin/bash + +.DEFAULT_GOAL := help +.DELETE_ON_ERROR: +.SUFFIXES: +.PHONY: proto + +proto: ## Generate proto files + @echo "-> $@" + @protoc -I=. --go_out=paths=source_relative:. ./*.proto + @protoc -I=c2o --go_out=paths=source_relative:c2o c2o/*.proto + @echo "Done." diff --git a/c2o/operation.pb.go b/c2o/operation.pb.go new file mode 100644 index 0000000..69fe646 --- /dev/null +++ b/c2o/operation.pb.go @@ -0,0 +1,186 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.12 +// protoc v7.36.2 +// source: operation.proto + +package c2o + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 RequestType int32 + +const ( + RequestType_PING RequestType = 0 + RequestType_DEPLOYMENT RequestType = 1 +) + +// Enum value maps for RequestType. +var ( + RequestType_name = map[int32]string{ + 0: "PING", + 1: "DEPLOYMENT", + } + RequestType_value = map[string]int32{ + "PING": 0, + "DEPLOYMENT": 1, + } +) + +func (x RequestType) Enum() *RequestType { + p := new(RequestType) + *p = x + return p +} + +func (x RequestType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (RequestType) Descriptor() protoreflect.EnumDescriptor { + return file_operation_proto_enumTypes[0].Descriptor() +} + +func (RequestType) Type() protoreflect.EnumType { + return &file_operation_proto_enumTypes[0] +} + +func (x RequestType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use RequestType.Descriptor instead. +func (RequestType) EnumDescriptor() ([]byte, []int) { + return file_operation_proto_rawDescGZIP(), []int{0} +} + +type Message struct { + state protoimpl.MessageState `protogen:"open.v1"` + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + Type RequestType `protobuf:"varint,2,opt,name=type,proto3,enum=proto.RequestType" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Message) Reset() { + *x = Message{} + mi := &file_operation_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Message) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message) ProtoMessage() {} + +func (x *Message) ProtoReflect() protoreflect.Message { + mi := &file_operation_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Message.ProtoReflect.Descriptor instead. +func (*Message) Descriptor() ([]byte, []int) { + return file_operation_proto_rawDescGZIP(), []int{0} +} + +func (x *Message) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +func (x *Message) GetType() RequestType { + if x != nil { + return x.Type + } + return RequestType_PING +} + +var File_operation_proto protoreflect.FileDescriptor + +const file_operation_proto_rawDesc = "" + + "\n" + + "\x0foperation.proto\x12\x05proto\"P\n" + + "\aMessage\x12\x1d\n" + + "\n" + + "request_id\x18\x01 \x01(\tR\trequestId\x12&\n" + + "\x04type\x18\x02 \x01(\x0e2\x12.proto.RequestTypeR\x04type*'\n" + + "\vRequestType\x12\b\n" + + "\x04PING\x10\x00\x12\x0e\n" + + "\n" + + "DEPLOYMENT\x10\x01B\x1aZ\x18beejay.kim/fog/model/c2ob\x06proto3" + +var ( + file_operation_proto_rawDescOnce sync.Once + file_operation_proto_rawDescData []byte +) + +func file_operation_proto_rawDescGZIP() []byte { + file_operation_proto_rawDescOnce.Do(func() { + file_operation_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_operation_proto_rawDesc), len(file_operation_proto_rawDesc))) + }) + return file_operation_proto_rawDescData +} + +var file_operation_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_operation_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_operation_proto_goTypes = []any{ + (RequestType)(0), // 0: proto.RequestType + (*Message)(nil), // 1: proto.Message +} +var file_operation_proto_depIdxs = []int32{ + 0, // 0: proto.Message.type:type_name -> proto.RequestType + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] 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_operation_proto_init() } +func file_operation_proto_init() { + if File_operation_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_operation_proto_rawDesc), len(file_operation_proto_rawDesc)), + NumEnums: 1, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_operation_proto_goTypes, + DependencyIndexes: file_operation_proto_depIdxs, + EnumInfos: file_operation_proto_enumTypes, + MessageInfos: file_operation_proto_msgTypes, + }.Build() + File_operation_proto = out.File + file_operation_proto_goTypes = nil + file_operation_proto_depIdxs = nil +} diff --git a/c2o/operation.proto b/c2o/operation.proto new file mode 100644 index 0000000..9cf1410 --- /dev/null +++ b/c2o/operation.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package proto; + +option go_package = "beejay.kim/fog/model/c2o"; + +enum RequestType { + PING = 0; + DEPLOYMENT = 1; +} + +message Message { + string request_id = 1; + RequestType type = 2; +} diff --git a/deployment.pb.go b/deployment.pb.go new file mode 100644 index 0000000..614b60f --- /dev/null +++ b/deployment.pb.go @@ -0,0 +1,342 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.12 +// protoc v7.36.2 +// source: deployment.proto + +package model + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 DeploymentAction int32 + +const ( + DeploymentAction_STOP DeploymentAction = 0 + DeploymentAction_START DeploymentAction = 1 +) + +// Enum value maps for DeploymentAction. +var ( + DeploymentAction_name = map[int32]string{ + 0: "STOP", + 1: "START", + } + DeploymentAction_value = map[string]int32{ + "STOP": 0, + "START": 1, + } +) + +func (x DeploymentAction) Enum() *DeploymentAction { + p := new(DeploymentAction) + *p = x + return p +} + +func (x DeploymentAction) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DeploymentAction) Descriptor() protoreflect.EnumDescriptor { + return file_deployment_proto_enumTypes[0].Descriptor() +} + +func (DeploymentAction) Type() protoreflect.EnumType { + return &file_deployment_proto_enumTypes[0] +} + +func (x DeploymentAction) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use DeploymentAction.Descriptor instead. +func (DeploymentAction) EnumDescriptor() ([]byte, []int) { + return file_deployment_proto_rawDescGZIP(), []int{0} +} + +type GlobalEnvironment struct { + state protoimpl.MessageState `protogen:"open.v1"` + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + Variables map[string]string `protobuf:"bytes,2,rep,name=variables,proto3" json:"variables,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GlobalEnvironment) Reset() { + *x = GlobalEnvironment{} + mi := &file_deployment_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GlobalEnvironment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GlobalEnvironment) ProtoMessage() {} + +func (x *GlobalEnvironment) ProtoReflect() protoreflect.Message { + mi := &file_deployment_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GlobalEnvironment.ProtoReflect.Descriptor instead. +func (*GlobalEnvironment) Descriptor() ([]byte, []int) { + return file_deployment_proto_rawDescGZIP(), []int{0} +} + +func (x *GlobalEnvironment) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *GlobalEnvironment) GetVariables() map[string]string { + if x != nil { + return x.Variables + } + return nil +} + +type ConfigFile struct { + state protoimpl.MessageState `protogen:"open.v1"` + Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + Content []byte `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` + Mode uint32 `protobuf:"varint,3,opt,name=mode,proto3" json:"mode,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ConfigFile) Reset() { + *x = ConfigFile{} + mi := &file_deployment_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ConfigFile) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigFile) ProtoMessage() {} + +func (x *ConfigFile) ProtoReflect() protoreflect.Message { + mi := &file_deployment_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigFile.ProtoReflect.Descriptor instead. +func (*ConfigFile) Descriptor() ([]byte, []int) { + return file_deployment_proto_rawDescGZIP(), []int{1} +} + +func (x *ConfigFile) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *ConfigFile) GetContent() []byte { + if x != nil { + return x.Content + } + return nil +} + +func (x *ConfigFile) GetMode() uint32 { + if x != nil { + return x.Mode + } + return 0 +} + +type Deployment struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Env *GlobalEnvironment `protobuf:"bytes,2,opt,name=env,proto3" json:"env,omitempty"` + Action DeploymentAction `protobuf:"varint,3,opt,name=action,proto3,enum=proto.DeploymentAction" json:"action,omitempty"` + Hcl []byte `protobuf:"bytes,4,opt,name=hcl,proto3" json:"hcl,omitempty"` + ConfigFiles []*ConfigFile `protobuf:"bytes,10,rep,name=config_files,json=configFiles,proto3" json:"config_files,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Deployment) Reset() { + *x = Deployment{} + mi := &file_deployment_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Deployment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Deployment) ProtoMessage() {} + +func (x *Deployment) ProtoReflect() protoreflect.Message { + mi := &file_deployment_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Deployment.ProtoReflect.Descriptor instead. +func (*Deployment) Descriptor() ([]byte, []int) { + return file_deployment_proto_rawDescGZIP(), []int{2} +} + +func (x *Deployment) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Deployment) GetEnv() *GlobalEnvironment { + if x != nil { + return x.Env + } + return nil +} + +func (x *Deployment) GetAction() DeploymentAction { + if x != nil { + return x.Action + } + return DeploymentAction_STOP +} + +func (x *Deployment) GetHcl() []byte { + if x != nil { + return x.Hcl + } + return nil +} + +func (x *Deployment) GetConfigFiles() []*ConfigFile { + if x != nil { + return x.ConfigFiles + } + return nil +} + +var File_deployment_proto protoreflect.FileDescriptor + +const file_deployment_proto_rawDesc = "" + + "\n" + + "\x10deployment.proto\x12\x05proto\"\xb2\x01\n" + + "\x11GlobalEnvironment\x12\x18\n" + + "\aversion\x18\x01 \x01(\tR\aversion\x12E\n" + + "\tvariables\x18\x02 \x03(\v2'.proto.GlobalEnvironment.VariablesEntryR\tvariables\x1a<\n" + + "\x0eVariablesEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"N\n" + + "\n" + + "ConfigFile\x12\x12\n" + + "\x04path\x18\x01 \x01(\tR\x04path\x12\x18\n" + + "\acontent\x18\x02 \x01(\fR\acontent\x12\x12\n" + + "\x04mode\x18\x03 \x01(\rR\x04mode\"\xc1\x01\n" + + "\n" + + "Deployment\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12*\n" + + "\x03env\x18\x02 \x01(\v2\x18.proto.GlobalEnvironmentR\x03env\x12/\n" + + "\x06action\x18\x03 \x01(\x0e2\x17.proto.DeploymentActionR\x06action\x12\x10\n" + + "\x03hcl\x18\x04 \x01(\fR\x03hcl\x124\n" + + "\fconfig_files\x18\n" + + " \x03(\v2\x11.proto.ConfigFileR\vconfigFiles*'\n" + + "\x10DeploymentAction\x12\b\n" + + "\x04STOP\x10\x00\x12\t\n" + + "\x05START\x10\x01B\x16Z\x14beejay.kim/fog/modelb\x06proto3" + +var ( + file_deployment_proto_rawDescOnce sync.Once + file_deployment_proto_rawDescData []byte +) + +func file_deployment_proto_rawDescGZIP() []byte { + file_deployment_proto_rawDescOnce.Do(func() { + file_deployment_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_deployment_proto_rawDesc), len(file_deployment_proto_rawDesc))) + }) + return file_deployment_proto_rawDescData +} + +var file_deployment_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_deployment_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_deployment_proto_goTypes = []any{ + (DeploymentAction)(0), // 0: proto.DeploymentAction + (*GlobalEnvironment)(nil), // 1: proto.GlobalEnvironment + (*ConfigFile)(nil), // 2: proto.ConfigFile + (*Deployment)(nil), // 3: proto.Deployment + nil, // 4: proto.GlobalEnvironment.VariablesEntry +} +var file_deployment_proto_depIdxs = []int32{ + 4, // 0: proto.GlobalEnvironment.variables:type_name -> proto.GlobalEnvironment.VariablesEntry + 1, // 1: proto.Deployment.env:type_name -> proto.GlobalEnvironment + 0, // 2: proto.Deployment.action:type_name -> proto.DeploymentAction + 2, // 3: proto.Deployment.config_files:type_name -> proto.ConfigFile + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_deployment_proto_init() } +func file_deployment_proto_init() { + if File_deployment_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_deployment_proto_rawDesc), len(file_deployment_proto_rawDesc)), + NumEnums: 1, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_deployment_proto_goTypes, + DependencyIndexes: file_deployment_proto_depIdxs, + EnumInfos: file_deployment_proto_enumTypes, + MessageInfos: file_deployment_proto_msgTypes, + }.Build() + File_deployment_proto = out.File + file_deployment_proto_goTypes = nil + file_deployment_proto_depIdxs = nil +} diff --git a/deployment.proto b/deployment.proto new file mode 100644 index 0000000..5a478c3 --- /dev/null +++ b/deployment.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; +package proto; + +option go_package = "beejay.kim/fog/model"; + +enum DeploymentAction { + STOP = 0; + START = 1; +} + +message GlobalEnvironment { + string version = 1; + map variables = 2; +} + +message ConfigFile { + string path = 1; + bytes content = 2; + uint32 mode = 3; +} + +message Deployment { + string id = 1; + GlobalEnvironment env = 2; + DeploymentAction action = 3; + bytes hcl = 4; + repeated ConfigFile config_files = 10; +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..45241d5 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module beejay.kim/fog/model + +go 1.27 + +require google.golang.org/protobuf v1.36.12 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..a0c9758 --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= +google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=