47e0e79550d806371eaa45a6c35a63af53f62369
Build protos / Build Protobufs (pull_request) Successful in 5m42s
Fog Model
This module contains the Protocol Buffer schemas and generated Go types used to represent Fog deployment data and control messages.
Schemas
deployment.protodefinesDeploymentAction(STOPorSTART),GlobalEnvironment,ConfigFile, andDeployment.c2o/operation.protodefines requestMessagevalues andRequestType(PINGorDEPLOYMENT).
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.
Languages
Go
74.4%
Makefile
25.6%