api: begin to define the containerkit api
This commit cuts out the structure for defining grpc services for this project. To provide compatibility with go package generation and support reuse, we use a single protobuf file per package and make the import paths relative to the GOPATH. This first pass attempts to position the Mount type as the lingua franca of ContainerKit. The Images service will provide paths prepared for use as a set of mounts of the container service. We'll need to merge the container service in place with new file defined here. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
40003e7085
commit
32a25d5523
10 changed files with 690 additions and 0 deletions
3
api/image/gen.go
Normal file
3
api/image/gen.go
Normal file
|
@ -0,0 +1,3 @@
|
|||
package image
|
||||
|
||||
//go:generate protoc -I .:../../..:$GOPATH/src --gogo_out=plugins=grpc,import_path=github.com/docker/containerkit/api/image:. image.proto
|
295
api/image/image.pb.go
Normal file
295
api/image/image.pb.go
Normal file
|
@ -0,0 +1,295 @@
|
|||
// Code generated by protoc-gen-gogo.
|
||||
// source: image.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package image is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
image.proto
|
||||
|
||||
It has these top-level messages:
|
||||
PrepareRequest
|
||||
PrepareResponse
|
||||
CleanupRequest
|
||||
CleanupResponse
|
||||
CommitRequest
|
||||
CommitResponse
|
||||
*/
|
||||
package image
|
||||
|
||||
import proto "github.com/gogo/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import _ "github.com/gogo/protobuf/gogoproto"
|
||||
import docker_containerkit_types "github.com/docker/containerkit/api/types/mount"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
const _ = proto.GoGoProtoPackageIsVersion1
|
||||
|
||||
type PrepareRequest struct {
|
||||
// Path specifies the filesystem path to target for the image preparation.
|
||||
//
|
||||
// These will influence the values of "target" in the emitted mounts. It
|
||||
// must be unique per usage of the prepared mount and can only be prepared
|
||||
// again after a call to cleanup.
|
||||
Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"`
|
||||
// name of the image to prepare.
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
}
|
||||
|
||||
func (m *PrepareRequest) Reset() { *m = PrepareRequest{} }
|
||||
func (m *PrepareRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*PrepareRequest) ProtoMessage() {}
|
||||
func (*PrepareRequest) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{0} }
|
||||
|
||||
type PrepareResponse struct {
|
||||
// Layers provides a list of mounts to use with container creation. The
|
||||
// layers will be mounted, in order, assembling the root filesystem.
|
||||
//
|
||||
// Typically, these can be augmented with other mounts from the volume
|
||||
// service, tmpfs, application-specific bind mounts or even mounts from
|
||||
// other containers.
|
||||
Layers []*docker_containerkit_types.Mount `protobuf:"bytes,1,rep,name=layers" json:"layers,omitempty"`
|
||||
}
|
||||
|
||||
func (m *PrepareResponse) Reset() { *m = PrepareResponse{} }
|
||||
func (m *PrepareResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*PrepareResponse) ProtoMessage() {}
|
||||
func (*PrepareResponse) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{1} }
|
||||
|
||||
func (m *PrepareResponse) GetLayers() []*docker_containerkit_types.Mount {
|
||||
if m != nil {
|
||||
return m.Layers
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type CleanupRequest struct {
|
||||
// Path cleans up the path used for the image.
|
||||
// ID identifies the prepared image to cleanup.
|
||||
Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
|
||||
}
|
||||
|
||||
func (m *CleanupRequest) Reset() { *m = CleanupRequest{} }
|
||||
func (m *CleanupRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*CleanupRequest) ProtoMessage() {}
|
||||
func (*CleanupRequest) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{2} }
|
||||
|
||||
type CleanupResponse struct {
|
||||
}
|
||||
|
||||
func (m *CleanupResponse) Reset() { *m = CleanupResponse{} }
|
||||
func (m *CleanupResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*CleanupResponse) ProtoMessage() {}
|
||||
func (*CleanupResponse) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{3} }
|
||||
|
||||
// CommitRequest provides argument for the Commit RPC.
|
||||
type CommitRequest struct {
|
||||
// Path to a prepared image to capture changes.
|
||||
Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
|
||||
}
|
||||
|
||||
func (m *CommitRequest) Reset() { *m = CommitRequest{} }
|
||||
func (m *CommitRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*CommitRequest) ProtoMessage() {}
|
||||
func (*CommitRequest) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{4} }
|
||||
|
||||
type CommitResponse struct {
|
||||
// name identifies the entity created as part of the image.
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
}
|
||||
|
||||
func (m *CommitResponse) Reset() { *m = CommitResponse{} }
|
||||
func (m *CommitResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*CommitResponse) ProtoMessage() {}
|
||||
func (*CommitResponse) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{5} }
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*PrepareRequest)(nil), "docker.containerkit.types.PrepareRequest")
|
||||
proto.RegisterType((*PrepareResponse)(nil), "docker.containerkit.types.PrepareResponse")
|
||||
proto.RegisterType((*CleanupRequest)(nil), "docker.containerkit.types.CleanupRequest")
|
||||
proto.RegisterType((*CleanupResponse)(nil), "docker.containerkit.types.CleanupResponse")
|
||||
proto.RegisterType((*CommitRequest)(nil), "docker.containerkit.types.CommitRequest")
|
||||
proto.RegisterType((*CommitResponse)(nil), "docker.containerkit.types.CommitResponse")
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion2
|
||||
|
||||
// Client API for Images service
|
||||
|
||||
type ImagesClient interface {
|
||||
// Prepare declares that an image is required for use. A prepared image,
|
||||
// complete with a set of mounts to use for the image will be provided.
|
||||
Prepare(ctx context.Context, in *PrepareRequest, opts ...grpc.CallOption) (*PrepareResponse, error)
|
||||
// Cleanup instructs the images service to cleanup resources for the image.
|
||||
Cleanup(ctx context.Context, in *CleanupRequest, opts ...grpc.CallOption) (*CleanupResponse, error)
|
||||
// Commit
|
||||
Commit(ctx context.Context, in *CommitRequest, opts ...grpc.CallOption) (*CommitResponse, error)
|
||||
}
|
||||
|
||||
type imagesClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewImagesClient(cc *grpc.ClientConn) ImagesClient {
|
||||
return &imagesClient{cc}
|
||||
}
|
||||
|
||||
func (c *imagesClient) Prepare(ctx context.Context, in *PrepareRequest, opts ...grpc.CallOption) (*PrepareResponse, error) {
|
||||
out := new(PrepareResponse)
|
||||
err := grpc.Invoke(ctx, "/docker.containerkit.types.Images/Prepare", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *imagesClient) Cleanup(ctx context.Context, in *CleanupRequest, opts ...grpc.CallOption) (*CleanupResponse, error) {
|
||||
out := new(CleanupResponse)
|
||||
err := grpc.Invoke(ctx, "/docker.containerkit.types.Images/Cleanup", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *imagesClient) Commit(ctx context.Context, in *CommitRequest, opts ...grpc.CallOption) (*CommitResponse, error) {
|
||||
out := new(CommitResponse)
|
||||
err := grpc.Invoke(ctx, "/docker.containerkit.types.Images/Commit", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Images service
|
||||
|
||||
type ImagesServer interface {
|
||||
// Prepare declares that an image is required for use. A prepared image,
|
||||
// complete with a set of mounts to use for the image will be provided.
|
||||
Prepare(context.Context, *PrepareRequest) (*PrepareResponse, error)
|
||||
// Cleanup instructs the images service to cleanup resources for the image.
|
||||
Cleanup(context.Context, *CleanupRequest) (*CleanupResponse, error)
|
||||
// Commit
|
||||
Commit(context.Context, *CommitRequest) (*CommitResponse, error)
|
||||
}
|
||||
|
||||
func RegisterImagesServer(s *grpc.Server, srv ImagesServer) {
|
||||
s.RegisterService(&_Images_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Images_Prepare_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PrepareRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ImagesServer).Prepare(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/docker.containerkit.types.Images/Prepare",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ImagesServer).Prepare(ctx, req.(*PrepareRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Images_Cleanup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CleanupRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ImagesServer).Cleanup(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/docker.containerkit.types.Images/Cleanup",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ImagesServer).Cleanup(ctx, req.(*CleanupRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Images_Commit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CommitRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ImagesServer).Commit(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/docker.containerkit.types.Images/Commit",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ImagesServer).Commit(ctx, req.(*CommitRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Images_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "docker.containerkit.types.Images",
|
||||
HandlerType: (*ImagesServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Prepare",
|
||||
Handler: _Images_Prepare_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Cleanup",
|
||||
Handler: _Images_Cleanup_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Commit",
|
||||
Handler: _Images_Commit_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
}
|
||||
|
||||
var fileDescriptorImage = []byte{
|
||||
// 314 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x52, 0x4f, 0x6b, 0x3a, 0x31,
|
||||
0x14, 0x64, 0xf5, 0xc7, 0x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0x2c, 0xfe, 0xcc, 0x58, 0xbc, 0xd6, 0x26, 0xe6, 0x11, 0x9f, 0xdf, 0x41, 0x6f,
|
||||
0xb6, 0x45, 0x26, 0x2b, 0x7d, 0x6e, 0x23, 0x39, 0xd8, 0xc8, 0xaf, 0xa1, 0xbf, 0x47, 0x85, 0x95,
|
||||
0xf9, 0x2d, 0x5c, 0xcd, 0x94, 0x10, 0xdc, 0x35, 0xf1, 0x6a, 0xf5, 0x08, 0x8a, 0x4e, 0x7f, 0x03,
|
||||
0x25, 0x87, 0x40, 0x93, 0xef, 0x16, 0xa4, 0xcf, 0xf5, 0x0f, 0xb2, 0x64, 0x01, 0x9d, 0x98, 0x8d,
|
||||
0x8c, 0x1b, 0x32, 0x9c, 0x36, 0x97, 0xdd, 0x5f, 0x02, 0x8d, 0x06, 0x16, 0xd0, 0x89, 0x51, 0x1a,
|
||||
0x37, 0x9c, 0x96, 0xd2, 0xb8, 0xe1, 0xac, 0x19, 0xf2, 0x0e, 0x69, 0x08, 0x4d, 0x46, 0x4d, 0xac,
|
||||
0xe3, 0xf2, 0xb2, 0xf1, 0x05, 0xc8, 0x20, 0xbf, 0x4c, 0xfd, 0xfb, 0x79, 0xfc, 0x09, 0x00, 0x00,
|
||||
0xff, 0xff, 0x28, 0x48, 0xab, 0xcd, 0xd4, 0x02, 0x00, 0x00,
|
||||
}
|
83
api/image/image.proto
Normal file
83
api/image/image.proto
Normal file
|
@ -0,0 +1,83 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package docker.containerkit.types;
|
||||
|
||||
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
|
||||
import "github.com/docker/containerkit/api/types/mount/mount.proto";
|
||||
|
||||
// Images abstracts the graph driver and image store.
|
||||
//
|
||||
// The interface is to be able to request and manage images. The output,
|
||||
// provided as part of the Prepare step, is to expose a set of mounts that can
|
||||
// be used at container startup to run the image.
|
||||
service Images {
|
||||
// Prepare declares that an image is required for use. A prepared image,
|
||||
// complete with a set of mounts to use for the image will be provided.
|
||||
rpc Prepare(PrepareRequest) returns (PrepareResponse);
|
||||
|
||||
// Cleanup instructs the images service to cleanup resources for the image.
|
||||
rpc Cleanup(CleanupRequest) returns (CleanupResponse);
|
||||
|
||||
// Commit
|
||||
rpc Commit(CommitRequest) returns (CommitResponse);
|
||||
|
||||
// NOTE(stevvooe): Placeholders for other operations here. Consider
|
||||
// splitting this into a graphdriver like service (Prepare/Cleanup) and an
|
||||
// image store service.
|
||||
//
|
||||
// Really, we want to separate image identification from CAS
|
||||
// identification, so placing push/pull here may cause too much coupling.
|
||||
// It might better to be able to import the layers here in the same way the
|
||||
// graphdriver works, then only use the image metadata to maintain the link
|
||||
// here.
|
||||
//
|
||||
// Basically, we want to avoid the tight coupling present between the image
|
||||
// store and graphdriver in docker today.
|
||||
//
|
||||
// rpc Push(PushRequest) returns (stream PullRequest);
|
||||
// rpc Pull(PullRequest) returns (stream PullResponse);
|
||||
}
|
||||
|
||||
message PrepareRequest {
|
||||
// Path specifies the filesystem path to target for the image preparation.
|
||||
//
|
||||
// These will influence the values of "target" in the emitted mounts. It
|
||||
// must be unique per usage of the prepared mount and can only be prepared
|
||||
// again after a call to cleanup.
|
||||
string path = 3;
|
||||
|
||||
// name of the image to prepare.
|
||||
string name = 2;
|
||||
}
|
||||
|
||||
message PrepareResponse {
|
||||
// Layers provides a list of mounts to use with container creation. The
|
||||
// layers will be mounted, in order, assembling the root filesystem.
|
||||
//
|
||||
// Typically, these can be augmented with other mounts from the volume
|
||||
// service, tmpfs, application-specific bind mounts or even mounts from
|
||||
// other containers.
|
||||
repeated types.Mount layers = 1;
|
||||
|
||||
// TODO(stevvooe): It is unclear whether or not we should integrate image
|
||||
// metadata with this part of the service.
|
||||
}
|
||||
|
||||
message CleanupRequest {
|
||||
// Path cleans up the path used for the image.
|
||||
// ID identifies the prepared image to cleanup.
|
||||
string path = 1;
|
||||
}
|
||||
|
||||
message CleanupResponse { }
|
||||
|
||||
// CommitRequest provides argument for the Commit RPC.
|
||||
message CommitRequest {
|
||||
// Path to a prepared image to capture changes.
|
||||
string path = 1;
|
||||
}
|
||||
|
||||
message CommitResponse {
|
||||
// name identifies the entity created as part of the image.
|
||||
string name = 1;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue