diff --git a/api/services/diff/diff.pb.go b/api/services/diff/diff.pb.go new file mode 100644 index 000000000..1891bac5e --- /dev/null +++ b/api/services/diff/diff.pb.go @@ -0,0 +1,1111 @@ +// Code generated by protoc-gen-gogo. +// source: github.com/containerd/containerd/api/services/diff/diff.proto +// DO NOT EDIT! + +/* + Package diff is a generated protocol buffer package. + + It is generated from these files: + github.com/containerd/containerd/api/services/diff/diff.proto + + It has these top-level messages: + ApplyRequest + ApplyResponse + DiffRequest + DiffResponse +*/ +package diff + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" +import _ "github.com/gogo/protobuf/gogoproto" +import _ "github.com/golang/protobuf/ptypes/empty" +import _ "github.com/gogo/protobuf/types" +import containerd_v1_types "github.com/containerd/containerd/api/types/mount" +import containerd_v1_types1 "github.com/containerd/containerd/api/types/descriptor" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +import strings "strings" +import reflect "reflect" + +import io "io" + +// 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. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +type ApplyRequest struct { + // Diff is the descriptor of the diff to be extracted + Diff *containerd_v1_types1.Descriptor `protobuf:"bytes,1,opt,name=diff" json:"diff,omitempty"` + Mounts []*containerd_v1_types.Mount `protobuf:"bytes,2,rep,name=mounts" json:"mounts,omitempty"` +} + +func (m *ApplyRequest) Reset() { *m = ApplyRequest{} } +func (*ApplyRequest) ProtoMessage() {} +func (*ApplyRequest) Descriptor() ([]byte, []int) { return fileDescriptorDiff, []int{0} } + +type ApplyResponse struct { + // Applied is the descriptor for the object which was applied. + // If the input was a compressed blob then the result will be + // the descriptor for the uncompressed blob. + Applied *containerd_v1_types1.Descriptor `protobuf:"bytes,1,opt,name=applied" json:"applied,omitempty"` +} + +func (m *ApplyResponse) Reset() { *m = ApplyResponse{} } +func (*ApplyResponse) ProtoMessage() {} +func (*ApplyResponse) Descriptor() ([]byte, []int) { return fileDescriptorDiff, []int{1} } + +type DiffRequest struct { + // Left are the mounts which represent the older copy + // in which is the base of the computed changes. + Left []*containerd_v1_types.Mount `protobuf:"bytes,1,rep,name=left" json:"left,omitempty"` + // Right are the mounts which represents the newer copy + // in which changes from the left were made into. + Right []*containerd_v1_types.Mount `protobuf:"bytes,2,rep,name=right" json:"right,omitempty"` + // MediaType is the media type descriptor for the created diff + // object + MediaType string `protobuf:"bytes,3,opt,name=media_type,json=mediaType,proto3" json:"media_type,omitempty"` + // Ref identifies the pre-commit content store object. This + // reference can be used to get the status from the content store. + Ref string `protobuf:"bytes,5,opt,name=ref,proto3" json:"ref,omitempty"` +} + +func (m *DiffRequest) Reset() { *m = DiffRequest{} } +func (*DiffRequest) ProtoMessage() {} +func (*DiffRequest) Descriptor() ([]byte, []int) { return fileDescriptorDiff, []int{2} } + +type DiffResponse struct { + // Diff is the descriptor of the diff which can be applied + Diff *containerd_v1_types1.Descriptor `protobuf:"bytes,3,opt,name=diff" json:"diff,omitempty"` +} + +func (m *DiffResponse) Reset() { *m = DiffResponse{} } +func (*DiffResponse) ProtoMessage() {} +func (*DiffResponse) Descriptor() ([]byte, []int) { return fileDescriptorDiff, []int{3} } + +func init() { + proto.RegisterType((*ApplyRequest)(nil), "containerd.v1.ApplyRequest") + proto.RegisterType((*ApplyResponse)(nil), "containerd.v1.ApplyResponse") + proto.RegisterType((*DiffRequest)(nil), "containerd.v1.DiffRequest") + proto.RegisterType((*DiffResponse)(nil), "containerd.v1.DiffResponse") +} + +// 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.SupportPackageIsVersion4 + +// Client API for Diff service + +type DiffClient interface { + // Apply applies the content associated with the provided digests onto + // the provided mounts. Archive content will be extracted and + // decompressed if necessary. + Apply(ctx context.Context, in *ApplyRequest, opts ...grpc.CallOption) (*ApplyResponse, error) + // Diff creates a diff between the given mounts and uploads the result + // to the content store. + Diff(ctx context.Context, in *DiffRequest, opts ...grpc.CallOption) (*DiffResponse, error) +} + +type diffClient struct { + cc *grpc.ClientConn +} + +func NewDiffClient(cc *grpc.ClientConn) DiffClient { + return &diffClient{cc} +} + +func (c *diffClient) Apply(ctx context.Context, in *ApplyRequest, opts ...grpc.CallOption) (*ApplyResponse, error) { + out := new(ApplyResponse) + err := grpc.Invoke(ctx, "/containerd.v1.Diff/Apply", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *diffClient) Diff(ctx context.Context, in *DiffRequest, opts ...grpc.CallOption) (*DiffResponse, error) { + out := new(DiffResponse) + err := grpc.Invoke(ctx, "/containerd.v1.Diff/Diff", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for Diff service + +type DiffServer interface { + // Apply applies the content associated with the provided digests onto + // the provided mounts. Archive content will be extracted and + // decompressed if necessary. + Apply(context.Context, *ApplyRequest) (*ApplyResponse, error) + // Diff creates a diff between the given mounts and uploads the result + // to the content store. + Diff(context.Context, *DiffRequest) (*DiffResponse, error) +} + +func RegisterDiffServer(s *grpc.Server, srv DiffServer) { + s.RegisterService(&_Diff_serviceDesc, srv) +} + +func _Diff_Apply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ApplyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DiffServer).Apply(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.v1.Diff/Apply", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DiffServer).Apply(ctx, req.(*ApplyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Diff_Diff_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DiffRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DiffServer).Diff(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.v1.Diff/Diff", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DiffServer).Diff(ctx, req.(*DiffRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Diff_serviceDesc = grpc.ServiceDesc{ + ServiceName: "containerd.v1.Diff", + HandlerType: (*DiffServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Apply", + Handler: _Diff_Apply_Handler, + }, + { + MethodName: "Diff", + Handler: _Diff_Diff_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "github.com/containerd/containerd/api/services/diff/diff.proto", +} + +func (m *ApplyRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ApplyRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Diff != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintDiff(dAtA, i, uint64(m.Diff.Size())) + n1, err := m.Diff.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + } + if len(m.Mounts) > 0 { + for _, msg := range m.Mounts { + dAtA[i] = 0x12 + i++ + i = encodeVarintDiff(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *ApplyResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ApplyResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Applied != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintDiff(dAtA, i, uint64(m.Applied.Size())) + n2, err := m.Applied.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n2 + } + return i, nil +} + +func (m *DiffRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DiffRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Left) > 0 { + for _, msg := range m.Left { + dAtA[i] = 0xa + i++ + i = encodeVarintDiff(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if len(m.Right) > 0 { + for _, msg := range m.Right { + dAtA[i] = 0x12 + i++ + i = encodeVarintDiff(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if len(m.MediaType) > 0 { + dAtA[i] = 0x1a + i++ + i = encodeVarintDiff(dAtA, i, uint64(len(m.MediaType))) + i += copy(dAtA[i:], m.MediaType) + } + if len(m.Ref) > 0 { + dAtA[i] = 0x2a + i++ + i = encodeVarintDiff(dAtA, i, uint64(len(m.Ref))) + i += copy(dAtA[i:], m.Ref) + } + return i, nil +} + +func (m *DiffResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DiffResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Diff != nil { + dAtA[i] = 0x1a + i++ + i = encodeVarintDiff(dAtA, i, uint64(m.Diff.Size())) + n3, err := m.Diff.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n3 + } + return i, nil +} + +func encodeFixed64Diff(dAtA []byte, offset int, v uint64) int { + dAtA[offset] = uint8(v) + dAtA[offset+1] = uint8(v >> 8) + dAtA[offset+2] = uint8(v >> 16) + dAtA[offset+3] = uint8(v >> 24) + dAtA[offset+4] = uint8(v >> 32) + dAtA[offset+5] = uint8(v >> 40) + dAtA[offset+6] = uint8(v >> 48) + dAtA[offset+7] = uint8(v >> 56) + return offset + 8 +} +func encodeFixed32Diff(dAtA []byte, offset int, v uint32) int { + dAtA[offset] = uint8(v) + dAtA[offset+1] = uint8(v >> 8) + dAtA[offset+2] = uint8(v >> 16) + dAtA[offset+3] = uint8(v >> 24) + return offset + 4 +} +func encodeVarintDiff(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *ApplyRequest) Size() (n int) { + var l int + _ = l + if m.Diff != nil { + l = m.Diff.Size() + n += 1 + l + sovDiff(uint64(l)) + } + if len(m.Mounts) > 0 { + for _, e := range m.Mounts { + l = e.Size() + n += 1 + l + sovDiff(uint64(l)) + } + } + return n +} + +func (m *ApplyResponse) Size() (n int) { + var l int + _ = l + if m.Applied != nil { + l = m.Applied.Size() + n += 1 + l + sovDiff(uint64(l)) + } + return n +} + +func (m *DiffRequest) Size() (n int) { + var l int + _ = l + if len(m.Left) > 0 { + for _, e := range m.Left { + l = e.Size() + n += 1 + l + sovDiff(uint64(l)) + } + } + if len(m.Right) > 0 { + for _, e := range m.Right { + l = e.Size() + n += 1 + l + sovDiff(uint64(l)) + } + } + l = len(m.MediaType) + if l > 0 { + n += 1 + l + sovDiff(uint64(l)) + } + l = len(m.Ref) + if l > 0 { + n += 1 + l + sovDiff(uint64(l)) + } + return n +} + +func (m *DiffResponse) Size() (n int) { + var l int + _ = l + if m.Diff != nil { + l = m.Diff.Size() + n += 1 + l + sovDiff(uint64(l)) + } + return n +} + +func sovDiff(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozDiff(x uint64) (n int) { + return sovDiff(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *ApplyRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ApplyRequest{`, + `Diff:` + strings.Replace(fmt.Sprintf("%v", this.Diff), "Descriptor", "containerd_v1_types1.Descriptor", 1) + `,`, + `Mounts:` + strings.Replace(fmt.Sprintf("%v", this.Mounts), "Mount", "containerd_v1_types.Mount", 1) + `,`, + `}`, + }, "") + return s +} +func (this *ApplyResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ApplyResponse{`, + `Applied:` + strings.Replace(fmt.Sprintf("%v", this.Applied), "Descriptor", "containerd_v1_types1.Descriptor", 1) + `,`, + `}`, + }, "") + return s +} +func (this *DiffRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&DiffRequest{`, + `Left:` + strings.Replace(fmt.Sprintf("%v", this.Left), "Mount", "containerd_v1_types.Mount", 1) + `,`, + `Right:` + strings.Replace(fmt.Sprintf("%v", this.Right), "Mount", "containerd_v1_types.Mount", 1) + `,`, + `MediaType:` + fmt.Sprintf("%v", this.MediaType) + `,`, + `Ref:` + fmt.Sprintf("%v", this.Ref) + `,`, + `}`, + }, "") + return s +} +func (this *DiffResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&DiffResponse{`, + `Diff:` + strings.Replace(fmt.Sprintf("%v", this.Diff), "Descriptor", "containerd_v1_types1.Descriptor", 1) + `,`, + `}`, + }, "") + return s +} +func valueToStringDiff(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *ApplyRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDiff + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ApplyRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ApplyRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Diff", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDiff + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDiff + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Diff == nil { + m.Diff = &containerd_v1_types1.Descriptor{} + } + if err := m.Diff.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Mounts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDiff + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDiff + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Mounts = append(m.Mounts, &containerd_v1_types.Mount{}) + if err := m.Mounts[len(m.Mounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDiff(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDiff + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ApplyResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDiff + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ApplyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ApplyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Applied", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDiff + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDiff + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Applied == nil { + m.Applied = &containerd_v1_types1.Descriptor{} + } + if err := m.Applied.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDiff(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDiff + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DiffRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDiff + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DiffRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DiffRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Left", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDiff + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDiff + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Left = append(m.Left, &containerd_v1_types.Mount{}) + if err := m.Left[len(m.Left)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Right", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDiff + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDiff + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Right = append(m.Right, &containerd_v1_types.Mount{}) + if err := m.Right[len(m.Right)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MediaType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDiff + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDiff + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MediaType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ref", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDiff + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDiff + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ref = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDiff(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDiff + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DiffResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDiff + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DiffResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DiffResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Diff", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDiff + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDiff + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Diff == nil { + m.Diff = &containerd_v1_types1.Descriptor{} + } + if err := m.Diff.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDiff(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDiff + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDiff(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDiff + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDiff + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDiff + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthDiff + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDiff + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipDiff(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthDiff = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDiff = fmt.Errorf("proto: integer overflow") +) + +func init() { + proto.RegisterFile("github.com/containerd/containerd/api/services/diff/diff.proto", fileDescriptorDiff) +} + +var fileDescriptorDiff = []byte{ + // 407 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x41, 0xcf, 0x93, 0x40, + 0x10, 0xfd, 0x56, 0xda, 0xcf, 0x74, 0xdb, 0x26, 0x66, 0xe3, 0x81, 0x50, 0xa5, 0x0d, 0xa7, 0x9e, + 0x40, 0xe9, 0xc9, 0x44, 0x63, 0xac, 0x8d, 0x07, 0x13, 0x2f, 0xc4, 0xbb, 0xa1, 0x30, 0xd0, 0x4d, + 0x80, 0x5d, 0xd9, 0xa5, 0x86, 0x9b, 0x77, 0xff, 0x84, 0x3f, 0xa7, 0x47, 0x8f, 0x1e, 0x2d, 0xbf, + 0xc4, 0xb0, 0x6c, 0x15, 0x9b, 0x26, 0xb6, 0x97, 0xcd, 0xb0, 0xef, 0xcd, 0x9b, 0x37, 0x8f, 0xc5, + 0xaf, 0x52, 0x2a, 0x77, 0xd5, 0xd6, 0x8d, 0x58, 0xee, 0x45, 0xac, 0x90, 0x21, 0x2d, 0xa0, 0x8c, + 0xfb, 0x65, 0xc8, 0xa9, 0x27, 0xa0, 0xdc, 0xd3, 0x08, 0x84, 0x17, 0xd3, 0x24, 0x51, 0x87, 0xcb, + 0x4b, 0x26, 0x19, 0x99, 0xfe, 0x25, 0xba, 0xfb, 0xe7, 0xd6, 0xe3, 0x94, 0xa5, 0x4c, 0x21, 0x5e, + 0x5b, 0x75, 0x24, 0x6b, 0x96, 0x32, 0x96, 0x66, 0xe0, 0xa9, 0xaf, 0x6d, 0x95, 0x78, 0x90, 0x73, + 0x59, 0x6b, 0x70, 0x7e, 0x0e, 0x4a, 0x9a, 0x83, 0x90, 0x61, 0xce, 0x35, 0xe1, 0xe5, 0x55, 0x0e, + 0x65, 0xcd, 0x41, 0x78, 0x39, 0xab, 0x0a, 0xd9, 0x9d, 0xba, 0xfb, 0xdd, 0x0d, 0xdd, 0x31, 0x88, + 0xa8, 0xa4, 0x5c, 0xb2, 0xb2, 0x57, 0x76, 0x3a, 0xce, 0x17, 0x3c, 0x79, 0xc3, 0x79, 0x56, 0x07, + 0xf0, 0xb9, 0x02, 0x21, 0xc9, 0x0a, 0x0f, 0xda, 0x18, 0x4c, 0xb4, 0x40, 0xcb, 0xb1, 0x3f, 0x77, + 0xff, 0xc9, 0xc1, 0x55, 0x7a, 0xee, 0xe6, 0x8f, 0x48, 0xa0, 0xc8, 0xc4, 0xc7, 0xf7, 0xca, 0x9b, + 0x30, 0x1f, 0x2c, 0x8c, 0xe5, 0xd8, 0xb7, 0x2e, 0xb6, 0x7d, 0x68, 0x29, 0x81, 0x66, 0x3a, 0xef, + 0xf1, 0x54, 0x0f, 0x16, 0x9c, 0x15, 0x02, 0xc8, 0x0b, 0xfc, 0x30, 0xe4, 0x3c, 0xa3, 0x10, 0x5f, + 0x3b, 0xfc, 0xc4, 0x77, 0xbe, 0x23, 0x3c, 0xde, 0xd0, 0x24, 0x39, 0x2d, 0xe1, 0xe2, 0x41, 0x06, + 0x89, 0x34, 0xd1, 0x7f, 0xdd, 0x28, 0x1e, 0x79, 0x86, 0x87, 0x25, 0x4d, 0x77, 0xf2, 0x0a, 0xfb, + 0x1d, 0x91, 0x3c, 0xc5, 0x38, 0x87, 0x98, 0x86, 0x9f, 0x5a, 0xcc, 0x34, 0x16, 0x68, 0x39, 0x0a, + 0x46, 0xea, 0xe6, 0x63, 0xcd, 0x81, 0x3c, 0xc2, 0x46, 0x09, 0x89, 0x39, 0x54, 0xf7, 0x6d, 0xe9, + 0xbc, 0xc5, 0x93, 0xce, 0xa1, 0xde, 0xf6, 0x94, 0xb3, 0x71, 0x43, 0xce, 0xfe, 0x37, 0x84, 0x07, + 0xad, 0x0a, 0x59, 0xe3, 0xa1, 0x0a, 0x8f, 0xcc, 0xce, 0x1a, 0xfb, 0xff, 0xd2, 0x7a, 0x72, 0x19, + 0xd4, 0x0e, 0x5e, 0x6b, 0xad, 0xf3, 0x6d, 0x7b, 0x41, 0x5a, 0xb3, 0x8b, 0x58, 0x27, 0xb0, 0x36, + 0x0f, 0x47, 0xfb, 0xee, 0xe7, 0xd1, 0xbe, 0xfb, 0xda, 0xd8, 0xe8, 0xd0, 0xd8, 0xe8, 0x47, 0x63, + 0xa3, 0x5f, 0x8d, 0x8d, 0xb6, 0xf7, 0xea, 0x6d, 0xad, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0x61, + 0x65, 0x17, 0x47, 0x85, 0x03, 0x00, 0x00, +} diff --git a/api/services/diff/diff.proto b/api/services/diff/diff.proto new file mode 100644 index 000000000..757eb27cb --- /dev/null +++ b/api/services/diff/diff.proto @@ -0,0 +1,58 @@ +syntax = "proto3"; + +package containerd.v1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; +import "github.com/containerd/containerd/api/types/mount/mount.proto"; +import "github.com/containerd/containerd/api/types/descriptor/descriptor.proto"; + +// Diff service creates and applies diffs +service Diff { + // Apply applies the content associated with the provided digests onto + // the provided mounts. Archive content will be extracted and + // decompressed if necessary. + rpc Apply(ApplyRequest) returns (ApplyResponse); + + // Diff creates a diff between the given mounts and uploads the result + // to the content store. + rpc Diff(DiffRequest) returns (DiffResponse); +} + +message ApplyRequest { + // Diff is the descriptor of the diff to be extracted + containerd.v1.types.Descriptor diff = 1; + + repeated containerd.v1.types.Mount mounts = 2; +} + +message ApplyResponse { + // Applied is the descriptor for the object which was applied. + // If the input was a compressed blob then the result will be + // the descriptor for the uncompressed blob. + containerd.v1.types.Descriptor applied = 1; +} + +message DiffRequest { + // Left are the mounts which represent the older copy + // in which is the base of the computed changes. + repeated containerd.v1.types.Mount left = 1; + + // Right are the mounts which represents the newer copy + // in which changes from the left were made into. + repeated containerd.v1.types.Mount right = 2; + + // MediaType is the media type descriptor for the created diff + // object + string media_type = 3; + + // Ref identifies the pre-commit content store object. This + // reference can be used to get the status from the content store. + string ref = 5; +} + +message DiffResponse { + // Diff is the descriptor of the diff which can be applied + containerd.v1.types.Descriptor diff = 3; +} diff --git a/api/services/rootfs/rootfs.pb.go b/api/services/rootfs/rootfs.pb.go deleted file mode 100644 index b012d6984..000000000 --- a/api/services/rootfs/rootfs.pb.go +++ /dev/null @@ -1,1133 +0,0 @@ -// Code generated by protoc-gen-gogo. -// source: github.com/containerd/containerd/api/services/rootfs/rootfs.proto -// DO NOT EDIT! - -/* - Package rootfs is a generated protocol buffer package. - - It is generated from these files: - github.com/containerd/containerd/api/services/rootfs/rootfs.proto - - It has these top-level messages: - UnpackRequest - UnpackResponse - PrepareRequest - MountsRequest - MountResponse -*/ -package rootfs - -import proto "github.com/gogo/protobuf/proto" -import fmt "fmt" -import math "math" -import _ "github.com/gogo/protobuf/gogoproto" -import containerd_v1_types "github.com/containerd/containerd/api/types/mount" -import containerd_v1_types1 "github.com/containerd/containerd/api/types/descriptor" - -import github_com_opencontainers_go_digest "github.com/opencontainers/go-digest" - -import ( - context "golang.org/x/net/context" - grpc "google.golang.org/grpc" -) - -import strings "strings" -import reflect "reflect" - -import io "io" - -// 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. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package - -type UnpackRequest struct { - Layers []*containerd_v1_types1.Descriptor `protobuf:"bytes,1,rep,name=layers" json:"layers,omitempty"` -} - -func (m *UnpackRequest) Reset() { *m = UnpackRequest{} } -func (*UnpackRequest) ProtoMessage() {} -func (*UnpackRequest) Descriptor() ([]byte, []int) { return fileDescriptorRootfs, []int{0} } - -type UnpackResponse struct { - ChainID github_com_opencontainers_go_digest.Digest `protobuf:"bytes,1,opt,name=chainid,proto3,customtype=github.com/opencontainers/go-digest.Digest" json:"chainid"` -} - -func (m *UnpackResponse) Reset() { *m = UnpackResponse{} } -func (*UnpackResponse) ProtoMessage() {} -func (*UnpackResponse) Descriptor() ([]byte, []int) { return fileDescriptorRootfs, []int{1} } - -type PrepareRequest struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - ChainID github_com_opencontainers_go_digest.Digest `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3,customtype=github.com/opencontainers/go-digest.Digest" json:"chain_id"` - Readonly bool `protobuf:"varint,3,opt,name=readonly,proto3" json:"readonly,omitempty"` -} - -func (m *PrepareRequest) Reset() { *m = PrepareRequest{} } -func (*PrepareRequest) ProtoMessage() {} -func (*PrepareRequest) Descriptor() ([]byte, []int) { return fileDescriptorRootfs, []int{2} } - -type MountsRequest struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (m *MountsRequest) Reset() { *m = MountsRequest{} } -func (*MountsRequest) ProtoMessage() {} -func (*MountsRequest) Descriptor() ([]byte, []int) { return fileDescriptorRootfs, []int{3} } - -type MountResponse struct { - Mounts []*containerd_v1_types.Mount `protobuf:"bytes,1,rep,name=mounts" json:"mounts,omitempty"` -} - -func (m *MountResponse) Reset() { *m = MountResponse{} } -func (*MountResponse) ProtoMessage() {} -func (*MountResponse) Descriptor() ([]byte, []int) { return fileDescriptorRootfs, []int{4} } - -func init() { - proto.RegisterType((*UnpackRequest)(nil), "containerd.v1.UnpackRequest") - proto.RegisterType((*UnpackResponse)(nil), "containerd.v1.UnpackResponse") - proto.RegisterType((*PrepareRequest)(nil), "containerd.v1.PrepareRequest") - proto.RegisterType((*MountsRequest)(nil), "containerd.v1.MountsRequest") - proto.RegisterType((*MountResponse)(nil), "containerd.v1.MountResponse") -} - -// 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.SupportPackageIsVersion4 - -// Client API for RootFS service - -type RootFSClient interface { - Unpack(ctx context.Context, in *UnpackRequest, opts ...grpc.CallOption) (*UnpackResponse, error) - Prepare(ctx context.Context, in *PrepareRequest, opts ...grpc.CallOption) (*MountResponse, error) - Mounts(ctx context.Context, in *MountsRequest, opts ...grpc.CallOption) (*MountResponse, error) -} - -type rootFSClient struct { - cc *grpc.ClientConn -} - -func NewRootFSClient(cc *grpc.ClientConn) RootFSClient { - return &rootFSClient{cc} -} - -func (c *rootFSClient) Unpack(ctx context.Context, in *UnpackRequest, opts ...grpc.CallOption) (*UnpackResponse, error) { - out := new(UnpackResponse) - err := grpc.Invoke(ctx, "/containerd.v1.RootFS/Unpack", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *rootFSClient) Prepare(ctx context.Context, in *PrepareRequest, opts ...grpc.CallOption) (*MountResponse, error) { - out := new(MountResponse) - err := grpc.Invoke(ctx, "/containerd.v1.RootFS/Prepare", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *rootFSClient) Mounts(ctx context.Context, in *MountsRequest, opts ...grpc.CallOption) (*MountResponse, error) { - out := new(MountResponse) - err := grpc.Invoke(ctx, "/containerd.v1.RootFS/Mounts", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// Server API for RootFS service - -type RootFSServer interface { - Unpack(context.Context, *UnpackRequest) (*UnpackResponse, error) - Prepare(context.Context, *PrepareRequest) (*MountResponse, error) - Mounts(context.Context, *MountsRequest) (*MountResponse, error) -} - -func RegisterRootFSServer(s *grpc.Server, srv RootFSServer) { - s.RegisterService(&_RootFS_serviceDesc, srv) -} - -func _RootFS_Unpack_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UnpackRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RootFSServer).Unpack(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/containerd.v1.RootFS/Unpack", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RootFSServer).Unpack(ctx, req.(*UnpackRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _RootFS_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.(RootFSServer).Prepare(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/containerd.v1.RootFS/Prepare", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RootFSServer).Prepare(ctx, req.(*PrepareRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _RootFS_Mounts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MountsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RootFSServer).Mounts(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/containerd.v1.RootFS/Mounts", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RootFSServer).Mounts(ctx, req.(*MountsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _RootFS_serviceDesc = grpc.ServiceDesc{ - ServiceName: "containerd.v1.RootFS", - HandlerType: (*RootFSServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Unpack", - Handler: _RootFS_Unpack_Handler, - }, - { - MethodName: "Prepare", - Handler: _RootFS_Prepare_Handler, - }, - { - MethodName: "Mounts", - Handler: _RootFS_Mounts_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "github.com/containerd/containerd/api/services/rootfs/rootfs.proto", -} - -func (m *UnpackRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *UnpackRequest) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Layers) > 0 { - for _, msg := range m.Layers { - dAtA[i] = 0xa - i++ - i = encodeVarintRootfs(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - return i, nil -} - -func (m *UnpackResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *UnpackResponse) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.ChainID) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintRootfs(dAtA, i, uint64(len(m.ChainID))) - i += copy(dAtA[i:], m.ChainID) - } - return i, nil -} - -func (m *PrepareRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PrepareRequest) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Name) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintRootfs(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) - } - if len(m.ChainID) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintRootfs(dAtA, i, uint64(len(m.ChainID))) - i += copy(dAtA[i:], m.ChainID) - } - if m.Readonly { - dAtA[i] = 0x18 - i++ - if m.Readonly { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i++ - } - return i, nil -} - -func (m *MountsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MountsRequest) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Name) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintRootfs(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) - } - return i, nil -} - -func (m *MountResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MountResponse) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Mounts) > 0 { - for _, msg := range m.Mounts { - dAtA[i] = 0xa - i++ - i = encodeVarintRootfs(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - return i, nil -} - -func encodeFixed64Rootfs(dAtA []byte, offset int, v uint64) int { - dAtA[offset] = uint8(v) - dAtA[offset+1] = uint8(v >> 8) - dAtA[offset+2] = uint8(v >> 16) - dAtA[offset+3] = uint8(v >> 24) - dAtA[offset+4] = uint8(v >> 32) - dAtA[offset+5] = uint8(v >> 40) - dAtA[offset+6] = uint8(v >> 48) - dAtA[offset+7] = uint8(v >> 56) - return offset + 8 -} -func encodeFixed32Rootfs(dAtA []byte, offset int, v uint32) int { - dAtA[offset] = uint8(v) - dAtA[offset+1] = uint8(v >> 8) - dAtA[offset+2] = uint8(v >> 16) - dAtA[offset+3] = uint8(v >> 24) - return offset + 4 -} -func encodeVarintRootfs(dAtA []byte, offset int, v uint64) int { - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return offset + 1 -} -func (m *UnpackRequest) Size() (n int) { - var l int - _ = l - if len(m.Layers) > 0 { - for _, e := range m.Layers { - l = e.Size() - n += 1 + l + sovRootfs(uint64(l)) - } - } - return n -} - -func (m *UnpackResponse) Size() (n int) { - var l int - _ = l - l = len(m.ChainID) - if l > 0 { - n += 1 + l + sovRootfs(uint64(l)) - } - return n -} - -func (m *PrepareRequest) Size() (n int) { - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovRootfs(uint64(l)) - } - l = len(m.ChainID) - if l > 0 { - n += 1 + l + sovRootfs(uint64(l)) - } - if m.Readonly { - n += 2 - } - return n -} - -func (m *MountsRequest) Size() (n int) { - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovRootfs(uint64(l)) - } - return n -} - -func (m *MountResponse) Size() (n int) { - var l int - _ = l - if len(m.Mounts) > 0 { - for _, e := range m.Mounts { - l = e.Size() - n += 1 + l + sovRootfs(uint64(l)) - } - } - return n -} - -func sovRootfs(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n -} -func sozRootfs(x uint64) (n int) { - return sovRootfs(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (this *UnpackRequest) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&UnpackRequest{`, - `Layers:` + strings.Replace(fmt.Sprintf("%v", this.Layers), "Descriptor", "containerd_v1_types1.Descriptor", 1) + `,`, - `}`, - }, "") - return s -} -func (this *UnpackResponse) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&UnpackResponse{`, - `ChainID:` + fmt.Sprintf("%v", this.ChainID) + `,`, - `}`, - }, "") - return s -} -func (this *PrepareRequest) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&PrepareRequest{`, - `Name:` + fmt.Sprintf("%v", this.Name) + `,`, - `ChainID:` + fmt.Sprintf("%v", this.ChainID) + `,`, - `Readonly:` + fmt.Sprintf("%v", this.Readonly) + `,`, - `}`, - }, "") - return s -} -func (this *MountsRequest) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&MountsRequest{`, - `Name:` + fmt.Sprintf("%v", this.Name) + `,`, - `}`, - }, "") - return s -} -func (this *MountResponse) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&MountResponse{`, - `Mounts:` + strings.Replace(fmt.Sprintf("%v", this.Mounts), "Mount", "containerd_v1_types.Mount", 1) + `,`, - `}`, - }, "") - return s -} -func valueToStringRootfs(v interface{}) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("*%v", pv) -} -func (m *UnpackRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRootfs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: UnpackRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UnpackRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Layers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRootfs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRootfs - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Layers = append(m.Layers, &containerd_v1_types1.Descriptor{}) - if err := m.Layers[len(m.Layers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRootfs(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthRootfs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *UnpackResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRootfs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: UnpackResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UnpackResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRootfs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRootfs - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainID = github_com_opencontainers_go_digest.Digest(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRootfs(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthRootfs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PrepareRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRootfs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PrepareRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PrepareRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRootfs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRootfs - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRootfs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRootfs - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainID = github_com_opencontainers_go_digest.Digest(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Readonly", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRootfs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.Readonly = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipRootfs(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthRootfs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MountsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRootfs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MountsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MountsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRootfs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRootfs - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRootfs(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthRootfs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MountResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRootfs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MountResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MountResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Mounts", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRootfs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRootfs - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Mounts = append(m.Mounts, &containerd_v1_types.Mount{}) - if err := m.Mounts[len(m.Mounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRootfs(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthRootfs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipRootfs(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowRootfs - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowRootfs - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - return iNdEx, nil - case 1: - iNdEx += 8 - return iNdEx, nil - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowRootfs - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - iNdEx += length - if length < 0 { - return 0, ErrInvalidLengthRootfs - } - return iNdEx, nil - case 3: - for { - var innerWire uint64 - var start int = iNdEx - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowRootfs - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - innerWire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - innerWireType := int(innerWire & 0x7) - if innerWireType == 4 { - break - } - next, err := skipRootfs(dAtA[start:]) - if err != nil { - return 0, err - } - iNdEx = start + next - } - return iNdEx, nil - case 4: - return iNdEx, nil - case 5: - iNdEx += 4 - return iNdEx, nil - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - } - panic("unreachable") -} - -var ( - ErrInvalidLengthRootfs = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowRootfs = fmt.Errorf("proto: integer overflow") -) - -func init() { - proto.RegisterFile("github.com/containerd/containerd/api/services/rootfs/rootfs.proto", fileDescriptorRootfs) -} - -var fileDescriptorRootfs = []byte{ - // 428 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x52, 0x4d, 0xab, 0xd3, 0x40, - 0x14, 0xed, 0xf8, 0x24, 0xad, 0x23, 0x7d, 0x8b, 0xc1, 0x45, 0x08, 0x9a, 0x94, 0xb8, 0x29, 0x82, - 0x09, 0xd6, 0x85, 0x1b, 0x5d, 0xf8, 0x5e, 0x2c, 0xbe, 0x85, 0x20, 0x11, 0xd1, 0x9d, 0x4c, 0x93, - 0x31, 0x1d, 0x6c, 0xe7, 0x8e, 0x33, 0xd3, 0x42, 0x77, 0xfe, 0x0e, 0x7f, 0x51, 0x97, 0x2e, 0x45, - 0xb0, 0xd8, 0xfc, 0x12, 0x69, 0xbe, 0x6c, 0x4a, 0x95, 0x0a, 0x6f, 0x93, 0xb9, 0x61, 0xce, 0x39, - 0xf7, 0xdc, 0x73, 0x07, 0x3f, 0xcf, 0xb8, 0x99, 0x2e, 0x26, 0x41, 0x02, 0xf3, 0x30, 0x01, 0x61, - 0x28, 0x17, 0x4c, 0xa5, 0xfb, 0x25, 0x95, 0x3c, 0xd4, 0x4c, 0x2d, 0x79, 0xc2, 0x74, 0xa8, 0x00, - 0xcc, 0xc7, 0xfa, 0x08, 0xa4, 0x02, 0x03, 0xa4, 0xff, 0x07, 0x1c, 0x2c, 0x1f, 0x39, 0x77, 0x32, - 0xc8, 0xa0, 0xb8, 0x09, 0x77, 0x55, 0x09, 0x72, 0x9e, 0x9e, 0xd4, 0xc7, 0xac, 0x24, 0xd3, 0xe1, - 0x1c, 0x16, 0xc2, 0x94, 0xdf, 0x8a, 0x3d, 0xfe, 0x0f, 0x76, 0xca, 0x74, 0xa2, 0xb8, 0x34, 0xa0, - 0xf6, 0xca, 0x52, 0xc7, 0x7f, 0x89, 0xfb, 0x6f, 0x85, 0xa4, 0xc9, 0xa7, 0x98, 0x7d, 0x5e, 0x30, - 0x6d, 0xc8, 0x13, 0x6c, 0xcd, 0xe8, 0x8a, 0x29, 0x6d, 0xa3, 0xc1, 0xd9, 0xf0, 0xf6, 0xc8, 0x0b, - 0x5a, 0xc3, 0x04, 0x85, 0x64, 0x10, 0x35, 0x3a, 0x71, 0x05, 0xf7, 0x39, 0x3e, 0xaf, 0x95, 0xb4, - 0x04, 0xa1, 0x19, 0x79, 0x87, 0xbb, 0xc9, 0x94, 0x72, 0xc1, 0x53, 0x1b, 0x0d, 0xd0, 0xf0, 0xd6, - 0xc5, 0xb3, 0xf5, 0xc6, 0xeb, 0xfc, 0xd8, 0x78, 0x0f, 0xf6, 0xcc, 0x83, 0x64, 0xa2, 0xe9, 0xa0, - 0xc3, 0x0c, 0x1e, 0xa6, 0x3c, 0x63, 0xda, 0x04, 0x51, 0x71, 0xe4, 0x1b, 0xaf, 0x7b, 0xb9, 0x13, - 0xb9, 0x8a, 0xe2, 0x5a, 0xcd, 0xff, 0x8a, 0xf0, 0xf9, 0x6b, 0xc5, 0x24, 0x55, 0xac, 0xb6, 0x4d, - 0xf0, 0x4d, 0x41, 0xe7, 0xac, 0x6c, 0x14, 0x17, 0x35, 0x79, 0x8f, 0x7b, 0x05, 0xe3, 0x03, 0x4f, - 0xed, 0x1b, 0xd7, 0x67, 0xe0, 0x2a, 0x25, 0x0e, 0xee, 0x29, 0x46, 0x53, 0x10, 0xb3, 0x95, 0x7d, - 0x36, 0x40, 0xc3, 0x5e, 0xdc, 0xfc, 0xfb, 0xf7, 0x71, 0xff, 0xd5, 0x6e, 0x51, 0xfa, 0x1f, 0xd6, - 0xfc, 0xcb, 0x0a, 0xd4, 0x64, 0x35, 0xc2, 0x56, 0xb1, 0xde, 0x3a, 0x76, 0xe7, 0x68, 0xec, 0x25, - 0xa7, 0x42, 0x8e, 0x7e, 0x22, 0x6c, 0xc5, 0x00, 0x66, 0xfc, 0x86, 0xbc, 0xc0, 0x56, 0x19, 0x3e, - 0xb9, 0x7b, 0x40, 0x6c, 0x6d, 0xd7, 0xb9, 0xf7, 0x97, 0xdb, 0xca, 0xc5, 0x18, 0x77, 0xab, 0x5c, - 0xc9, 0x21, 0xb2, 0x9d, 0xb7, 0x73, 0xd8, 0xa6, 0x3d, 0x4d, 0x84, 0xad, 0x32, 0x03, 0x72, 0x14, - 0xa7, 0x4f, 0x52, 0xb9, 0xb0, 0xd7, 0x5b, 0xb7, 0xf3, 0x7d, 0xeb, 0x76, 0xbe, 0xe4, 0x2e, 0x5a, - 0xe7, 0x2e, 0xfa, 0x96, 0xbb, 0xe8, 0x57, 0xee, 0xa2, 0x89, 0x55, 0x3c, 0xde, 0xc7, 0xbf, 0x03, - 0x00, 0x00, 0xff, 0xff, 0x3c, 0xba, 0xae, 0xaa, 0xac, 0x03, 0x00, 0x00, -} diff --git a/api/services/rootfs/rootfs.proto b/api/services/rootfs/rootfs.proto deleted file mode 100644 index b46985eac..000000000 --- a/api/services/rootfs/rootfs.proto +++ /dev/null @@ -1,35 +0,0 @@ -syntax = "proto3"; - -package containerd.v1; - -import "gogoproto/gogo.proto"; -import "github.com/containerd/containerd/api/types/mount/mount.proto"; -import "github.com/containerd/containerd/api/types/descriptor/descriptor.proto"; - -service RootFS { - rpc Unpack(UnpackRequest) returns (UnpackResponse); - rpc Prepare(PrepareRequest) returns (MountResponse); - rpc Mounts(MountsRequest) returns (MountResponse); -} - -message UnpackRequest { - repeated containerd.v1.types.Descriptor layers = 1; -} - -message UnpackResponse { - string chainid = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false, (gogoproto.customname) = "ChainID"]; -} - -message PrepareRequest { - string name = 1; - string chain_id = 2 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false, (gogoproto.customname) = "ChainID"]; - bool readonly = 3; -} - -message MountsRequest { - string name = 1; -} - -message MountResponse { - repeated containerd.v1.types.Mount mounts = 1; -} diff --git a/api/services/snapshot/snapshots.pb.go b/api/services/snapshot/snapshots.pb.go new file mode 100644 index 000000000..2ee996ba1 --- /dev/null +++ b/api/services/snapshot/snapshots.pb.go @@ -0,0 +1,2379 @@ +// Code generated by protoc-gen-gogo. +// source: github.com/containerd/containerd/api/services/snapshot/snapshots.proto +// DO NOT EDIT! + +/* + Package snapshot is a generated protocol buffer package. + + It is generated from these files: + github.com/containerd/containerd/api/services/snapshot/snapshots.proto + + It has these top-level messages: + PrepareRequest + MountsRequest + MountsResponse + RemoveRequest + CommitRequest + StatRequest + Info + StatResponse + ListRequest + ListResponse + UsageRequest + UsageResponse +*/ +package snapshot + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" +import _ "github.com/gogo/protobuf/gogoproto" +import google_protobuf1 "github.com/golang/protobuf/ptypes/empty" +import containerd_v1_types "github.com/containerd/containerd/api/types/mount" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +import strings "strings" +import reflect "reflect" + +import io "io" + +// 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. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +type Kind int32 + +const ( + KindActive Kind = 0 + KindCommitted Kind = 1 +) + +var Kind_name = map[int32]string{ + 0: "ACTIVE", + 1: "COMMITTED", +} +var Kind_value = map[string]int32{ + "ACTIVE": 0, + "COMMITTED": 1, +} + +func (x Kind) String() string { + return proto.EnumName(Kind_name, int32(x)) +} +func (Kind) EnumDescriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{0} } + +type PrepareRequest struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` +} + +func (m *PrepareRequest) Reset() { *m = PrepareRequest{} } +func (*PrepareRequest) ProtoMessage() {} +func (*PrepareRequest) Descriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{0} } + +type MountsRequest struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *MountsRequest) Reset() { *m = MountsRequest{} } +func (*MountsRequest) ProtoMessage() {} +func (*MountsRequest) Descriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{1} } + +type MountsResponse struct { + Mounts []*containerd_v1_types.Mount `protobuf:"bytes,1,rep,name=mounts" json:"mounts,omitempty"` +} + +func (m *MountsResponse) Reset() { *m = MountsResponse{} } +func (*MountsResponse) ProtoMessage() {} +func (*MountsResponse) Descriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{2} } + +type RemoveRequest struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *RemoveRequest) Reset() { *m = RemoveRequest{} } +func (*RemoveRequest) ProtoMessage() {} +func (*RemoveRequest) Descriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{3} } + +type CommitRequest struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *CommitRequest) Reset() { *m = CommitRequest{} } +func (*CommitRequest) ProtoMessage() {} +func (*CommitRequest) Descriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{4} } + +type StatRequest struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *StatRequest) Reset() { *m = StatRequest{} } +func (*StatRequest) ProtoMessage() {} +func (*StatRequest) Descriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{5} } + +type Info struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` + Kind Kind `protobuf:"varint,3,opt,name=kind,proto3,enum=containerd.v1.snapshot.Kind" json:"kind,omitempty"` + Readonly bool `protobuf:"varint,4,opt,name=readonly,proto3" json:"readonly,omitempty"` +} + +func (m *Info) Reset() { *m = Info{} } +func (*Info) ProtoMessage() {} +func (*Info) Descriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{6} } + +type StatResponse struct { + Info Info `protobuf:"bytes,1,opt,name=info" json:"info"` +} + +func (m *StatResponse) Reset() { *m = StatResponse{} } +func (*StatResponse) ProtoMessage() {} +func (*StatResponse) Descriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{7} } + +type ListRequest struct { +} + +func (m *ListRequest) Reset() { *m = ListRequest{} } +func (*ListRequest) ProtoMessage() {} +func (*ListRequest) Descriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{8} } + +type ListResponse struct { + Info []Info `protobuf:"bytes,1,rep,name=info" json:"info"` +} + +func (m *ListResponse) Reset() { *m = ListResponse{} } +func (*ListResponse) ProtoMessage() {} +func (*ListResponse) Descriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{9} } + +type UsageRequest struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *UsageRequest) Reset() { *m = UsageRequest{} } +func (*UsageRequest) ProtoMessage() {} +func (*UsageRequest) Descriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{10} } + +type UsageResponse struct { + Inodes int64 `protobuf:"varint,2,opt,name=inodes,proto3" json:"inodes,omitempty"` + Size_ int64 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"` +} + +func (m *UsageResponse) Reset() { *m = UsageResponse{} } +func (*UsageResponse) ProtoMessage() {} +func (*UsageResponse) Descriptor() ([]byte, []int) { return fileDescriptorSnapshots, []int{11} } + +func init() { + proto.RegisterType((*PrepareRequest)(nil), "containerd.v1.snapshot.PrepareRequest") + proto.RegisterType((*MountsRequest)(nil), "containerd.v1.snapshot.MountsRequest") + proto.RegisterType((*MountsResponse)(nil), "containerd.v1.snapshot.MountsResponse") + proto.RegisterType((*RemoveRequest)(nil), "containerd.v1.snapshot.RemoveRequest") + proto.RegisterType((*CommitRequest)(nil), "containerd.v1.snapshot.CommitRequest") + proto.RegisterType((*StatRequest)(nil), "containerd.v1.snapshot.StatRequest") + proto.RegisterType((*Info)(nil), "containerd.v1.snapshot.Info") + proto.RegisterType((*StatResponse)(nil), "containerd.v1.snapshot.StatResponse") + proto.RegisterType((*ListRequest)(nil), "containerd.v1.snapshot.ListRequest") + proto.RegisterType((*ListResponse)(nil), "containerd.v1.snapshot.ListResponse") + proto.RegisterType((*UsageRequest)(nil), "containerd.v1.snapshot.UsageRequest") + proto.RegisterType((*UsageResponse)(nil), "containerd.v1.snapshot.UsageResponse") + proto.RegisterEnum("containerd.v1.snapshot.Kind", Kind_name, Kind_value) +} + +// 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.SupportPackageIsVersion4 + +// Client API for Snapshot service + +type SnapshotClient interface { + Prepare(ctx context.Context, in *PrepareRequest, opts ...grpc.CallOption) (*MountsResponse, error) + View(ctx context.Context, in *PrepareRequest, opts ...grpc.CallOption) (*MountsResponse, error) + Mounts(ctx context.Context, in *MountsRequest, opts ...grpc.CallOption) (*MountsResponse, error) + Commit(ctx context.Context, in *CommitRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) + Remove(ctx context.Context, in *RemoveRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) + Stat(ctx context.Context, in *StatRequest, opts ...grpc.CallOption) (*StatResponse, error) + List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (Snapshot_ListClient, error) + Usage(ctx context.Context, in *UsageRequest, opts ...grpc.CallOption) (*UsageResponse, error) +} + +type snapshotClient struct { + cc *grpc.ClientConn +} + +func NewSnapshotClient(cc *grpc.ClientConn) SnapshotClient { + return &snapshotClient{cc} +} + +func (c *snapshotClient) Prepare(ctx context.Context, in *PrepareRequest, opts ...grpc.CallOption) (*MountsResponse, error) { + out := new(MountsResponse) + err := grpc.Invoke(ctx, "/containerd.v1.snapshot.Snapshot/Prepare", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *snapshotClient) View(ctx context.Context, in *PrepareRequest, opts ...grpc.CallOption) (*MountsResponse, error) { + out := new(MountsResponse) + err := grpc.Invoke(ctx, "/containerd.v1.snapshot.Snapshot/View", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *snapshotClient) Mounts(ctx context.Context, in *MountsRequest, opts ...grpc.CallOption) (*MountsResponse, error) { + out := new(MountsResponse) + err := grpc.Invoke(ctx, "/containerd.v1.snapshot.Snapshot/Mounts", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *snapshotClient) Commit(ctx context.Context, in *CommitRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { + out := new(google_protobuf1.Empty) + err := grpc.Invoke(ctx, "/containerd.v1.snapshot.Snapshot/Commit", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *snapshotClient) Remove(ctx context.Context, in *RemoveRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { + out := new(google_protobuf1.Empty) + err := grpc.Invoke(ctx, "/containerd.v1.snapshot.Snapshot/Remove", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *snapshotClient) Stat(ctx context.Context, in *StatRequest, opts ...grpc.CallOption) (*StatResponse, error) { + out := new(StatResponse) + err := grpc.Invoke(ctx, "/containerd.v1.snapshot.Snapshot/Stat", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *snapshotClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (Snapshot_ListClient, error) { + stream, err := grpc.NewClientStream(ctx, &_Snapshot_serviceDesc.Streams[0], c.cc, "/containerd.v1.snapshot.Snapshot/List", opts...) + if err != nil { + return nil, err + } + x := &snapshotListClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Snapshot_ListClient interface { + Recv() (*ListResponse, error) + grpc.ClientStream +} + +type snapshotListClient struct { + grpc.ClientStream +} + +func (x *snapshotListClient) Recv() (*ListResponse, error) { + m := new(ListResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *snapshotClient) Usage(ctx context.Context, in *UsageRequest, opts ...grpc.CallOption) (*UsageResponse, error) { + out := new(UsageResponse) + err := grpc.Invoke(ctx, "/containerd.v1.snapshot.Snapshot/Usage", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for Snapshot service + +type SnapshotServer interface { + Prepare(context.Context, *PrepareRequest) (*MountsResponse, error) + View(context.Context, *PrepareRequest) (*MountsResponse, error) + Mounts(context.Context, *MountsRequest) (*MountsResponse, error) + Commit(context.Context, *CommitRequest) (*google_protobuf1.Empty, error) + Remove(context.Context, *RemoveRequest) (*google_protobuf1.Empty, error) + Stat(context.Context, *StatRequest) (*StatResponse, error) + List(*ListRequest, Snapshot_ListServer) error + Usage(context.Context, *UsageRequest) (*UsageResponse, error) +} + +func RegisterSnapshotServer(s *grpc.Server, srv SnapshotServer) { + s.RegisterService(&_Snapshot_serviceDesc, srv) +} + +func _Snapshot_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.(SnapshotServer).Prepare(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.v1.snapshot.Snapshot/Prepare", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SnapshotServer).Prepare(ctx, req.(*PrepareRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Snapshot_View_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.(SnapshotServer).View(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.v1.snapshot.Snapshot/View", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SnapshotServer).View(ctx, req.(*PrepareRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Snapshot_Mounts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MountsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SnapshotServer).Mounts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.v1.snapshot.Snapshot/Mounts", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SnapshotServer).Mounts(ctx, req.(*MountsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Snapshot_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.(SnapshotServer).Commit(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.v1.snapshot.Snapshot/Commit", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SnapshotServer).Commit(ctx, req.(*CommitRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Snapshot_Remove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RemoveRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SnapshotServer).Remove(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.v1.snapshot.Snapshot/Remove", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SnapshotServer).Remove(ctx, req.(*RemoveRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Snapshot_Stat_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StatRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SnapshotServer).Stat(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.v1.snapshot.Snapshot/Stat", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SnapshotServer).Stat(ctx, req.(*StatRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Snapshot_List_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ListRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(SnapshotServer).List(m, &snapshotListServer{stream}) +} + +type Snapshot_ListServer interface { + Send(*ListResponse) error + grpc.ServerStream +} + +type snapshotListServer struct { + grpc.ServerStream +} + +func (x *snapshotListServer) Send(m *ListResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _Snapshot_Usage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UsageRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SnapshotServer).Usage(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.v1.snapshot.Snapshot/Usage", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SnapshotServer).Usage(ctx, req.(*UsageRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Snapshot_serviceDesc = grpc.ServiceDesc{ + ServiceName: "containerd.v1.snapshot.Snapshot", + HandlerType: (*SnapshotServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Prepare", + Handler: _Snapshot_Prepare_Handler, + }, + { + MethodName: "View", + Handler: _Snapshot_View_Handler, + }, + { + MethodName: "Mounts", + Handler: _Snapshot_Mounts_Handler, + }, + { + MethodName: "Commit", + Handler: _Snapshot_Commit_Handler, + }, + { + MethodName: "Remove", + Handler: _Snapshot_Remove_Handler, + }, + { + MethodName: "Stat", + Handler: _Snapshot_Stat_Handler, + }, + { + MethodName: "Usage", + Handler: _Snapshot_Usage_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "List", + Handler: _Snapshot_List_Handler, + ServerStreams: true, + }, + }, + Metadata: "github.com/containerd/containerd/api/services/snapshot/snapshots.proto", +} + +func (m *PrepareRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PrepareRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Key) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(len(m.Key))) + i += copy(dAtA[i:], m.Key) + } + if len(m.Parent) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(len(m.Parent))) + i += copy(dAtA[i:], m.Parent) + } + return i, nil +} + +func (m *MountsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MountsRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Key) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(len(m.Key))) + i += copy(dAtA[i:], m.Key) + } + return i, nil +} + +func (m *MountsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MountsResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Mounts) > 0 { + for _, msg := range m.Mounts { + dAtA[i] = 0xa + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *RemoveRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RemoveRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Key) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(len(m.Key))) + i += copy(dAtA[i:], m.Key) + } + return i, nil +} + +func (m *CommitRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CommitRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if len(m.Key) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(len(m.Key))) + i += copy(dAtA[i:], m.Key) + } + return i, nil +} + +func (m *StatRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StatRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Key) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(len(m.Key))) + i += copy(dAtA[i:], m.Key) + } + return i, nil +} + +func (m *Info) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Info) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if len(m.Parent) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(len(m.Parent))) + i += copy(dAtA[i:], m.Parent) + } + if m.Kind != 0 { + dAtA[i] = 0x18 + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(m.Kind)) + } + if m.Readonly { + dAtA[i] = 0x20 + i++ + if m.Readonly { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + return i, nil +} + +func (m *StatResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StatResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(m.Info.Size())) + n1, err := m.Info.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + return i, nil +} + +func (m *ListRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + return i, nil +} + +func (m *ListResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Info) > 0 { + for _, msg := range m.Info { + dAtA[i] = 0xa + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *UsageRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UsageRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Key) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(len(m.Key))) + i += copy(dAtA[i:], m.Key) + } + return i, nil +} + +func (m *UsageResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UsageResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Size_ != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(m.Size_)) + } + if m.Inodes != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintSnapshots(dAtA, i, uint64(m.Inodes)) + } + return i, nil +} + +func encodeFixed64Snapshots(dAtA []byte, offset int, v uint64) int { + dAtA[offset] = uint8(v) + dAtA[offset+1] = uint8(v >> 8) + dAtA[offset+2] = uint8(v >> 16) + dAtA[offset+3] = uint8(v >> 24) + dAtA[offset+4] = uint8(v >> 32) + dAtA[offset+5] = uint8(v >> 40) + dAtA[offset+6] = uint8(v >> 48) + dAtA[offset+7] = uint8(v >> 56) + return offset + 8 +} +func encodeFixed32Snapshots(dAtA []byte, offset int, v uint32) int { + dAtA[offset] = uint8(v) + dAtA[offset+1] = uint8(v >> 8) + dAtA[offset+2] = uint8(v >> 16) + dAtA[offset+3] = uint8(v >> 24) + return offset + 4 +} +func encodeVarintSnapshots(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *PrepareRequest) Size() (n int) { + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovSnapshots(uint64(l)) + } + l = len(m.Parent) + if l > 0 { + n += 1 + l + sovSnapshots(uint64(l)) + } + return n +} + +func (m *MountsRequest) Size() (n int) { + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovSnapshots(uint64(l)) + } + return n +} + +func (m *MountsResponse) Size() (n int) { + var l int + _ = l + if len(m.Mounts) > 0 { + for _, e := range m.Mounts { + l = e.Size() + n += 1 + l + sovSnapshots(uint64(l)) + } + } + return n +} + +func (m *RemoveRequest) Size() (n int) { + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovSnapshots(uint64(l)) + } + return n +} + +func (m *CommitRequest) Size() (n int) { + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovSnapshots(uint64(l)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovSnapshots(uint64(l)) + } + return n +} + +func (m *StatRequest) Size() (n int) { + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovSnapshots(uint64(l)) + } + return n +} + +func (m *Info) Size() (n int) { + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovSnapshots(uint64(l)) + } + l = len(m.Parent) + if l > 0 { + n += 1 + l + sovSnapshots(uint64(l)) + } + if m.Kind != 0 { + n += 1 + sovSnapshots(uint64(m.Kind)) + } + if m.Readonly { + n += 2 + } + return n +} + +func (m *StatResponse) Size() (n int) { + var l int + _ = l + l = m.Info.Size() + n += 1 + l + sovSnapshots(uint64(l)) + return n +} + +func (m *ListRequest) Size() (n int) { + var l int + _ = l + return n +} + +func (m *ListResponse) Size() (n int) { + var l int + _ = l + if len(m.Info) > 0 { + for _, e := range m.Info { + l = e.Size() + n += 1 + l + sovSnapshots(uint64(l)) + } + } + return n +} + +func (m *UsageRequest) Size() (n int) { + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovSnapshots(uint64(l)) + } + return n +} + +func (m *UsageResponse) Size() (n int) { + var l int + _ = l + if m.Size_ != 0 { + n += 1 + sovSnapshots(uint64(m.Size_)) + } + if m.Inodes != 0 { + n += 1 + sovSnapshots(uint64(m.Inodes)) + } + return n +} + +func sovSnapshots(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozSnapshots(x uint64) (n int) { + return sovSnapshots(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *PrepareRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&PrepareRequest{`, + `Key:` + fmt.Sprintf("%v", this.Key) + `,`, + `Parent:` + fmt.Sprintf("%v", this.Parent) + `,`, + `}`, + }, "") + return s +} +func (this *MountsRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&MountsRequest{`, + `Key:` + fmt.Sprintf("%v", this.Key) + `,`, + `}`, + }, "") + return s +} +func (this *MountsResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&MountsResponse{`, + `Mounts:` + strings.Replace(fmt.Sprintf("%v", this.Mounts), "Mount", "containerd_v1_types.Mount", 1) + `,`, + `}`, + }, "") + return s +} +func (this *RemoveRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&RemoveRequest{`, + `Key:` + fmt.Sprintf("%v", this.Key) + `,`, + `}`, + }, "") + return s +} +func (this *CommitRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&CommitRequest{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `Key:` + fmt.Sprintf("%v", this.Key) + `,`, + `}`, + }, "") + return s +} +func (this *StatRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&StatRequest{`, + `Key:` + fmt.Sprintf("%v", this.Key) + `,`, + `}`, + }, "") + return s +} +func (this *Info) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Info{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `Parent:` + fmt.Sprintf("%v", this.Parent) + `,`, + `Kind:` + fmt.Sprintf("%v", this.Kind) + `,`, + `Readonly:` + fmt.Sprintf("%v", this.Readonly) + `,`, + `}`, + }, "") + return s +} +func (this *StatResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&StatResponse{`, + `Info:` + strings.Replace(strings.Replace(this.Info.String(), "Info", "Info", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} +func (this *ListRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ListRequest{`, + `}`, + }, "") + return s +} +func (this *ListResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ListResponse{`, + `Info:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Info), "Info", "Info", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} +func (this *UsageRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&UsageRequest{`, + `Key:` + fmt.Sprintf("%v", this.Key) + `,`, + `}`, + }, "") + return s +} +func (this *UsageResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&UsageResponse{`, + `Size_:` + fmt.Sprintf("%v", this.Size_) + `,`, + `Inodes:` + fmt.Sprintf("%v", this.Inodes) + `,`, + `}`, + }, "") + return s +} +func valueToStringSnapshots(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *PrepareRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PrepareRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PrepareRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Parent", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Parent = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshots(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSnapshots + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MountsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MountsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MountsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshots(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSnapshots + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MountsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MountsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MountsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Mounts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Mounts = append(m.Mounts, &containerd_v1_types.Mount{}) + if err := m.Mounts[len(m.Mounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshots(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSnapshots + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RemoveRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RemoveRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RemoveRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshots(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSnapshots + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CommitRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CommitRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CommitRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshots(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSnapshots + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StatRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StatRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StatRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshots(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSnapshots + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Info) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Info: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Info: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Parent", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Parent = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) + } + m.Kind = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Kind |= (Kind(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Readonly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Readonly = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipSnapshots(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSnapshots + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StatResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StatResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StatResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshots(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSnapshots + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipSnapshots(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSnapshots + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Info = append(m.Info, Info{}) + if err := m.Info[len(m.Info)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshots(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSnapshots + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UsageRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UsageRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UsageRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSnapshots + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshots(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSnapshots + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UsageResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UsageResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UsageResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) + } + m.Size_ = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Size_ |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Inodes", wireType) + } + m.Inodes = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshots + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Inodes |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSnapshots(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSnapshots + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSnapshots(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSnapshots + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSnapshots + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSnapshots + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthSnapshots + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSnapshots + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipSnapshots(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthSnapshots = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSnapshots = fmt.Errorf("proto: integer overflow") +) + +func init() { + proto.RegisterFile("github.com/containerd/containerd/api/services/snapshot/snapshots.proto", fileDescriptorSnapshots) +} + +var fileDescriptorSnapshots = []byte{ + // 649 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xcd, 0x6e, 0x13, 0x31, + 0x10, 0xc7, 0xb3, 0xcd, 0x36, 0xb4, 0x93, 0x26, 0x2a, 0x16, 0xaa, 0xa2, 0x05, 0x6d, 0x97, 0x40, + 0x51, 0xc4, 0x61, 0xb7, 0x04, 0xc1, 0x01, 0xb8, 0xf4, 0x13, 0x55, 0xa5, 0x02, 0xb6, 0xa1, 0x88, + 0xe3, 0x36, 0x71, 0x53, 0xab, 0x5d, 0x7b, 0x89, 0x9d, 0xa0, 0x70, 0xea, 0x11, 0xf5, 0x1d, 0x7a, + 0x02, 0xf1, 0x10, 0x3c, 0x41, 0x8f, 0x1c, 0x39, 0x21, 0x9a, 0x27, 0x41, 0xb6, 0x77, 0xdb, 0x04, + 0xea, 0x96, 0x4a, 0x5c, 0x56, 0x33, 0xf6, 0x7f, 0x7e, 0x1e, 0xcf, 0xce, 0x18, 0x56, 0xdb, 0x44, + 0xec, 0x76, 0xb7, 0xfd, 0x26, 0x8b, 0x83, 0x26, 0xa3, 0x22, 0x22, 0x14, 0x77, 0x5a, 0xc3, 0x66, + 0x94, 0x90, 0x80, 0xe3, 0x4e, 0x8f, 0x34, 0x31, 0x0f, 0x38, 0x8d, 0x12, 0xbe, 0xcb, 0xc4, 0xa9, + 0xc1, 0xfd, 0xa4, 0xc3, 0x04, 0x43, 0x33, 0x67, 0x11, 0x7e, 0xef, 0x81, 0x9f, 0x6d, 0x3b, 0x37, + 0xda, 0xac, 0xcd, 0x94, 0x24, 0x90, 0x96, 0x56, 0x3b, 0x37, 0xdb, 0x8c, 0xb5, 0xf7, 0x71, 0xa0, + 0xbc, 0xed, 0xee, 0x4e, 0x80, 0xe3, 0x44, 0xf4, 0xd3, 0xcd, 0x67, 0xff, 0x94, 0x92, 0xe8, 0x27, + 0x98, 0x07, 0x31, 0xeb, 0x52, 0xa1, 0xbf, 0x3a, 0xba, 0xfa, 0x04, 0xca, 0xaf, 0x3a, 0x38, 0x89, + 0x3a, 0x38, 0xc4, 0xef, 0xbb, 0x98, 0x0b, 0x34, 0x0d, 0xf9, 0x3d, 0xdc, 0xaf, 0x58, 0x9e, 0x55, + 0x9b, 0x0c, 0xa5, 0x89, 0x66, 0xa0, 0x20, 0x05, 0x54, 0x54, 0xc6, 0xd4, 0x62, 0xea, 0x55, 0x6f, + 0x43, 0x69, 0x43, 0xa2, 0xb8, 0x31, 0xb4, 0xba, 0x0c, 0xe5, 0x4c, 0xc2, 0x13, 0x46, 0x39, 0x46, + 0x75, 0x28, 0xa8, 0xf3, 0x79, 0xc5, 0xf2, 0xf2, 0xb5, 0x62, 0xdd, 0xf1, 0x47, 0x4b, 0xa1, 0x12, + 0xf5, 0x55, 0x50, 0x98, 0x2a, 0xe5, 0x41, 0x21, 0x8e, 0x59, 0xcf, 0x9c, 0x63, 0xf5, 0x11, 0x94, + 0x96, 0x58, 0x1c, 0x13, 0x91, 0x49, 0x10, 0xd8, 0x34, 0x8a, 0x71, 0xaa, 0x51, 0x76, 0x16, 0x36, + 0x76, 0x16, 0x36, 0x0b, 0xc5, 0x4d, 0x11, 0x09, 0x33, 0xf7, 0xc0, 0x02, 0x7b, 0x8d, 0xee, 0xb0, + 0x73, 0x79, 0x86, 0xc2, 0xa0, 0x79, 0xb0, 0xf7, 0x08, 0x6d, 0x55, 0xf2, 0x9e, 0x55, 0x2b, 0xd7, + 0x6f, 0xf9, 0xe7, 0xff, 0x6c, 0x7f, 0x9d, 0xd0, 0x56, 0xa8, 0x94, 0xc8, 0x81, 0x89, 0x0e, 0x8e, + 0x5a, 0x8c, 0xee, 0xf7, 0x2b, 0xb6, 0x67, 0xd5, 0x26, 0xc2, 0x53, 0xbf, 0xba, 0x0a, 0x53, 0x3a, + 0xc7, 0xb4, 0x82, 0x8f, 0xc1, 0x26, 0x74, 0x87, 0xa9, 0x4c, 0x8a, 0x66, 0xba, 0xcc, 0x7a, 0xd1, + 0x3e, 0xfe, 0x39, 0x9b, 0x0b, 0x95, 0xbe, 0x5a, 0x82, 0xe2, 0x0b, 0xc2, 0xb3, 0xbb, 0x4a, 0xac, + 0x76, 0xff, 0xc2, 0xe6, 0xaf, 0x84, 0xf5, 0x60, 0xea, 0x0d, 0x8f, 0xda, 0x17, 0xfc, 0x9b, 0xa7, + 0x50, 0x4a, 0x15, 0xe9, 0x51, 0x08, 0x6c, 0x4e, 0x3e, 0xea, 0x5a, 0xe6, 0x43, 0x65, 0xcb, 0x5a, + 0x12, 0xca, 0x5a, 0x98, 0xab, 0x5a, 0xe6, 0xc3, 0xd4, 0xbb, 0x1f, 0x82, 0xbd, 0xae, 0x2b, 0x54, + 0x58, 0x58, 0x6a, 0xac, 0x6d, 0xad, 0x4c, 0xe7, 0x9c, 0xf2, 0xe1, 0x91, 0x07, 0x72, 0x75, 0xa1, + 0x29, 0x48, 0x0f, 0x23, 0x0f, 0x26, 0x97, 0x5e, 0x6e, 0x6c, 0xac, 0x35, 0x1a, 0x2b, 0xcb, 0xd3, + 0x96, 0x73, 0xfd, 0xf0, 0xc8, 0x2b, 0xc9, 0x6d, 0xdd, 0x11, 0x02, 0xb7, 0x9c, 0xa9, 0x4f, 0x9f, + 0xdd, 0xdc, 0xb7, 0x2f, 0xae, 0x62, 0xd5, 0xbf, 0x8e, 0xc3, 0xc4, 0x66, 0x7a, 0x21, 0xf4, 0x0e, + 0xae, 0xa5, 0x13, 0x80, 0xee, 0x99, 0x2e, 0x3d, 0x3a, 0x22, 0x8e, 0x51, 0xf7, 0x47, 0xaf, 0x6f, + 0x81, 0xbd, 0x45, 0xf0, 0x87, 0xff, 0xce, 0x7d, 0x0b, 0x05, 0xbd, 0x82, 0xe6, 0x2e, 0x8b, 0xb8, + 0x1a, 0xf8, 0x39, 0x14, 0x74, 0xcd, 0xcc, 0xe0, 0x91, 0x29, 0x73, 0x66, 0x7c, 0xfd, 0x34, 0xf9, + 0xd9, 0xd3, 0xe4, 0xaf, 0xc8, 0xa7, 0x49, 0x82, 0xf4, 0xc4, 0x9a, 0x41, 0x23, 0x13, 0x6d, 0x04, + 0xbd, 0x06, 0x5b, 0x36, 0x3f, 0xba, 0x63, 0xc2, 0x0c, 0x8d, 0xaf, 0x73, 0xf7, 0x62, 0x51, 0x7a, + 0xc9, 0x4d, 0xb0, 0x65, 0xe3, 0x9b, 0x91, 0x43, 0x53, 0x62, 0x46, 0x0e, 0xcf, 0xce, 0xbc, 0x85, + 0x1a, 0x30, 0xae, 0x7a, 0x1c, 0x19, 0x03, 0x86, 0x87, 0xc4, 0x99, 0xbb, 0x44, 0xa5, 0xb9, 0x8b, + 0x95, 0xe3, 0x13, 0x37, 0xf7, 0xe3, 0xc4, 0xcd, 0x1d, 0x0c, 0x5c, 0xeb, 0x78, 0xe0, 0x5a, 0xdf, + 0x07, 0xae, 0xf5, 0x6b, 0xe0, 0x5a, 0xdb, 0x05, 0x55, 0xa7, 0x87, 0xbf, 0x03, 0x00, 0x00, 0xff, + 0xff, 0xed, 0x08, 0xd9, 0xe9, 0x91, 0x06, 0x00, 0x00, +} diff --git a/api/services/snapshot/snapshots.proto b/api/services/snapshot/snapshots.proto new file mode 100644 index 000000000..76c27e4b1 --- /dev/null +++ b/api/services/snapshot/snapshots.proto @@ -0,0 +1,81 @@ +syntax = "proto3"; + +package containerd.v1.snapshot; + +import "gogoproto/gogo.proto"; +import "google/protobuf/empty.proto"; +import "github.com/containerd/containerd/api/types/mount/mount.proto"; + +// Snapshot service manages snapshots +service Snapshot { + rpc Prepare(PrepareRequest) returns (MountsResponse); + rpc View(PrepareRequest) returns (MountsResponse); + rpc Mounts(MountsRequest) returns (MountsResponse); + rpc Commit(CommitRequest) returns (google.protobuf.Empty); + rpc Remove(RemoveRequest) returns (google.protobuf.Empty); + rpc Stat(StatRequest) returns (StatResponse); + rpc List(ListRequest) returns (stream ListResponse); + rpc Usage(UsageRequest) returns (UsageResponse); + // "Snapshot" prepares a new set of mounts from existing name +} + +message PrepareRequest { + string key = 1; + string parent = 2; +} + +message MountsRequest { + string key = 1; +} + +message MountsResponse { + repeated containerd.v1.types.Mount mounts = 1; +} + +message RemoveRequest { + string key = 1; +} + +message CommitRequest { + string name = 1; + string key = 2; +} + +message StatRequest { + string key = 1; +} + +enum Kind { + option (gogoproto.goproto_enum_prefix) = false; + option (gogoproto.enum_customname) = "Kind"; + + ACTIVE = 0 [(gogoproto.enumvalue_customname) = "KindActive"]; + + COMMITTED = 1 [(gogoproto.enumvalue_customname) = "KindCommitted"]; +} + +message Info { + string name = 1; + string parent = 2; + Kind kind = 3; + bool readonly = 4; +} + +message StatResponse { + Info info = 1 [(gogoproto.nullable) = false]; +} + +message ListRequest{} + +message ListResponse { + repeated Info info = 1 [(gogoproto.nullable) = false]; +} + +message UsageRequest { + string key = 1; +} + +message UsageResponse { + int64 inodes = 2; + int64 size = 1; +} diff --git a/cmd/containerd/builtins.go b/cmd/containerd/builtins.go index 2888dd1d2..8124b592a 100644 --- a/cmd/containerd/builtins.go +++ b/cmd/containerd/builtins.go @@ -3,10 +3,11 @@ package main // register containerd builtins here import ( _ "github.com/containerd/containerd/services/content" + _ "github.com/containerd/containerd/services/diff" _ "github.com/containerd/containerd/services/execution" _ "github.com/containerd/containerd/services/healthcheck" _ "github.com/containerd/containerd/services/images" _ "github.com/containerd/containerd/services/metrics" - _ "github.com/containerd/containerd/services/rootfs" + _ "github.com/containerd/containerd/services/snapshot" _ "github.com/containerd/containerd/services/version" ) diff --git a/cmd/containerd/main.go b/cmd/containerd/main.go index e02349485..f2f5d81f3 100644 --- a/cmd/containerd/main.go +++ b/cmd/containerd/main.go @@ -18,9 +18,10 @@ import ( "github.com/Sirupsen/logrus" contentapi "github.com/containerd/containerd/api/services/content" + diffapi "github.com/containerd/containerd/api/services/diff" api "github.com/containerd/containerd/api/services/execution" imagesapi "github.com/containerd/containerd/api/services/images" - rootfsapi "github.com/containerd/containerd/api/services/rootfs" + snapshotapi "github.com/containerd/containerd/api/services/snapshot" versionapi "github.com/containerd/containerd/api/services/version" "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" @@ -417,14 +418,16 @@ func interceptor(ctx gocontext.Context, ctx = log.WithModule(ctx, "execution") case contentapi.ContentServer: ctx = log.WithModule(ctx, "content") - case rootfsapi.RootFSServer: - ctx = log.WithModule(ctx, "rootfs") case imagesapi.ImagesServer: ctx = log.WithModule(ctx, "images") case grpc_health_v1.HealthServer: // No need to change the context case versionapi.VersionServer: ctx = log.WithModule(ctx, "version") + case snapshotapi.SnapshotServer: + ctx = log.WithModule(ctx, "snapshot") + case diffapi.DiffServer: + ctx = log.WithModule(ctx, "diff") default: log.G(ctx).Warnf("unknown GRPC server type: %#v\n", info.Server) } diff --git a/cmd/ctr/run.go b/cmd/ctr/run.go index fe9a25aa4..0f9d479a7 100644 --- a/cmd/ctr/run.go +++ b/cmd/ctr/run.go @@ -7,14 +7,13 @@ import ( "os" "runtime" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "github.com/Sirupsen/logrus" "github.com/containerd/console" + "github.com/containerd/containerd" "github.com/containerd/containerd/api/services/execution" - rootfsapi "github.com/containerd/containerd/api/services/rootfs" + mounttypes "github.com/containerd/containerd/api/types/mount" "github.com/containerd/containerd/images" + "github.com/containerd/containerd/snapshot" "github.com/opencontainers/image-spec/identity" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" @@ -59,7 +58,7 @@ var runCommand = cli.Command{ Action: func(context *cli.Context) error { var ( err error - resp *rootfsapi.MountResponse + mounts []containerd.Mount imageConfig ocispec.Image ctx = gocontext.Background() @@ -87,7 +86,7 @@ var runCommand = cli.Command{ return err } - rootfsClient, err := getRootFSService(context) + snapshotter, err := getSnapshotter(context) if err != nil { return err } @@ -111,20 +110,15 @@ var runCommand = cli.Command{ return err } - if _, err := rootfsClient.Prepare(gocontext.TODO(), &rootfsapi.PrepareRequest{ - Name: id, - ChainID: identity.ChainID(diffIDs), - }); err != nil { - if grpc.Code(err) != codes.AlreadyExists { + mounts, err = snapshotter.Prepare(ctx, id, identity.ChainID(diffIDs).String()) + if err != nil { + if !snapshot.IsExist(err) { + return err + } + mounts, err = snapshotter.Mounts(ctx, id) + if err != nil { return err } - } - - resp, err = rootfsClient.Mounts(gocontext.TODO(), &rootfsapi.MountsRequest{ - Name: id, - }) - if err != nil { - return err } ic, err := image.Config(ctx, content) @@ -153,8 +147,13 @@ var runCommand = cli.Command{ if err != nil { return err } - if resp != nil { - create.Rootfs = resp.Mounts + for _, m := range mounts { + create.Rootfs = append(create.Rootfs, &mounttypes.Mount{ + Type: m.Type, + Source: m.Source, + Options: m.Options, + }) + } var con console.Console if create.Terminal { diff --git a/cmd/ctr/utils.go b/cmd/ctr/utils.go index 36ce2dd27..9db0296ea 100644 --- a/cmd/ctr/utils.go +++ b/cmd/ctr/utils.go @@ -15,13 +15,15 @@ import ( contentapi "github.com/containerd/containerd/api/services/content" "github.com/containerd/containerd/api/services/execution" imagesapi "github.com/containerd/containerd/api/services/images" - rootfsapi "github.com/containerd/containerd/api/services/rootfs" + snapshotapi "github.com/containerd/containerd/api/services/snapshot" versionservice "github.com/containerd/containerd/api/services/version" "github.com/containerd/containerd/api/types/container" "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" contentservice "github.com/containerd/containerd/services/content" imagesservice "github.com/containerd/containerd/services/images" + snapshotservice "github.com/containerd/containerd/services/snapshot" + "github.com/containerd/containerd/snapshot" "github.com/urfave/cli" "google.golang.org/grpc" ) @@ -44,12 +46,12 @@ func getContentStore(context *cli.Context) (content.Store, error) { return contentservice.NewStoreFromClient(contentapi.NewContentClient(conn)), nil } -func getRootFSService(context *cli.Context) (rootfsapi.RootFSClient, error) { +func getSnapshotter(context *cli.Context) (snapshot.Snapshotter, error) { conn, err := getGRPCConnection(context) if err != nil { return nil, err } - return rootfsapi.NewRootFSClient(conn), nil + return snapshotservice.NewSnapshotterFromClient(snapshotapi.NewSnapshotClient(conn)), nil } func getImageStore(clicontext *cli.Context) (images.Store, error) { diff --git a/cmd/dist/common.go b/cmd/dist/common.go index 34abc2b76..fb5bdb3ee 100644 --- a/cmd/dist/common.go +++ b/cmd/dist/common.go @@ -4,6 +4,7 @@ import ( "bufio" "context" "crypto/tls" + "encoding/json" "fmt" "net" "net/http" @@ -18,8 +19,10 @@ import ( "github.com/containerd/containerd/images" "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes/docker" + "github.com/containerd/containerd/rootfs" contentservice "github.com/containerd/containerd/services/content" imagesservice "github.com/containerd/containerd/services/images" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" "github.com/urfave/cli" "google.golang.org/grpc" @@ -151,3 +154,36 @@ func passwordPrompt() (string, error) { } return string(line), nil } + +func getImageLayers(ctx context.Context, image images.Image, cs content.Store) ([]rootfs.Layer, error) { + p, err := content.ReadBlob(ctx, cs, image.Target.Digest) + if err != nil { + return nil, errors.Wrapf(err, "failed to read manifest blob") + } + + var manifest ocispec.Manifest + if err := json.Unmarshal(p, &manifest); err != nil { + return nil, errors.Wrap(err, "failed to unmarshal manifest") + } + + diffIDs, err := image.RootFS(ctx, cs) + if err != nil { + return nil, errors.Wrap(err, "failed to resolve rootfs") + } + + if len(diffIDs) != len(manifest.Layers) { + return nil, errors.Errorf("mismatched image rootfs and manifest layers") + } + + layers := make([]rootfs.Layer, len(diffIDs)) + for i := range diffIDs { + layers[i].Diff = ocispec.Descriptor{ + // TODO: derive media type from compressed type + MediaType: ocispec.MediaTypeImageLayer, + Digest: diffIDs[i], + } + layers[i].Blob = manifest.Layers[i] + } + + return layers, nil +} diff --git a/cmd/dist/pull.go b/cmd/dist/pull.go index 50791081d..1b834f37e 100644 --- a/cmd/dist/pull.go +++ b/cmd/dist/pull.go @@ -2,19 +2,19 @@ package main import ( "context" - "encoding/json" "os" "text/tabwriter" "time" - rootfsapi "github.com/containerd/containerd/api/services/rootfs" - "github.com/containerd/containerd/content" + diffapi "github.com/containerd/containerd/api/services/diff" + snapshotapi "github.com/containerd/containerd/api/services/snapshot" "github.com/containerd/containerd/images" "github.com/containerd/containerd/log" "github.com/containerd/containerd/progress" "github.com/containerd/containerd/remotes" - rootfsservice "github.com/containerd/containerd/services/rootfs" - "github.com/opencontainers/image-spec/identity" + "github.com/containerd/containerd/rootfs" + diffservice "github.com/containerd/containerd/services/diff" + snapshotservice "github.com/containerd/containerd/services/snapshot" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/urfave/cli" "golang.org/x/sync/errgroup" @@ -101,43 +101,31 @@ command. As part of this process, we do the following: // TODO(stevvooe): This section unpacks the layers and resolves the // root filesystem chainid for the image. For now, we just print // it, but we should keep track of this in the metadata storage. - image, err := imageStore.Get(ctx, resolvedImageName) if err != nil { - log.G(ctx).Fatal(err) + log.G(ctx).WithError(err).Fatal("Failed to get image") } - p, err := content.ReadBlob(ctx, cs, image.Target.Digest) + layers, err := getImageLayers(ctx, image, cs) if err != nil { - log.G(ctx).Fatal(err) - } - - var manifest ocispec.Manifest - if err := json.Unmarshal(p, &manifest); err != nil { - log.G(ctx).Fatal(err) + log.G(ctx).WithError(err).Fatal("Failed to get rootfs layers") } conn, err := connectGRPC(clicontext) if err != nil { log.G(ctx).Fatal(err) } - rootfs := rootfsservice.NewUnpackerFromClient(rootfsapi.NewRootFSClient(conn)) + snapshotter := snapshotservice.NewSnapshotterFromClient(snapshotapi.NewSnapshotClient(conn)) + applier := diffservice.NewApplierFromClient(diffapi.NewDiffClient(conn)) log.G(ctx).Info("unpacking rootfs") - chainID, err := rootfs.Unpack(ctx, manifest.Layers) + + chainID, err := rootfs.ApplyLayers(ctx, layers, snapshotter, applier) if err != nil { log.G(ctx).Fatal(err) } - diffIDs, err := image.RootFS(ctx, cs) - if err != nil { - log.G(ctx).WithError(err).Fatal("failed resolving rootfs") - } - - expectedChainID := identity.ChainID(diffIDs) - if expectedChainID != chainID { - log.G(ctx).Fatal("rootfs service did not match chainid") - } + log.G(ctx).Infof("Unpacked chain id: %s", chainID) }() var ( diff --git a/cmd/dist/rootfs.go b/cmd/dist/rootfs.go index 0e97da8ca..70a7b5706 100644 --- a/cmd/dist/rootfs.go +++ b/cmd/dist/rootfs.go @@ -1,17 +1,17 @@ package main import ( - "context" - "encoding/json" "fmt" - "io/ioutil" "os" "strings" - rootfsapi "github.com/containerd/containerd/api/services/rootfs" - "github.com/containerd/containerd/content" + diffapi "github.com/containerd/containerd/api/services/diff" + snapshotapi "github.com/containerd/containerd/api/services/snapshot" + "github.com/containerd/containerd/images" "github.com/containerd/containerd/log" - rootfsservice "github.com/containerd/containerd/services/rootfs" + "github.com/containerd/containerd/rootfs" + diffservice "github.com/containerd/containerd/services/diff" + snapshotservice "github.com/containerd/containerd/services/snapshot" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/urfave/cli" @@ -42,23 +42,32 @@ var rootfsUnpackCommand = cli.Command{ log.G(ctx).Infof("unpacking layers from manifest %s", dgst.String()) - conn, err := connectGRPC(clicontext) - if err != nil { - return err - } - cs, err := resolveContentStore(clicontext) if err != nil { return err } - m, err := resolveManifest(ctx, cs, dgst) - if err != nil { - return err + image := images.Image{ + Target: ocispec.Descriptor{ + MediaType: ocispec.MediaTypeImageManifest, + Digest: dgst, + }, } - unpacker := rootfsservice.NewUnpackerFromClient(rootfsapi.NewRootFSClient(conn)) - chainID, err := unpacker.Unpack(ctx, m.Layers) + layers, err := getImageLayers(ctx, image, cs) + if err != nil { + log.G(ctx).WithError(err).Fatal("Failed to get rootfs layers") + } + + conn, err := connectGRPC(clicontext) + if err != nil { + log.G(ctx).Fatal(err) + } + + snapshotter := snapshotservice.NewSnapshotterFromClient(snapshotapi.NewSnapshotClient(conn)) + applier := diffservice.NewApplierFromClient(diffapi.NewDiffClient(conn)) + + chainID, err := rootfs.ApplyLayers(ctx, layers, snapshotter, applier) if err != nil { return err } @@ -95,48 +104,17 @@ var rootfsPrepareCommand = cli.Command{ return err } - rclient := rootfsapi.NewRootFSClient(conn) + snapshotter := snapshotservice.NewSnapshotterFromClient(snapshotapi.NewSnapshotClient(conn)) - ir := &rootfsapi.PrepareRequest{ - Name: target, - ChainID: dgst, - } - - resp, err := rclient.Prepare(ctx, ir) + mounts, err := snapshotter.Prepare(ctx, target, dgst.String()) if err != nil { return err } - for _, m := range resp.Mounts { + for _, m := range mounts { fmt.Fprintf(os.Stdout, "mount -t %s %s %s -o %s\n", m.Type, m.Source, target, strings.Join(m.Options, ",")) } return nil }, } - -func resolveManifest(ctx context.Context, provider content.Provider, dgst digest.Digest) (ocispec.Manifest, error) { - p, err := readAll(ctx, provider, dgst) - if err != nil { - return ocispec.Manifest{}, err - } - - // TODO(stevvooe): This assumption that we get a manifest is unfortunate. - // Need to provide way to resolve what the type of the target is. - var manifest ocispec.Manifest - if err := json.Unmarshal(p, &manifest); err != nil { - return ocispec.Manifest{}, err - } - - return manifest, nil -} - -func readAll(ctx context.Context, provider content.Provider, dgst digest.Digest) ([]byte, error) { - rc, err := provider.Reader(ctx, dgst) - if err != nil { - return nil, err - } - defer rc.Close() - - return ioutil.ReadAll(rc) -} diff --git a/rootfs/apply.go b/rootfs/apply.go index b846adab8..bedd16f0d 100644 --- a/rootfs/apply.go +++ b/rootfs/apply.go @@ -2,13 +2,9 @@ package rootfs import ( "context" - "io" - "io/ioutil" - "os" + "fmt" "github.com/containerd/containerd" - "github.com/containerd/containerd/archive" - "github.com/containerd/containerd/archive/compression" "github.com/containerd/containerd/log" "github.com/containerd/containerd/snapshot" "github.com/opencontainers/go-digest" @@ -17,134 +13,72 @@ import ( "github.com/pkg/errors" ) -type Unpacker interface { - Unpack(ctx context.Context, layers []ocispec.Descriptor) (digest.Digest, error) +type Applier interface { + Apply(context.Context, ocispec.Descriptor, []containerd.Mount) (ocispec.Descriptor, error) } -type Mounter interface { - Mount(target string, mounts ...containerd.Mount) error - Unmount(target string) error +type Layer struct { + Diff ocispec.Descriptor + Blob ocispec.Descriptor } -// ApplyLayer applies the layer to the provided parent. The resulting snapshot -// will be stored under its ChainID. -// -// The parent *must* be the chainID of the parent layer. -// -// The returned digest is the diffID for the applied layer. -func ApplyLayer(snapshots snapshot.Snapshotter, mounter Mounter, rd io.Reader, parent digest.Digest) (digest.Digest, error) { - ctx := context.TODO() - - // create a temporary directory to work from, needs to be on same - // filesystem. Probably better if this shared but we'll use a tempdir, for - // now. - dir, err := ioutil.TempDir("", "unpack-") - if err != nil { - return "", errors.Wrapf(err, "creating temporary directory failed") - } - defer os.RemoveAll(dir) - - // TODO(stevvooe): Choose this key WAY more carefully. We should be able to - // create collisions for concurrent, conflicting unpack processes but we - // would need to have it be a function of the parent diffID and child - // layerID (since we don't know the diffID until we are done!). - key := dir - - mounts, err := snapshots.Prepare(ctx, key, parent.String()) - if err != nil { - return "", err - } - - if err := mounter.Mount(dir, mounts...); err != nil { - if err := snapshots.Remove(ctx, key); err != nil { - log.L.WithError(err).Error("snapshot rollback failed") +func ApplyLayers(ctx context.Context, layers []Layer, sn snapshot.Snapshotter, a Applier) (digest.Digest, error) { + var chain []digest.Digest + for _, layer := range layers { + if err := applyLayer(ctx, layer, chain, sn, a); err != nil { + // TODO: possibly wait and retry if extraction of same chain id was in progress + return "", err } - return "", err + + chain = append(chain, layer.Diff.Digest) } - defer mounter.Unmount(dir) - - rd, err = compression.DecompressStream(rd) - if err != nil { - return "", err - } - - digester := digest.Canonical.Digester() // used to calculate diffID. - rd = io.TeeReader(rd, digester.Hash()) - - if _, err := archive.Apply(context.Background(), dir, rd); err != nil { - return "", err - } - - diffID := digester.Digest() - - chainID := diffID - if parent != "" { - chainID = identity.ChainID([]digest.Digest{parent, chainID}) - } - if _, err := snapshots.Stat(ctx, chainID.String()); err == nil { - return diffID, snapshots.Remove(ctx, key) - } - - return diffID, snapshots.Commit(ctx, chainID.String(), key) + return identity.ChainID(chain), nil } -// Prepare the root filesystem from the set of layers. Snapshots are created -// for each layer if they don't exist, keyed by their chain id. If the snapshot -// already exists, it will be skipped. -// -// If successful, the chainID for the top-level layer is returned. That -// identifier can be used to check out a snapshot. -func Prepare(ctx context.Context, snapshots snapshot.Snapshotter, mounter Mounter, layers []ocispec.Descriptor, - // TODO(stevvooe): The following functions are candidate for internal - // object functions. We can use these to formulate the beginnings of a - // rootfs Controller. - // - // Just pass them in for now. - openBlob func(context.Context, digest.Digest) (io.ReadCloser, error), - resolveDiffID func(digest.Digest) digest.Digest, - registerDiffID func(diffID, dgst digest.Digest) error) (digest.Digest, error) { +func applyLayer(ctx context.Context, layer Layer, chain []digest.Digest, sn snapshot.Snapshotter, a Applier) error { var ( - parent digest.Digest - chain []digest.Digest + parent = identity.ChainID(chain) + chainID = identity.ChainID(append(chain, layer.Diff.Digest)) + diff ocispec.Descriptor ) - for _, layer := range layers { - // This will convert a possibly compressed layer hash to the - // uncompressed hash, if we know about it. If we don't, we unpack and - // calculate it. If we do have it, we then calculate the chain id for - // the application and see if the snapshot is there. - diffID := resolveDiffID(layer.Digest) - if diffID != "" { - chainLocal := append(chain, diffID) - chainID := identity.ChainID(chainLocal) - - if _, err := snapshots.Stat(ctx, chainID.String()); err == nil { - continue - } - } - - rc, err := openBlob(ctx, layer.Digest) - if err != nil { - return "", err - } - defer rc.Close() // pretty lazy! - - diffID, err = ApplyLayer(snapshots, mounter, rc, parent) - if err != nil { - return "", err - } - - // Register the association between the diffID and the layer's digest. - // For uncompressed layers, this will be the same. For compressed - // layers, we can look up the diffID from the digest if we've already - // unpacked it. - if err := registerDiffID(diffID, layer.Digest); err != nil { - return "", err - } - - chain = append(chain, diffID) - parent = identity.ChainID(chain) + _, err := sn.Stat(ctx, chainID.String()) + if err == nil { + log.G(ctx).Debugf("Extraction not needed, layer snapshot exists") + return nil + } else if !snapshot.IsNotExist(err) { + return errors.Wrap(err, "failed to stat snapshot") } - return parent, nil + key := fmt.Sprintf("extract %s", chainID) + + // Prepare snapshot with from parent + mounts, err := sn.Prepare(ctx, key, parent.String()) + if err != nil { + //TODO: If is snapshot exists error, retry + return errors.Wrap(err, "failed to prepare extraction layer") + } + defer func() { + if err != nil { + log.G(ctx).WithError(err).WithField("key", key).Infof("Apply failure, attempting cleanup") + if rerr := sn.Remove(ctx, key); rerr != nil { + log.G(ctx).WithError(rerr).Warnf("Extraction snapshot %q removal failed: %v", key) + } + } + }() + + diff, err = a.Apply(ctx, layer.Blob, mounts) + if err != nil { + return errors.Wrapf(err, "failed to extract layer %s", layer.Diff.Digest) + } + if diff.Digest != layer.Diff.Digest { + err = errors.Errorf("wrong diff id calculated on extraction %q", diff.Digest) + return err + } + + if err = sn.Commit(ctx, chainID.String(), key); err != nil { + return errors.Wrapf(err, "failed to commit snapshot %s", parent) + } + + return nil } diff --git a/rootfs/init.go b/rootfs/init.go index 076ed6e92..2ef411632 100644 --- a/rootfs/init.go +++ b/rootfs/init.go @@ -19,6 +19,11 @@ var ( type initializerFunc func(string) error +type Mounter interface { + Mount(target string, mounts ...containerd.Mount) error + Unmount(target string) error +} + func InitRootFS(ctx context.Context, name string, parent digest.Digest, readonly bool, snapshotter snapshot.Snapshotter, mounter Mounter) ([]containerd.Mount, error) { _, err := snapshotter.Stat(ctx, name) if err == nil { diff --git a/services/diff/client.go b/services/diff/client.go new file mode 100644 index 000000000..a64e0407a --- /dev/null +++ b/services/diff/client.go @@ -0,0 +1,56 @@ +package diff + +import ( + "context" + + "github.com/containerd/containerd" + diffapi "github.com/containerd/containerd/api/services/diff" + "github.com/containerd/containerd/api/types/descriptor" + mounttypes "github.com/containerd/containerd/api/types/mount" + "github.com/containerd/containerd/rootfs" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" +) + +// NewApplierFromClient returns a new Applier which communicates +// over a GRPC connection. +func NewApplierFromClient(client diffapi.DiffClient) rootfs.Applier { + return &remoteApplier{ + client: client, + } +} + +type remoteApplier struct { + client diffapi.DiffClient +} + +func (r *remoteApplier) Apply(ctx context.Context, diff ocispec.Descriptor, mounts []containerd.Mount) (ocispec.Descriptor, error) { + req := &diffapi.ApplyRequest{ + Diff: fromDescriptor(diff), + Mounts: fromMounts(mounts), + } + resp, err := r.client.Apply(ctx, req) + if err != nil { + return ocispec.Descriptor{}, err + } + return toDescriptor(resp.Applied), nil +} + +func fromDescriptor(d ocispec.Descriptor) *descriptor.Descriptor { + return &descriptor.Descriptor{ + MediaType: d.MediaType, + Digest: d.Digest, + Size_: d.Size, + } +} + +func fromMounts(mounts []containerd.Mount) []*mounttypes.Mount { + apiMounts := make([]*mounttypes.Mount, len(mounts)) + for i, m := range mounts { + apiMounts[i] = &mounttypes.Mount{ + Type: m.Type, + Source: m.Source, + Options: m.Options, + } + } + return apiMounts +} diff --git a/services/diff/service.go b/services/diff/service.go new file mode 100644 index 000000000..1c1d16197 --- /dev/null +++ b/services/diff/service.go @@ -0,0 +1,138 @@ +package diff + +import ( + "io" + "io/ioutil" + "os" + + "github.com/containerd/containerd" + diffapi "github.com/containerd/containerd/api/services/diff" + "github.com/containerd/containerd/api/types/descriptor" + mounttypes "github.com/containerd/containerd/api/types/mount" + "github.com/containerd/containerd/archive" + "github.com/containerd/containerd/archive/compression" + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/plugin" + "github.com/containerd/containerd/snapshot" + digest "github.com/opencontainers/go-digest" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/pkg/errors" + "golang.org/x/net/context" + "google.golang.org/grpc" +) + +func init() { + plugin.Register("diff-grpc", &plugin.Registration{ + Type: plugin.GRPCPlugin, + Init: func(ic *plugin.InitContext) (interface{}, error) { + return newService(ic.Content, ic.Snapshotter) + }, + }) +} + +type service struct { + store content.Store + snapshotter snapshot.Snapshotter +} + +func newService(store content.Store, snapshotter snapshot.Snapshotter) (*service, error) { + return &service{ + store: store, + snapshotter: snapshotter, + }, nil +} + +func (s *service) Register(gs *grpc.Server) error { + diffapi.RegisterDiffServer(gs, s) + return nil +} + +func (s *service) Apply(ctx context.Context, er *diffapi.ApplyRequest) (*diffapi.ApplyResponse, error) { + desc := toDescriptor(er.Diff) + // TODO: Check for supported media types + + mounts := toMounts(er.Mounts) + + dir, err := ioutil.TempDir("", "extract-") + if err != nil { + return nil, errors.Wrap(err, "failed to create temporary directory") + } + defer os.RemoveAll(dir) + + if err := containerd.MountAll(mounts, dir); err != nil { + return nil, errors.Wrap(err, "failed to mount") + } + defer containerd.Unmount(dir, 0) + + r, err := s.store.Reader(ctx, desc.Digest) + if err != nil { + return nil, errors.Wrap(err, "failed to get reader from content store") + } + defer r.Close() + + // TODO: only decompress stream if media type is compressed + ds, err := compression.DecompressStream(r) + if err != nil { + return nil, err + } + defer ds.Close() + + digester := digest.Canonical.Digester() + rc := &readCounter{ + r: io.TeeReader(ds, digester.Hash()), + } + + if _, err := archive.Apply(ctx, dir, rc); err != nil { + return nil, err + } + + // Read any trailing data + if _, err := io.Copy(ioutil.Discard, rc); err != nil { + return nil, err + } + + resp := &diffapi.ApplyResponse{ + Applied: &descriptor.Descriptor{ + MediaType: ocispec.MediaTypeImageLayer, + Digest: digester.Digest(), + Size_: rc.c, + }, + } + + return resp, nil +} + +func (s *service) Diff(context.Context, *diffapi.DiffRequest) (*diffapi.DiffResponse, error) { + return nil, errors.New("not implemented") +} + +type readCounter struct { + r io.Reader + c int64 +} + +func (rc *readCounter) Read(p []byte) (n int, err error) { + n, err = rc.r.Read(p) + rc.c += int64(n) + return +} + +func toDescriptor(d *descriptor.Descriptor) ocispec.Descriptor { + return ocispec.Descriptor{ + MediaType: d.MediaType, + Digest: d.Digest, + Size: d.Size_, + } +} + +func toMounts(apim []*mounttypes.Mount) []containerd.Mount { + mounts := make([]containerd.Mount, len(apim)) + for i, m := range apim { + mounts[i] = containerd.Mount{ + Type: m.Type, + Source: m.Source, + Options: m.Options, + } + } + return mounts +} diff --git a/services/rootfs/preparer.go b/services/rootfs/preparer.go deleted file mode 100644 index baeb194e0..000000000 --- a/services/rootfs/preparer.go +++ /dev/null @@ -1,39 +0,0 @@ -package rootfs - -import ( - "context" - - rootfsapi "github.com/containerd/containerd/api/services/rootfs" - containerd_v1_types "github.com/containerd/containerd/api/types/descriptor" - "github.com/containerd/containerd/rootfs" - digest "github.com/opencontainers/go-digest" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" -) - -func NewUnpackerFromClient(client rootfsapi.RootFSClient) rootfs.Unpacker { - return remoteUnpacker{ - client: client, - } -} - -type remoteUnpacker struct { - client rootfsapi.RootFSClient -} - -func (rp remoteUnpacker) Unpack(ctx context.Context, layers []ocispec.Descriptor) (digest.Digest, error) { - pr := rootfsapi.UnpackRequest{ - Layers: make([]*containerd_v1_types.Descriptor, len(layers)), - } - for i, l := range layers { - pr.Layers[i] = &containerd_v1_types.Descriptor{ - MediaType: l.MediaType, - Digest: l.Digest, - Size_: l.Size, - } - } - resp, err := rp.client.Unpack(ctx, &pr) - if err != nil { - return "", err - } - return resp.ChainID, nil -} diff --git a/services/rootfs/service.go b/services/rootfs/service.go deleted file mode 100644 index 685de5b4a..000000000 --- a/services/rootfs/service.go +++ /dev/null @@ -1,114 +0,0 @@ -package rootfs - -import ( - "github.com/containerd/containerd" - rootfsapi "github.com/containerd/containerd/api/services/rootfs" - containerd_v1_types "github.com/containerd/containerd/api/types/mount" - "github.com/containerd/containerd/content" - "github.com/containerd/containerd/log" - "github.com/containerd/containerd/plugin" - "github.com/containerd/containerd/rootfs" - "github.com/containerd/containerd/snapshot" - digest "github.com/opencontainers/go-digest" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "golang.org/x/net/context" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" -) - -func init() { - plugin.Register("rootfs-grpc", &plugin.Registration{ - Type: plugin.GRPCPlugin, - Init: func(ic *plugin.InitContext) (interface{}, error) { - return NewService(ic.Content, ic.Snapshotter) - }, - }) -} - -type Service struct { - store content.Store - snapshotter snapshot.Snapshotter -} - -func NewService(store content.Store, snapshotter snapshot.Snapshotter) (*Service, error) { - return &Service{ - store: store, - snapshotter: snapshotter, - }, nil -} - -func (s *Service) Register(gs *grpc.Server) error { - rootfsapi.RegisterRootFSServer(gs, s) - return nil -} - -func (s *Service) Unpack(ctx context.Context, pr *rootfsapi.UnpackRequest) (*rootfsapi.UnpackResponse, error) { - layers := make([]ocispec.Descriptor, len(pr.Layers)) - for i, l := range pr.Layers { - layers[i] = ocispec.Descriptor{ - MediaType: l.MediaType, - Digest: l.Digest, - Size: l.Size_, - } - } - log.G(ctx).Infof("Preparing %#v", layers) - chainID, err := rootfs.Prepare(ctx, s.snapshotter, mounter{}, layers, s.store.Reader, emptyResolver, noopRegister) - if err != nil { - log.G(ctx).Errorf("Rootfs Prepare failed!: %v", err) - return nil, err - } - log.G(ctx).Infof("ChainID %#v", chainID) - return &rootfsapi.UnpackResponse{ - ChainID: chainID, - }, nil -} - -func (s *Service) Prepare(ctx context.Context, ir *rootfsapi.PrepareRequest) (*rootfsapi.MountResponse, error) { - mounts, err := rootfs.InitRootFS(ctx, ir.Name, ir.ChainID, ir.Readonly, s.snapshotter, mounter{}) - if err != nil { - return nil, grpc.Errorf(codes.AlreadyExists, "%v", err) - } - return &rootfsapi.MountResponse{ - Mounts: apiMounts(mounts), - }, nil -} - -func (s *Service) Mounts(ctx context.Context, mr *rootfsapi.MountsRequest) (*rootfsapi.MountResponse, error) { - mounts, err := s.snapshotter.Mounts(ctx, mr.Name) - if err != nil { - return nil, err - } - return &rootfsapi.MountResponse{ - Mounts: apiMounts(mounts), - }, nil -} - -func apiMounts(mounts []containerd.Mount) []*containerd_v1_types.Mount { - am := make([]*containerd_v1_types.Mount, len(mounts)) - for i, m := range mounts { - am[i] = &containerd_v1_types.Mount{ - Type: m.Type, - Source: m.Source, - Options: m.Options, - } - } - return am -} - -type mounter struct{} - -func (mounter) Mount(dir string, mounts ...containerd.Mount) error { - return containerd.MountAll(mounts, dir) -} - -func (mounter) Unmount(dir string) error { - return containerd.Unmount(dir, 0) -} - -func emptyResolver(digest.Digest) digest.Digest { - return digest.Digest("") -} - -func noopRegister(digest.Digest, digest.Digest) error { - return nil -} diff --git a/services/snapshot/client.go b/services/snapshot/client.go new file mode 100644 index 000000000..ff30cd76c --- /dev/null +++ b/services/snapshot/client.go @@ -0,0 +1,158 @@ +package snapshot + +import ( + "context" + "io" + "strings" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + + "github.com/containerd/containerd" + snapshotapi "github.com/containerd/containerd/api/services/snapshot" + "github.com/containerd/containerd/snapshot" + "github.com/pkg/errors" +) + +// NewSnapshotterFromClient returns a new Snapshotter which communicates +// over a GRPC connection. +func NewSnapshotterFromClient(client snapshotapi.SnapshotClient) snapshot.Snapshotter { + return &remoteSnapshotter{ + client: client, + } +} + +type remoteSnapshotter struct { + client snapshotapi.SnapshotClient +} + +func (r *remoteSnapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { + resp, err := r.client.Stat(ctx, &snapshotapi.StatRequest{Key: key}) + if err != nil { + return snapshot.Info{}, rewriteGRPCError(err) + } + return toInfo(resp.Info), nil +} + +func (r *remoteSnapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { + resp, err := r.client.Usage(ctx, &snapshotapi.UsageRequest{Key: key}) + if err != nil { + return snapshot.Usage{}, rewriteGRPCError(err) + } + return toUsage(resp), nil +} + +func (r *remoteSnapshotter) Mounts(ctx context.Context, key string) ([]containerd.Mount, error) { + resp, err := r.client.Mounts(ctx, &snapshotapi.MountsRequest{Key: key}) + if err != nil { + return nil, rewriteGRPCError(err) + } + return toMounts(resp), nil +} + +func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string) ([]containerd.Mount, error) { + resp, err := r.client.Prepare(ctx, &snapshotapi.PrepareRequest{Key: key, Parent: parent}) + if err != nil { + return nil, rewriteGRPCError(err) + } + return toMounts(resp), nil +} + +func (r *remoteSnapshotter) View(ctx context.Context, key, parent string) ([]containerd.Mount, error) { + resp, err := r.client.View(ctx, &snapshotapi.PrepareRequest{Key: key, Parent: parent}) + if err != nil { + return nil, rewriteGRPCError(err) + } + return toMounts(resp), nil +} + +func (r *remoteSnapshotter) Commit(ctx context.Context, name, key string) error { + _, err := r.client.Commit(ctx, &snapshotapi.CommitRequest{ + Name: name, + Key: key, + }) + return rewriteGRPCError(err) +} + +func (r *remoteSnapshotter) Remove(ctx context.Context, key string) error { + _, err := r.client.Remove(ctx, &snapshotapi.RemoveRequest{Key: key}) + return rewriteGRPCError(err) +} + +func (r *remoteSnapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { + sc, err := r.client.List(ctx, &snapshotapi.ListRequest{}) + if err != nil { + rewriteGRPCError(err) + } + for { + resp, err := sc.Recv() + if err != nil { + if err == io.EOF { + return nil + } + return rewriteGRPCError(err) + } + if resp == nil { + return nil + } + for _, info := range resp.Info { + if err := fn(ctx, toInfo(info)); err != nil { + return err + } + } + } +} + +func rewriteGRPCError(err error) error { + switch grpc.Code(errors.Cause(err)) { + case codes.AlreadyExists: + return snapshot.ErrSnapshotExist + case codes.NotFound: + return snapshot.ErrSnapshotNotExist + case codes.FailedPrecondition: + desc := grpc.ErrorDesc(errors.Cause(err)) + if strings.Contains(desc, snapshot.ErrSnapshotNotActive.Error()) { + return snapshot.ErrSnapshotNotActive + } + if strings.Contains(desc, snapshot.ErrSnapshotNotCommitted.Error()) { + return snapshot.ErrSnapshotNotCommitted + } + } + + return err +} + +func toKind(kind snapshotapi.Kind) snapshot.Kind { + if kind == snapshotapi.KindActive { + return snapshot.KindActive + } + return snapshot.KindCommitted +} + +func toInfo(info snapshotapi.Info) snapshot.Info { + return snapshot.Info{ + Name: info.Name, + Parent: info.Parent, + Kind: toKind(info.Kind), + Readonly: info.Readonly, + } +} + +func toUsage(resp *snapshotapi.UsageResponse) snapshot.Usage { + return snapshot.Usage{ + Inodes: resp.Inodes, + Size: resp.Size_, + } +} + +func toMounts(resp *snapshotapi.MountsResponse) []containerd.Mount { + mounts := make([]containerd.Mount, len(resp.Mounts)) + for i, m := range resp.Mounts { + mounts[i] = containerd.Mount{ + Type: m.Type, + Source: m.Source, + Options: m.Options, + } + } + return mounts +} diff --git a/services/snapshot/service.go b/services/snapshot/service.go new file mode 100644 index 000000000..4aff3c4c9 --- /dev/null +++ b/services/snapshot/service.go @@ -0,0 +1,204 @@ +package snapshot + +import ( + gocontext "context" + + "github.com/containerd/containerd" + snapshotapi "github.com/containerd/containerd/api/services/snapshot" + mounttypes "github.com/containerd/containerd/api/types/mount" + "github.com/containerd/containerd/log" + "github.com/containerd/containerd/plugin" + "github.com/containerd/containerd/snapshot" + protoempty "github.com/golang/protobuf/ptypes/empty" + "golang.org/x/net/context" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" +) + +func init() { + plugin.Register("snapshots-grpc", &plugin.Registration{ + Type: plugin.GRPCPlugin, + Init: func(ic *plugin.InitContext) (interface{}, error) { + return newService(ic.Snapshotter) + }, + }) +} + +var empty = &protoempty.Empty{} + +type service struct { + snapshotter snapshot.Snapshotter +} + +func newService(snapshotter snapshot.Snapshotter) (*service, error) { + return &service{ + snapshotter: snapshotter, + }, nil +} + +func (s *service) Register(gs *grpc.Server) error { + snapshotapi.RegisterSnapshotServer(gs, s) + return nil +} + +func (s *service) Prepare(ctx context.Context, pr *snapshotapi.PrepareRequest) (*snapshotapi.MountsResponse, error) { + log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("Preparing snapshot") + // TODO: Apply namespace + // TODO: Lookup snapshot id from metadata store + mounts, err := s.snapshotter.Prepare(ctx, pr.Key, pr.Parent) + if err != nil { + return nil, grpcError(err) + } + return fromMounts(mounts), nil +} + +func (s *service) View(ctx context.Context, pr *snapshotapi.PrepareRequest) (*snapshotapi.MountsResponse, error) { + log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("Preparing view snapshot") + // TODO: Apply namespace + // TODO: Lookup snapshot id from metadata store + mounts, err := s.snapshotter.View(ctx, pr.Key, pr.Parent) + if err != nil { + return nil, grpcError(err) + } + return fromMounts(mounts), nil +} + +func (s *service) Mounts(ctx context.Context, mr *snapshotapi.MountsRequest) (*snapshotapi.MountsResponse, error) { + log.G(ctx).WithField("key", mr.Key).Debugf("Getting snapshot mounts") + // TODO: Apply namespace + // TODO: Lookup snapshot id from metadata store + mounts, err := s.snapshotter.Mounts(ctx, mr.Key) + if err != nil { + return nil, grpcError(err) + } + return fromMounts(mounts), nil +} + +func (s *service) Commit(ctx context.Context, cr *snapshotapi.CommitRequest) (*protoempty.Empty, error) { + log.G(ctx).WithField("key", cr.Key).WithField("name", cr.Name).Debugf("Committing snapshot") + // TODO: Apply namespace + // TODO: Lookup snapshot id from metadata store + if err := s.snapshotter.Commit(ctx, cr.Name, cr.Key); err != nil { + return nil, grpcError(err) + } + return empty, nil +} + +func (s *service) Remove(ctx context.Context, rr *snapshotapi.RemoveRequest) (*protoempty.Empty, error) { + log.G(ctx).WithField("key", rr.Key).Debugf("Removing snapshot") + // TODO: Apply namespace + // TODO: Lookup snapshot id from metadata store + if err := s.snapshotter.Remove(ctx, rr.Key); err != nil { + return nil, grpcError(err) + } + return empty, nil +} + +func (s *service) Stat(ctx context.Context, sr *snapshotapi.StatRequest) (*snapshotapi.StatResponse, error) { + log.G(ctx).WithField("key", sr.Key).Debugf("Statting snapshot") + // TODO: Apply namespace + info, err := s.snapshotter.Stat(ctx, sr.Key) + if err != nil { + return nil, grpcError(err) + } + + return &snapshotapi.StatResponse{Info: fromInfo(info)}, nil +} + +func (s *service) List(sr *snapshotapi.ListRequest, ss snapshotapi.Snapshot_ListServer) error { + // TODO: Apply namespace + + var ( + buffer []snapshotapi.Info + sendBlock = func(block []snapshotapi.Info) error { + return ss.Send(&snapshotapi.ListResponse{ + Info: block, + }) + } + ) + err := s.snapshotter.Walk(ss.Context(), func(ctx gocontext.Context, info snapshot.Info) error { + buffer = append(buffer, fromInfo(info)) + + if len(buffer) >= 100 { + if err := sendBlock(buffer); err != nil { + return err + } + + buffer = buffer[:0] + } + + return nil + }) + if err != nil { + return err + } + if len(buffer) > 0 { + // Send remaining infos + if err := sendBlock(buffer); err != nil { + return err + } + } + + return nil +} + +func (s *service) Usage(ctx context.Context, ur *snapshotapi.UsageRequest) (*snapshotapi.UsageResponse, error) { + // TODO: Apply namespace + usage, err := s.snapshotter.Usage(ctx, ur.Key) + if err != nil { + return nil, grpcError(err) + } + + return fromUsage(usage), nil +} + +func grpcError(err error) error { + if snapshot.IsNotExist(err) { + return grpc.Errorf(codes.NotFound, err.Error()) + } + if snapshot.IsExist(err) { + return grpc.Errorf(codes.AlreadyExists, err.Error()) + } + if snapshot.IsNotActive(err) || snapshot.IsNotCommitted(err) { + return grpc.Errorf(codes.FailedPrecondition, err.Error()) + } + + return err +} + +func fromKind(kind snapshot.Kind) snapshotapi.Kind { + if kind == snapshot.KindActive { + return snapshotapi.KindActive + } + return snapshotapi.KindCommitted +} + +func fromInfo(info snapshot.Info) snapshotapi.Info { + return snapshotapi.Info{ + Name: info.Name, + Parent: info.Parent, + Kind: fromKind(info.Kind), + Readonly: info.Readonly, + } +} + +func fromUsage(usage snapshot.Usage) *snapshotapi.UsageResponse { + return &snapshotapi.UsageResponse{ + Inodes: usage.Inodes, + Size_: usage.Size, + } +} + +func fromMounts(mounts []containerd.Mount) *snapshotapi.MountsResponse { + resp := &snapshotapi.MountsResponse{ + Mounts: make([]*mounttypes.Mount, len(mounts)), + } + for i, m := range mounts { + resp.Mounts[i] = &mounttypes.Mount{ + Type: m.Type, + Source: m.Source, + Options: m.Options, + } + } + return resp +} diff --git a/snapshot/storage/proto/record.pb.go b/snapshot/storage/proto/record.pb.go index e8081c686..b42b674f6 100644 --- a/snapshot/storage/proto/record.pb.go +++ b/snapshot/storage/proto/record.pb.go @@ -63,7 +63,7 @@ func (Kind) EnumDescriptor() ([]byte, []int) { return fileDescriptorRecord, []in type Snapshot struct { ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` - Kind Kind `protobuf:"varint,4,opt,name=kind,proto3,enum=containerd.v1.Kind" json:"kind,omitempty"` + Kind Kind `protobuf:"varint,4,opt,name=kind,proto3,enum=containerd.snapshot.v1.Kind" json:"kind,omitempty"` Readonly bool `protobuf:"varint,5,opt,name=readonly,proto3" json:"readonly,omitempty"` // inodes stores the number inodes in use for the snapshot. // @@ -81,8 +81,8 @@ func (*Snapshot) ProtoMessage() {} func (*Snapshot) Descriptor() ([]byte, []int) { return fileDescriptorRecord, []int{0} } func init() { - proto1.RegisterType((*Snapshot)(nil), "containerd.v1.Snapshot") - proto1.RegisterEnum("containerd.v1.Kind", Kind_name, Kind_value) + proto1.RegisterType((*Snapshot)(nil), "containerd.snapshot.v1.Snapshot") + proto1.RegisterEnum("containerd.snapshot.v1.Kind", Kind_name, Kind_value) } func (m *Snapshot) Marshal() (dAtA []byte, err error) { size := m.Size() @@ -511,26 +511,26 @@ func init() { } var fileDescriptorRecord = []byte{ - // 330 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0xbd, 0x4e, 0xf3, 0x30, - 0x18, 0x85, 0xe3, 0x7c, 0xf9, 0x42, 0x6b, 0xd1, 0xaa, 0x18, 0x54, 0x59, 0x19, 0x8c, 0xc5, 0x42, - 0xc4, 0x90, 0x08, 0xb8, 0x82, 0xfe, 0x0d, 0x55, 0x55, 0x21, 0x85, 0x8a, 0x3d, 0x8d, 0xad, 0xd4, - 0x82, 0xda, 0x95, 0x63, 0x2a, 0xc1, 0xc4, 0x88, 0x7a, 0x0f, 0x9d, 0x60, 0xe3, 0x0e, 0xb8, 0x82, - 0x8e, 0x8c, 0x4c, 0x88, 0xe6, 0x4a, 0x50, 0xd2, 0x8a, 0x9f, 0xed, 0x9c, 0xe3, 0x47, 0x8f, 0xa5, - 0x17, 0x76, 0x53, 0x61, 0x26, 0xb7, 0xe3, 0x20, 0x51, 0xd3, 0x30, 0x51, 0xd2, 0xc4, 0x42, 0x72, - 0xcd, 0x7e, 0xc7, 0x4c, 0xc6, 0xb3, 0x6c, 0xa2, 0x4c, 0x98, 0x19, 0xa5, 0xe3, 0x94, 0x87, 0x33, - 0xad, 0x8c, 0x0a, 0x35, 0x4f, 0x94, 0x66, 0x41, 0x59, 0x50, 0xed, 0x87, 0x0f, 0xe6, 0xa7, 0xde, - 0x41, 0xaa, 0x52, 0xb5, 0xc1, 0x8a, 0xb4, 0x81, 0x8e, 0x5e, 0x00, 0xac, 0x5c, 0x6e, 0x65, 0xa8, - 0x09, 0x6d, 0xc1, 0x30, 0xa0, 0xc0, 0x77, 0xda, 0x6e, 0xfe, 0x71, 0x68, 0xf7, 0xbb, 0x91, 0x2d, - 0x18, 0x6a, 0x42, 0x77, 0x16, 0x6b, 0x2e, 0x0d, 0xb6, 0x29, 0xf0, 0xab, 0xd1, 0xb6, 0xa1, 0x63, - 0xe8, 0x5c, 0x0b, 0xc9, 0xb0, 0x43, 0x81, 0x5f, 0x3f, 0xdb, 0x0f, 0xfe, 0x7c, 0x18, 0x0c, 0x84, - 0x64, 0x51, 0x09, 0x20, 0x0f, 0x56, 0x34, 0x8f, 0x99, 0x92, 0x37, 0x77, 0xf8, 0x3f, 0x05, 0x7e, - 0x25, 0xfa, 0xee, 0x85, 0x5c, 0x48, 0xc5, 0x78, 0x86, 0x5d, 0x0a, 0xfc, 0x7f, 0xd1, 0xb6, 0x21, - 0x04, 0x9d, 0x4c, 0xdc, 0x73, 0xbc, 0x53, 0xae, 0x65, 0x3e, 0x89, 0xa0, 0x33, 0xd8, 0xf8, 0xdc, - 0x56, 0x67, 0xd4, 0xbf, 0xea, 0x35, 0x2c, 0xaf, 0xbe, 0x58, 0x52, 0x58, 0xac, 0xad, 0xc4, 0x88, - 0x39, 0x47, 0x14, 0x56, 0x3b, 0x17, 0xc3, 0x61, 0x7f, 0x34, 0xea, 0x75, 0x1b, 0xc0, 0xdb, 0x5b, - 0x2c, 0x69, 0xad, 0x78, 0xee, 0xa8, 0xe9, 0x54, 0x18, 0xc3, 0x99, 0xb7, 0xfb, 0xf8, 0x44, 0xac, - 0xd7, 0x67, 0x52, 0xba, 0xda, 0x78, 0xb5, 0x26, 0xd6, 0xfb, 0x9a, 0x58, 0x0f, 0x39, 0x01, 0xab, - 0x9c, 0x80, 0xb7, 0x9c, 0x80, 0xcf, 0x9c, 0x80, 0xb1, 0x5b, 0x9e, 0xe8, 0xfc, 0x2b, 0x00, 0x00, - 0xff, 0xff, 0xce, 0x7e, 0x6f, 0x85, 0x8f, 0x01, 0x00, 0x00, + // 334 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xbb, 0x4e, 0xf3, 0x30, + 0x1c, 0xc5, 0xe3, 0x7c, 0xf9, 0x42, 0x6b, 0x41, 0x55, 0x2c, 0x54, 0x59, 0x11, 0x32, 0x16, 0x53, + 0xc4, 0x90, 0x70, 0x79, 0x82, 0xde, 0x86, 0xaa, 0xaa, 0x90, 0x42, 0xc5, 0x9e, 0xc6, 0x56, 0x6a, + 0x41, 0xed, 0xca, 0x31, 0x95, 0x60, 0x62, 0x44, 0x7d, 0x87, 0x4e, 0xf0, 0x08, 0x4c, 0x3c, 0x41, + 0x47, 0x46, 0x26, 0x44, 0xf3, 0x24, 0x28, 0x69, 0xb9, 0x0c, 0x6c, 0xe7, 0xf7, 0xf7, 0x4f, 0xe7, + 0x48, 0x86, 0x9d, 0x54, 0x98, 0xf1, 0xcd, 0x28, 0x48, 0xd4, 0x24, 0x4c, 0x94, 0x34, 0xb1, 0x90, + 0x5c, 0xb3, 0xdf, 0x31, 0x93, 0xf1, 0x34, 0x1b, 0x2b, 0x13, 0x66, 0x46, 0xe9, 0x38, 0xe5, 0xe1, + 0x54, 0x2b, 0xa3, 0x42, 0xcd, 0x13, 0xa5, 0x59, 0x50, 0x02, 0x6a, 0xfc, 0xf8, 0xc1, 0x97, 0x1f, + 0xcc, 0x4e, 0xbc, 0xbd, 0x54, 0xa5, 0x6a, 0xed, 0x17, 0x69, 0x6d, 0x1f, 0x3e, 0x03, 0x58, 0xb9, + 0xd8, 0x58, 0xa8, 0x01, 0x6d, 0xc1, 0x30, 0xa0, 0xc0, 0x77, 0x5a, 0x6e, 0xfe, 0x7e, 0x60, 0xf7, + 0x3a, 0x91, 0x2d, 0x18, 0x6a, 0x40, 0x77, 0x1a, 0x6b, 0x2e, 0x0d, 0xb6, 0x29, 0xf0, 0xab, 0xd1, + 0x86, 0xd0, 0x31, 0x74, 0xae, 0x84, 0x64, 0xd8, 0xa1, 0xc0, 0xaf, 0x9d, 0xee, 0x07, 0x7f, 0x2f, + 0x07, 0x7d, 0x21, 0x59, 0x54, 0x9a, 0xc8, 0x83, 0x15, 0xcd, 0x63, 0xa6, 0xe4, 0xf5, 0x2d, 0xfe, + 0x4f, 0x81, 0x5f, 0x89, 0xbe, 0xb9, 0x58, 0x11, 0x52, 0x31, 0x9e, 0x61, 0x97, 0x02, 0xff, 0x5f, + 0xb4, 0x21, 0x84, 0xa0, 0x93, 0x89, 0x3b, 0x8e, 0xb7, 0xca, 0x6b, 0x99, 0x8f, 0x22, 0xe8, 0xf4, + 0xd7, 0x7d, 0x6e, 0xb3, 0x3d, 0xec, 0x5d, 0x76, 0xeb, 0x96, 0x57, 0x9b, 0x2f, 0x28, 0x2c, 0xae, + 0xcd, 0xc4, 0x88, 0x19, 0x47, 0x14, 0x56, 0xdb, 0xe7, 0x83, 0x41, 0x6f, 0x38, 0xec, 0x76, 0xea, + 0xc0, 0xdb, 0x9d, 0x2f, 0xe8, 0x4e, 0xf1, 0xdc, 0x56, 0x93, 0x89, 0x30, 0x86, 0x33, 0x6f, 0xfb, + 0xe1, 0x91, 0x58, 0x2f, 0x4f, 0xa4, 0xec, 0x6a, 0xe1, 0xe5, 0x8a, 0x58, 0x6f, 0x2b, 0x62, 0xdd, + 0xe7, 0x04, 0x2c, 0x73, 0x02, 0x5e, 0x73, 0x02, 0x3e, 0x72, 0x02, 0x46, 0x6e, 0xf9, 0x57, 0x67, + 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xae, 0x6e, 0x6e, 0xcd, 0xa1, 0x01, 0x00, 0x00, } diff --git a/snapshot/storage/proto/record.proto b/snapshot/storage/proto/record.proto index 64eb36b47..8893a1771 100644 --- a/snapshot/storage/proto/record.proto +++ b/snapshot/storage/proto/record.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package containerd.v1; +package containerd.snapshot.v1; import "gogoproto/gogo.proto";