api: fix types in protobuf

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2017-06-13 17:40:15 -07:00
parent 12a84368df
commit 177aac4018
6 changed files with 289 additions and 839 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,13 @@
syntax = "proto3";
package control;
package moby.buildkit.v1;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
option (gogoproto.sizer_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true;
service Control {
rpc DiskUsage(DiskUsageRequest) returns (DiskUsageResponse);
@ -42,25 +49,26 @@ message StatusResponse {
}
message Vertex {
string ID = 1;
repeated string inputs = 2;
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 name = 3;
bool cached = 4;
int64 started = 5; // relative, add abolute google.protobuf.Timestamp as well?
int64 completed = 6;
google.protobuf.Timestamp started = 5 [(gogoproto.stdtime) = true ];
google.protobuf.Timestamp completed = 6 [(gogoproto.stdtime) = true ];
}
message VertexStatus {
string ID = 1;
string vertex = 2;
string vertex = 2 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
string name = 3;
int64 current = 4;
int64 total = 5;
google.protobuf.Timestamp timestamp = 6 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
}
message VertexLog {
int64 inc = 1;
int64 timestamp = 2;
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];
int64 stream = 3;
bytes msg = 4;
}

View File

@ -1,3 +1,3 @@
package control
package moby_buildkit_v1
//go:generate protoc --gogoslick_out=plugins=grpc:. control.proto
//go:generate protoc -I=. -I=../../../vendor/ --gogo_out=plugins=grpc:. control.proto

View File

@ -7,7 +7,7 @@ import (
)
type Vertex struct {
ID digest.Digest
Digest digest.Digest
Inputs []digest.Digest
Name string
Started *time.Time
@ -17,7 +17,7 @@ type Vertex struct {
}
type VertexStatus struct {
ID digest.Digest
ID string
Vertex digest.Digest
Name string
Total int

View File

@ -1,10 +1,7 @@
package control
import (
"time"
"github.com/containerd/containerd/snapshot"
digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors"
controlapi "github.com/tonistiigi/buildkit_poc/api/services/control"
"github.com/tonistiigi/buildkit_poc/cache"
@ -95,11 +92,11 @@ func (c *Controller) Status(req *controlapi.StatusRequest, stream controlapi.Con
sr := controlapi.StatusResponse{}
for _, v := range ss.Vertexes {
sr.Vertexes = append(sr.Vertexes, &controlapi.Vertex{
ID: v.ID.String(),
Inputs: digestToString(v.Inputs),
Digest: v.Digest,
Inputs: v.Inputs,
Name: v.Name,
Started: marshalTimeStamp(v.Started),
Completed: marshalTimeStamp(v.Completed),
Started: v.Started,
Completed: v.Completed,
})
}
if err := stream.SendMsg(&sr); err != nil {
@ -111,17 +108,3 @@ func (c *Controller) Status(req *controlapi.StatusRequest, stream controlapi.Con
return eg.Wait()
}
func digestToString(dgsts []digest.Digest) (out []string) { // TODO: make proto use digest
for _, dgst := range dgsts {
out = append(out, dgst.String())
}
return
}
func marshalTimeStamp(tm *time.Time) int64 {
if tm == nil {
return 0
}
return tm.UnixNano()
}

View File

@ -63,7 +63,7 @@ func loadReqursive(dgst digest.Digest, op *pb.Op, inputs map[digest.Digest]*pb.O
vtx.vtx = client.Vertex{
Inputs: inputDigests,
Name: vtx.name(),
ID: dgst,
Digest: dgst,
}
cache[dgst] = vtx
return vtx, nil