Files
model/README.md
T
beejay 47e0e79550
Build protos / Build Protobufs (pull_request) Successful in 5m42s
add README documentation for Fog Model and Protocol Buffer schemas
2026-11-11 16:21:55 +09:00

1.6 KiB

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:

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:

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.