From 47e0e79550d806371eaa45a6c35a63af53f62369 Mon Sep 17 00:00:00 2001 From: Alek Kim Date: Wed, 11 Nov 2026 16:21:55 +0900 Subject: [PATCH] add README documentation for Fog Model and Protocol Buffer schemas --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ace2975 --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +# Fog Model + +This module contains the Protocol Buffer schemas and generated Go types used to +represent Fog deployment data and control messages. + +## Schemas + +- `deployment.proto` defines `DeploymentAction` (`STOP` or `START`), + `GlobalEnvironment`, `ConfigFile`, and `Deployment`. +- `c2o/operation.proto` defines request `Message` values and `RequestType` + (`PING` or `DEPLOYMENT`). + +The generated Go packages are `beejay.kim/fog/model` and +`beejay.kim/fog/model/c2o`, respectively. The generated `.pb.go` files are +checked in; edit the `.proto` files rather than editing generated code. + +## Using the Go types + +Import the generated package and use the standard Protocol Buffers Go API: + +```go +package main + +import ( + "fmt" + + model "beejay.kim/fog/model" + "google.golang.org/protobuf/proto" +) + +func main() { + deployment := &model.Deployment{ + Id: "example", + Action: model.DeploymentAction_START, + Env: &model.GlobalEnvironment{ + Version: "1", + Variables: map[string]string{"REGION": "west"}, + }, + } + + data, err := proto.Marshal(deployment) + if err != nil { + panic(err) + } + + var decoded model.Deployment + if err := proto.Unmarshal(data, &decoded); err != nil { + panic(err) + } + fmt.Println(decoded.GetId()) +} +``` + +The module requires Go 1.27 and `google.golang.org/protobuf`. + +## Regenerating Go code + +Install `protoc` and the Go generator, and ensure both executables are on +`PATH`: + +```sh +go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.12 +make proto +``` + +`make proto` regenerates the Go files from both schemas. Commit the updated +`.pb.go` files together with any schema changes. \ No newline at end of file