Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protobuf: remove gogoproto #5342

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12,922 changes: 2,289 additions & 10,633 deletions api/services/control/control.pb.go

Large diffs are not rendered by default.

49 changes: 23 additions & 26 deletions api/services/control/control.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ syntax = "proto3";

package moby.buildkit.v1;

option go_package = "github.com/moby/buildkit/api/services/control;moby_buildkit_v1";

// import "github.com/containerd/containerd/api/types/descriptor.proto";
import "github.com/gogo/googleapis/google/rpc/status.proto";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "github.com/moby/buildkit/api/types/worker.proto";
import "github.com/moby/buildkit/solver/pb/ops.proto";
import "github.com/moby/buildkit/sourcepolicy/pb/policy.proto";
import "google/protobuf/timestamp.proto";

option (gogoproto.sizer_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true;
import "google/rpc/status.proto";

service Control {
rpc DiskUsage(DiskUsageRequest) returns (DiskUsageResponse);
Expand All @@ -30,8 +27,8 @@ service Control {
message PruneRequest {
repeated string filter = 1;
bool all = 2;
int64 keepDuration = 3 [(gogoproto.nullable) = true];
int64 keepBytes = 4 [(gogoproto.nullable) = true];
int64 keepDuration = 3;
int64 keepBytes = 4;
}

message DiskUsageRequest {
Expand All @@ -48,8 +45,8 @@ message UsageRecord {
bool InUse = 3;
int64 Size = 4;
string Parent = 5 [deprecated=true];
google.protobuf.Timestamp CreatedAt = 6 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
google.protobuf.Timestamp LastUsedAt = 7 [(gogoproto.stdtime) = true];
google.protobuf.Timestamp CreatedAt = 6;
google.protobuf.Timestamp LastUsedAt = 7;
int64 UsageCount = 8;
string Description = 9;
string RecordType = 10;
Expand All @@ -68,8 +65,8 @@ message SolveRequest {
string Session = 5;
string Frontend = 6;
map<string, string> FrontendAttrs = 7;
CacheOptions Cache = 8 [(gogoproto.nullable) = false];
repeated string Entitlements = 9 [(gogoproto.customtype) = "github.com/moby/buildkit/util/entitlements.Entitlement" ];
CacheOptions Cache = 8;
repeated string Entitlements = 9;
map<string, pb.Definition> FrontendInputs = 10;
bool Internal = 11; // Internal builds are not recorded in build history
moby.buildkit.v1.sourcepolicy.Policy SourcePolicy = 12;
Expand Down Expand Up @@ -120,36 +117,36 @@ message StatusResponse {
}

message Vertex {
string digest = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
repeated string inputs = 2 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
string digest = 1;
repeated string inputs = 2;
string name = 3;
bool cached = 4;
google.protobuf.Timestamp started = 5 [(gogoproto.stdtime) = true ];
google.protobuf.Timestamp completed = 6 [(gogoproto.stdtime) = true ];
google.protobuf.Timestamp started = 5;
google.protobuf.Timestamp completed = 6;
string error = 7; // typed errors?
pb.ProgressGroup progressGroup = 8;
}

message VertexStatus {
string ID = 1;
string vertex = 2 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
string vertex = 2;
string name = 3;
int64 current = 4;
int64 total = 5;
google.protobuf.Timestamp timestamp = 6 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
google.protobuf.Timestamp started = 7 [(gogoproto.stdtime) = true ];
google.protobuf.Timestamp completed = 8 [(gogoproto.stdtime) = true ];
google.protobuf.Timestamp timestamp = 6;
google.protobuf.Timestamp started = 7;
google.protobuf.Timestamp completed = 8;
}

message VertexLog {
string vertex = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
google.protobuf.Timestamp timestamp = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
string vertex = 1;
google.protobuf.Timestamp timestamp = 2;
int64 stream = 3;
bytes msg = 4;
}

message VertexWarning {
string vertex = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
string vertex = 1;
int64 level = 2;
bytes short = 3;
repeated bytes detail = 4;
Expand Down Expand Up @@ -199,8 +196,8 @@ message BuildHistoryRecord {
map<string, string> FrontendAttrs = 3;
repeated Exporter Exporters = 4;
google.rpc.Status error = 5;
google.protobuf.Timestamp CreatedAt = 6 [(gogoproto.stdtime) = true];
google.protobuf.Timestamp CompletedAt = 7 [(gogoproto.stdtime) = true];
google.protobuf.Timestamp CreatedAt = 6;
google.protobuf.Timestamp CompletedAt = 7;
Descriptor logs = 8;
map<string, string> ExporterResponse = 9;
BuildResultInfo Result = 10;
Expand Down Expand Up @@ -228,7 +225,7 @@ message UpdateBuildHistoryResponse {}

message Descriptor {
string media_type = 1;
string digest = 2 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
string digest = 2;
int64 size = 3;
map<string, string> annotations = 5;
}
Expand Down
120 changes: 120 additions & 0 deletions api/services/control/control_bench_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package moby_buildkit_v1 //nolint:revive

import (
"testing"
"time"

digest "github.com/opencontainers/go-digest"
"github.com/stretchr/testify/require"
proto "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
)

// Buf is used to prevent the benchmark from being optimized away.
var Buf []byte

func BenchmarkMarshalVertex(b *testing.B) {
v := sampleVertex()
for i := 0; i < b.N; i++ {
var err error
Buf, err = v.MarshalVT()
require.NoError(b, err)
}
}

func BenchmarkMarshalVertexStatus(b *testing.B) {
v := sampleVertexStatus()
for i := 0; i < b.N; i++ {
var err error
Buf, err = v.MarshalVT()
require.NoError(b, err)
}
}

func BenchmarkMarshalVertexLog(b *testing.B) {
v := sampleVertexLog()
for i := 0; i < b.N; i++ {
var err error
Buf, err = v.MarshalVT()
require.NoError(b, err)
}
}

var VertexOutput Vertex

func BenchmarkUnmarshalVertex(b *testing.B) {
v := sampleVertex()
buf, err := proto.Marshal(v)
require.NoError(b, err)

for i := 0; i < b.N; i++ {
err := VertexOutput.UnmarshalVT(buf)
require.NoError(b, err)
}
}

var VertexStatusOutput VertexStatus

func BenchmarkUnmarshalVertexStatus(b *testing.B) {
v := sampleVertexStatus()
buf, err := proto.Marshal(v)
require.NoError(b, err)

for i := 0; i < b.N; i++ {
err := VertexStatusOutput.UnmarshalVT(buf)
require.NoError(b, err)
}
}

var VertexLogOutput VertexLog

func BenchmarkUnmarshalVertexLog(b *testing.B) {
v := sampleVertexLog()
buf, err := proto.Marshal(v)
require.NoError(b, err)

for i := 0; i < b.N; i++ {
err := VertexLogOutput.UnmarshalVT(buf)
require.NoError(b, err)
}
}

func sampleVertex() *Vertex {
now := time.Now()
started := now.Add(-time.Minute)
return &Vertex{
Digest: string(digest.FromString("abc")),
Inputs: []string{
string(digest.FromString("dep1")),
string(digest.FromString("dep2")),
},
Name: "abc",
Started: timestamppb.New(started),
Completed: timestamppb.New(now),
}
}

func sampleVertexStatus() *VertexStatus {
now := time.Now()
started := now.Add(-time.Minute)
return &VertexStatus{
ID: "abc",
Vertex: string(digest.FromString("abc")),
Name: "abc",
Current: 1024,
Total: 1024,
Timestamp: timestamppb.New(now),
Started: timestamppb.New(started),
Completed: timestamppb.New(now),
}
}

func sampleVertexLog() *VertexLog {
now := time.Now()
return &VertexLog{
Vertex: string(digest.FromString("abc")),
Timestamp: timestamppb.New(now),
Stream: 1,
Msg: []byte("this is a log message"),
}
}
Loading
Loading