api: fix types in protobuf
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>docker-18.09
parent
12a84368df
commit
177aac4018
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,13 @@
|
||||||
syntax = "proto3";
|
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 {
|
service Control {
|
||||||
rpc DiskUsage(DiskUsageRequest) returns (DiskUsageResponse);
|
rpc DiskUsage(DiskUsageRequest) returns (DiskUsageResponse);
|
||||||
|
@ -42,25 +49,26 @@ message StatusResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
message Vertex {
|
message Vertex {
|
||||||
string ID = 1;
|
string digest = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
|
||||||
repeated string inputs = 2;
|
repeated string inputs = 2 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
|
||||||
string name = 3;
|
string name = 3;
|
||||||
bool cached = 4;
|
bool cached = 4;
|
||||||
int64 started = 5; // relative, add abolute google.protobuf.Timestamp as well?
|
google.protobuf.Timestamp started = 5 [(gogoproto.stdtime) = true ];
|
||||||
int64 completed = 6;
|
google.protobuf.Timestamp completed = 6 [(gogoproto.stdtime) = true ];
|
||||||
}
|
}
|
||||||
|
|
||||||
message VertexStatus {
|
message VertexStatus {
|
||||||
string ID = 1;
|
string ID = 1;
|
||||||
string vertex = 2;
|
string vertex = 2 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
|
||||||
string name = 3;
|
string name = 3;
|
||||||
int64 current = 4;
|
int64 current = 4;
|
||||||
int64 total = 5;
|
int64 total = 5;
|
||||||
|
google.protobuf.Timestamp timestamp = 6 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||||
}
|
}
|
||||||
|
|
||||||
message VertexLog {
|
message VertexLog {
|
||||||
int64 inc = 1;
|
string vertex = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
|
||||||
int64 timestamp = 2;
|
google.protobuf.Timestamp timestamp = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||||
int64 stream = 3;
|
int64 stream = 3;
|
||||||
bytes msg = 4;
|
bytes msg = 4;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Vertex struct {
|
type Vertex struct {
|
||||||
ID digest.Digest
|
Digest digest.Digest
|
||||||
Inputs []digest.Digest
|
Inputs []digest.Digest
|
||||||
Name string
|
Name string
|
||||||
Started *time.Time
|
Started *time.Time
|
||||||
|
@ -17,7 +17,7 @@ type Vertex struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type VertexStatus struct {
|
type VertexStatus struct {
|
||||||
ID digest.Digest
|
ID string
|
||||||
Vertex digest.Digest
|
Vertex digest.Digest
|
||||||
Name string
|
Name string
|
||||||
Total int
|
Total int
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package control
|
package control
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/containerd/containerd/snapshot"
|
"github.com/containerd/containerd/snapshot"
|
||||||
digest "github.com/opencontainers/go-digest"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
controlapi "github.com/tonistiigi/buildkit_poc/api/services/control"
|
controlapi "github.com/tonistiigi/buildkit_poc/api/services/control"
|
||||||
"github.com/tonistiigi/buildkit_poc/cache"
|
"github.com/tonistiigi/buildkit_poc/cache"
|
||||||
|
@ -95,11 +92,11 @@ func (c *Controller) Status(req *controlapi.StatusRequest, stream controlapi.Con
|
||||||
sr := controlapi.StatusResponse{}
|
sr := controlapi.StatusResponse{}
|
||||||
for _, v := range ss.Vertexes {
|
for _, v := range ss.Vertexes {
|
||||||
sr.Vertexes = append(sr.Vertexes, &controlapi.Vertex{
|
sr.Vertexes = append(sr.Vertexes, &controlapi.Vertex{
|
||||||
ID: v.ID.String(),
|
Digest: v.Digest,
|
||||||
Inputs: digestToString(v.Inputs),
|
Inputs: v.Inputs,
|
||||||
Name: v.Name,
|
Name: v.Name,
|
||||||
Started: marshalTimeStamp(v.Started),
|
Started: v.Started,
|
||||||
Completed: marshalTimeStamp(v.Completed),
|
Completed: v.Completed,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err := stream.SendMsg(&sr); err != nil {
|
if err := stream.SendMsg(&sr); err != nil {
|
||||||
|
@ -111,17 +108,3 @@ func (c *Controller) Status(req *controlapi.StatusRequest, stream controlapi.Con
|
||||||
|
|
||||||
return eg.Wait()
|
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()
|
|
||||||
}
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ func loadReqursive(dgst digest.Digest, op *pb.Op, inputs map[digest.Digest]*pb.O
|
||||||
vtx.vtx = client.Vertex{
|
vtx.vtx = client.Vertex{
|
||||||
Inputs: inputDigests,
|
Inputs: inputDigests,
|
||||||
Name: vtx.name(),
|
Name: vtx.name(),
|
||||||
ID: dgst,
|
Digest: dgst,
|
||||||
}
|
}
|
||||||
cache[dgst] = vtx
|
cache[dgst] = vtx
|
||||||
return vtx, nil
|
return vtx, nil
|
||||||
|
|
Loading…
Reference in New Issue