From a78d0bdeac8fcb329e3d719632cc45cd1def301c Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Wed, 12 Jul 2017 16:22:13 -0700 Subject: [PATCH] Update the content interface to return info from update Namespace keys used by client for uncompressed Signed-off-by: Derek McGowan --- api/services/content/v1/content.pb.go | 344 ++++++++++++++++++-------- api/services/content/v1/content.proto | 6 +- cmd/dist/labels.go | 46 ++-- content/content.go | 2 +- content/store.go | 4 +- image.go | 6 +- metadata/adaptors.go | 19 ++ metadata/content.go | 52 +--- services/content/service.go | 9 +- services/content/store.go | 11 +- 10 files changed, 318 insertions(+), 181 deletions(-) diff --git a/api/services/content/v1/content.pb.go b/api/services/content/v1/content.pb.go index 6594428d4..ecb6cc452 100644 --- a/api/services/content/v1/content.pb.go +++ b/api/services/content/v1/content.pb.go @@ -13,6 +13,7 @@ InfoRequest InfoResponse UpdateRequest + UpdateResponse ListContentRequest ListContentResponse DeleteContentRequest @@ -153,6 +154,14 @@ func (m *UpdateRequest) Reset() { *m = UpdateRequest{} } func (*UpdateRequest) ProtoMessage() {} func (*UpdateRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{3} } +type UpdateResponse struct { + Info Info `protobuf:"bytes,1,opt,name=info" json:"info"` +} + +func (m *UpdateResponse) Reset() { *m = UpdateResponse{} } +func (*UpdateResponse) ProtoMessage() {} +func (*UpdateResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{4} } + type ListContentRequest struct { // Filters contains one or more filters using the syntax defined in the // containerd filter package. @@ -169,7 +178,7 @@ type ListContentRequest struct { func (m *ListContentRequest) Reset() { *m = ListContentRequest{} } func (*ListContentRequest) ProtoMessage() {} -func (*ListContentRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{4} } +func (*ListContentRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{5} } type ListContentResponse struct { Info []Info `protobuf:"bytes,1,rep,name=info" json:"info"` @@ -177,7 +186,7 @@ type ListContentResponse struct { func (m *ListContentResponse) Reset() { *m = ListContentResponse{} } func (*ListContentResponse) ProtoMessage() {} -func (*ListContentResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{5} } +func (*ListContentResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{6} } type DeleteContentRequest struct { // Digest specifies which content to delete. @@ -186,7 +195,7 @@ type DeleteContentRequest struct { func (m *DeleteContentRequest) Reset() { *m = DeleteContentRequest{} } func (*DeleteContentRequest) ProtoMessage() {} -func (*DeleteContentRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{6} } +func (*DeleteContentRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{7} } // ReadContentRequest defines the fields that make up a request to read a portion of // data from a stored object. @@ -204,7 +213,7 @@ type ReadContentRequest struct { func (m *ReadContentRequest) Reset() { *m = ReadContentRequest{} } func (*ReadContentRequest) ProtoMessage() {} -func (*ReadContentRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{7} } +func (*ReadContentRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{8} } // ReadContentResponse carries byte data for a read request. type ReadContentResponse struct { @@ -214,7 +223,7 @@ type ReadContentResponse struct { func (m *ReadContentResponse) Reset() { *m = ReadContentResponse{} } func (*ReadContentResponse) ProtoMessage() {} -func (*ReadContentResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{8} } +func (*ReadContentResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{9} } type Status struct { StartedAt time.Time `protobuf:"bytes,1,opt,name=started_at,json=startedAt,stdtime" json:"started_at"` @@ -227,7 +236,7 @@ type Status struct { func (m *Status) Reset() { *m = Status{} } func (*Status) ProtoMessage() {} -func (*Status) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{9} } +func (*Status) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{10} } type StatusRequest struct { Ref string `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` @@ -235,7 +244,7 @@ type StatusRequest struct { func (m *StatusRequest) Reset() { *m = StatusRequest{} } func (*StatusRequest) ProtoMessage() {} -func (*StatusRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{10} } +func (*StatusRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{11} } type StatusResponse struct { Status *Status `protobuf:"bytes,1,opt,name=status" json:"status,omitempty"` @@ -243,7 +252,7 @@ type StatusResponse struct { func (m *StatusResponse) Reset() { *m = StatusResponse{} } func (*StatusResponse) ProtoMessage() {} -func (*StatusResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{11} } +func (*StatusResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{12} } type ListStatusesRequest struct { Filters []string `protobuf:"bytes,1,rep,name=filters" json:"filters,omitempty"` @@ -251,7 +260,7 @@ type ListStatusesRequest struct { func (m *ListStatusesRequest) Reset() { *m = ListStatusesRequest{} } func (*ListStatusesRequest) ProtoMessage() {} -func (*ListStatusesRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{12} } +func (*ListStatusesRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{13} } type ListStatusesResponse struct { Statuses []Status `protobuf:"bytes,1,rep,name=statuses" json:"statuses"` @@ -259,7 +268,7 @@ type ListStatusesResponse struct { func (m *ListStatusesResponse) Reset() { *m = ListStatusesResponse{} } func (*ListStatusesResponse) ProtoMessage() {} -func (*ListStatusesResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{13} } +func (*ListStatusesResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{14} } // WriteContentRequest writes data to the request ref at offset. type WriteContentRequest struct { @@ -316,7 +325,7 @@ type WriteContentRequest struct { func (m *WriteContentRequest) Reset() { *m = WriteContentRequest{} } func (*WriteContentRequest) ProtoMessage() {} -func (*WriteContentRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{14} } +func (*WriteContentRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{15} } // WriteContentResponse is returned on the culmination of a write call. type WriteContentResponse struct { @@ -350,7 +359,7 @@ type WriteContentResponse struct { func (m *WriteContentResponse) Reset() { *m = WriteContentResponse{} } func (*WriteContentResponse) ProtoMessage() {} -func (*WriteContentResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{15} } +func (*WriteContentResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{16} } type AbortRequest struct { Ref string `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` @@ -358,13 +367,14 @@ type AbortRequest struct { func (m *AbortRequest) Reset() { *m = AbortRequest{} } func (*AbortRequest) ProtoMessage() {} -func (*AbortRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{16} } +func (*AbortRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{17} } func init() { proto.RegisterType((*Info)(nil), "containerd.services.content.v1.Info") proto.RegisterType((*InfoRequest)(nil), "containerd.services.content.v1.InfoRequest") proto.RegisterType((*InfoResponse)(nil), "containerd.services.content.v1.InfoResponse") proto.RegisterType((*UpdateRequest)(nil), "containerd.services.content.v1.UpdateRequest") + proto.RegisterType((*UpdateResponse)(nil), "containerd.services.content.v1.UpdateResponse") proto.RegisterType((*ListContentRequest)(nil), "containerd.services.content.v1.ListContentRequest") proto.RegisterType((*ListContentResponse)(nil), "containerd.services.content.v1.ListContentResponse") proto.RegisterType((*DeleteContentRequest)(nil), "containerd.services.content.v1.DeleteContentRequest") @@ -402,7 +412,7 @@ type ContentClient interface { // This call can be used to manage the mutable content labels. The // immutable metadata such as digest, size, and committed at cannot // be updated. - Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*google_protobuf3.Empty, error) + Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*UpdateResponse, error) // List streams the entire set of content as Info objects and closes the // stream. // @@ -464,8 +474,8 @@ func (c *contentClient) Info(ctx context.Context, in *InfoRequest, opts ...grpc. return out, nil } -func (c *contentClient) Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*google_protobuf3.Empty, error) { - out := new(google_protobuf3.Empty) +func (c *contentClient) Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*UpdateResponse, error) { + out := new(UpdateResponse) err := grpc.Invoke(ctx, "/containerd.services.content.v1.Content/Update", in, out, c.cc, opts...) if err != nil { return nil, err @@ -617,7 +627,7 @@ type ContentServer interface { // This call can be used to manage the mutable content labels. The // immutable metadata such as digest, size, and committed at cannot // be updated. - Update(context.Context, *UpdateRequest) (*google_protobuf3.Empty, error) + Update(context.Context, *UpdateRequest) (*UpdateResponse, error) // List streams the entire set of content as Info objects and closes the // stream. // @@ -1040,6 +1050,32 @@ func (m *UpdateRequest) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *UpdateResponse) 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 *UpdateResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintContent(dAtA, i, uint64(m.Info.Size())) + n6, err := m.Info.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n6 + return i, nil +} + func (m *ListContentRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1208,19 +1244,19 @@ func (m *Status) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.StartedAt))) - n6, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartedAt, dAtA[i:]) - if err != nil { - return 0, err - } - i += n6 - dAtA[i] = 0x12 - i++ - i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt))) - n7, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i:]) + n7, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartedAt, dAtA[i:]) if err != nil { return 0, err } i += n7 + dAtA[i] = 0x12 + i++ + i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt))) + n8, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i:]) + if err != nil { + return 0, err + } + i += n8 if len(m.Ref) > 0 { dAtA[i] = 0x1a i++ @@ -1289,11 +1325,11 @@ func (m *StatusResponse) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintContent(dAtA, i, uint64(m.Status.Size())) - n8, err := m.Status.MarshalTo(dAtA[i:]) + n9, err := m.Status.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n8 + i += n9 } return i, nil } @@ -1435,19 +1471,19 @@ func (m *WriteContentResponse) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.StartedAt))) - n9, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartedAt, dAtA[i:]) - if err != nil { - return 0, err - } - i += n9 - dAtA[i] = 0x1a - i++ - i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt))) - n10, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i:]) + n10, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartedAt, dAtA[i:]) if err != nil { return 0, err } i += n10 + dAtA[i] = 0x1a + i++ + i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt))) + n11, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i:]) + if err != nil { + return 0, err + } + i += n11 if m.Offset != 0 { dAtA[i] = 0x20 i++ @@ -1573,6 +1609,14 @@ func (m *UpdateRequest) Size() (n int) { return n } +func (m *UpdateResponse) Size() (n int) { + var l int + _ = l + l = m.Info.Size() + n += 1 + l + sovContent(uint64(l)) + return n +} + func (m *ListContentRequest) Size() (n int) { var l int _ = l @@ -1832,6 +1876,16 @@ func (this *UpdateRequest) String() string { }, "") return s } +func (this *UpdateResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&UpdateResponse{`, + `Info:` + strings.Replace(strings.Replace(this.Info.String(), "Info", "Info", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} func (this *ListContentRequest) String() string { if this == nil { return "nil" @@ -2534,6 +2588,86 @@ func (m *UpdateRequest) Unmarshal(dAtA []byte) error { } return nil } +func (m *UpdateResponse) 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 ErrIntOverflowContent + } + 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: UpdateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UpdateResponse: 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 ErrIntOverflowContent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthContent + } + 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 := skipContent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthContent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ListContentRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -4099,72 +4233,72 @@ func init() { } var fileDescriptorContent = []byte{ - // 1061 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcf, 0x6f, 0x1a, 0xc7, - 0x17, 0x67, 0x58, 0x58, 0x9b, 0x07, 0xc9, 0x97, 0xef, 0x40, 0x23, 0xb4, 0x55, 0x61, 0xb3, 0xaa, - 0x2a, 0x94, 0xd4, 0x8b, 0x83, 0x7d, 0x68, 0x1b, 0xa9, 0x2a, 0x26, 0x4e, 0xe3, 0x2a, 0x4e, 0xaa, - 0x0d, 0x69, 0xd4, 0x5c, 0xd2, 0x05, 0x06, 0xba, 0x32, 0xb0, 0x84, 0x19, 0x50, 0xdd, 0x53, 0x2f, - 0x95, 0x2a, 0x2b, 0x87, 0xfe, 0x03, 0xbe, 0xb4, 0x55, 0xff, 0x88, 0xfe, 0x05, 0x3e, 0xf6, 0x58, - 0xf5, 0x90, 0x34, 0xfe, 0x2f, 0x7a, 0xa9, 0xaa, 0x9d, 0x99, 0x85, 0x05, 0xec, 0x2c, 0x60, 0xf7, - 0xe4, 0x37, 0xc3, 0xfb, 0xbc, 0x79, 0xbf, 0x3e, 0xef, 0xad, 0xe1, 0x6e, 0xdb, 0x61, 0x5f, 0x0f, - 0xeb, 0x66, 0xc3, 0xed, 0x96, 0x1a, 0x6e, 0x8f, 0xd9, 0x4e, 0x8f, 0x0c, 0x9a, 0x41, 0xd1, 0xee, - 0x3b, 0x25, 0x4a, 0x06, 0x23, 0xa7, 0x41, 0x28, 0xbf, 0x27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x00, 0x00, 0xff, 0xff, 0xed, 0xa1, 0x30, - 0xea, 0x98, 0x0e, 0x00, 0x00, + // 1067 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x6f, 0x1a, 0x47, + 0x14, 0xf7, 0xb0, 0xb0, 0x36, 0x0f, 0x92, 0xd2, 0x81, 0x46, 0x68, 0xab, 0xc2, 0x66, 0x55, 0x55, + 0x28, 0xa9, 0x17, 0x07, 0xfb, 0xd0, 0x36, 0x52, 0x55, 0x4c, 0x9c, 0xc6, 0x55, 0x9c, 0x56, 0x1b, + 0xd2, 0xa8, 0xb9, 0xa4, 0x0b, 0x0c, 0x74, 0x65, 0x60, 0x09, 0x33, 0xa0, 0xba, 0xa7, 0x5e, 0x2a, + 0x55, 0x56, 0x0e, 0xfd, 0x02, 0xbe, 0xb4, 0xfd, 0x14, 0x3d, 0xf4, 0xec, 0x63, 0x8f, 0x55, 0x0f, + 0x49, 0xe3, 0x6f, 0xd1, 0x4b, 0x55, 0xed, 0xcc, 0x2c, 0x2c, 0x60, 0x97, 0x05, 0x93, 0x13, 0x6f, + 0x66, 0xdf, 0xef, 0xfd, 0xff, 0x33, 0xc0, 0xdd, 0x96, 0xc3, 0xbe, 0x19, 0xd4, 0xcc, 0xba, 0xdb, + 0x29, 0xd6, 0xdd, 0x2e, 0xb3, 0x9d, 0x2e, 0xe9, 0x37, 0x82, 0xa4, 0xdd, 0x73, 0x8a, 0x94, 0xf4, + 0x87, 0x4e, 0x9d, 0x50, 0x7e, 0x4f, 0xba, 0xac, 0x38, 0xbc, 0xe5, 0x93, 0x66, 0xaf, 0xef, 0x32, + 0x17, 0xe7, 0xc6, 0x08, 0xd3, 0xe7, 0x36, 0x7d, 0x96, 0xe1, 0x2d, 0x2d, 0xd3, 0x72, 0x5b, 0x2e, + 0x67, 0x2d, 0x7a, 0x94, 0x40, 0x69, 0x7a, 0xcb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xec, 0x75, 0x59, + 0xff, 0xc8, 0x92, 0x78, 0xed, 0x43, 0x48, 0x04, 0xae, 0x71, 0x0a, 0x94, 0x43, 0x72, 0x24, 0x62, + 0x68, 0x79, 0x24, 0xce, 0x40, 0x6c, 0x68, 0xb7, 0x07, 0x22, 0x1a, 0x71, 0x4b, 0x1c, 0x3e, 0x8a, + 0x7c, 0x80, 0x8c, 0xaf, 0x20, 0xe1, 0x89, 0xb5, 0xc8, 0xb3, 0x81, 0x17, 0xb5, 0x15, 0x66, 0xc0, + 0x78, 0x00, 0x49, 0x21, 0x9a, 0xf6, 0xdc, 0x2e, 0x25, 0xf8, 0x63, 0x88, 0x3a, 0xdd, 0xa6, 0xcb, + 0x25, 0x27, 0x4a, 0xef, 0x86, 0xf1, 0x76, 0x37, 0xea, 0xe9, 0xb7, 0x38, 0xce, 0x78, 0x8e, 0xe0, + 0xca, 0x23, 0x1e, 0x3d, 0xdf, 0xda, 0x4b, 0x4a, 0xc4, 0xb7, 0x21, 0x21, 0xd2, 0xc1, 0x6b, 0x99, + 0x07, 0xe7, 0xbc, 0x3c, 0xde, 0xf5, 0xca, 0xfd, 0xc0, 0xa6, 0x87, 0x96, 0xcc, 0xba, 0x47, 0x1b, + 0x5f, 0xc0, 0x55, 0xdf, 0x9a, 0x15, 0x39, 0x68, 0x02, 0xbe, 0xef, 0x50, 0x56, 0x11, 0x2c, 0xbe, + 0x93, 0x59, 0x58, 0x6f, 0x3a, 0x6d, 0x46, 0xfa, 0x34, 0x8b, 0x74, 0xa5, 0x10, 0xb7, 0xfc, 0xa3, + 0xf1, 0x08, 0xd2, 0x13, 0xfc, 0x33, 0x66, 0x28, 0x4b, 0x99, 0x51, 0x83, 0xcc, 0x1d, 0xd2, 0x26, + 0x8c, 0x4c, 0x19, 0xb2, 0xca, 0xda, 0x78, 0x8e, 0x00, 0x5b, 0xc4, 0x6e, 0xbc, 0x3e, 0x15, 0xf8, + 0x1a, 0xa8, 0x6e, 0xb3, 0x49, 0x09,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 0x33, 0x88, 0x7a, 0x63, 0x04, 0x97, 0xe6, 0xe1, 0x66, 0x97, 0xbe, 0xb6, 0xbd, + 0x10, 0x46, 0x28, 0xdc, 0x42, 0xf8, 0x4b, 0x50, 0xc5, 0xea, 0xc6, 0x3b, 0xf3, 0x04, 0x9c, 0xb7, + 0xe2, 0xb5, 0x6b, 0x33, 0xf5, 0xbd, 0xe7, 0xbd, 0xd3, 0x3d, 0x57, 0xbc, 0xfd, 0x38, 0xdf, 0x95, + 0xd9, 0x9d, 0x3e, 0xdf, 0x95, 0x73, 0x36, 0xef, 0x16, 0xf2, 0xd2, 0x24, 0xd7, 0xe9, 0x66, 0xc8, + 0x79, 0x1f, 0x36, 0x4d, 0x53, 0xeb, 0xe5, 0x08, 0x92, 0xc1, 0x69, 0x8f, 0x43, 0x85, 0x7e, 0x6a, + 0x99, 0x68, 0x3b, 0x8b, 0x81, 0xa4, 0xea, 0x21, 0xc4, 0x44, 0xeb, 0x6c, 0x87, 0x9a, 0x72, 0x53, + 0x81, 0xdd, 0x59, 0x0c, 0x24, 0x74, 0x16, 0xd0, 0x16, 0xc2, 0x07, 0x10, 0xe3, 0xb3, 0x01, 0xcf, + 0xed, 0x9c, 0xe0, 0x08, 0xb9, 0xa8, 0x3a, 0x76, 0x9f, 0x9c, 0xbe, 0xca, 0xad, 0xfd, 0xf9, 0x2a, + 0xb7, 0xf6, 0xfd, 0x59, 0x0e, 0x9d, 0x9e, 0xe5, 0xd0, 0x1f, 0x67, 0x39, 0xf4, 0xf7, 0x59, 0x0e, + 0x3d, 0xf9, 0x64, 0xd9, 0xff, 0xad, 0xb7, 0x25, 0x59, 0x53, 0xb9, 0xae, 0xed, 0xff, 0x02, 0x00, + 0x00, 0xff, 0xff, 0x63, 0x60, 0xb3, 0x49, 0x02, 0x0f, 0x00, 0x00, } diff --git a/api/services/content/v1/content.proto b/api/services/content/v1/content.proto index 4bc8fa3ba..d8c3bf586 100644 --- a/api/services/content/v1/content.proto +++ b/api/services/content/v1/content.proto @@ -22,7 +22,7 @@ service Content { // This call can be used to manage the mutable content labels. The // immutable metadata such as digest, size, and committed at cannot // be updated. - rpc Update(UpdateRequest) returns (google.protobuf.Empty); + rpc Update(UpdateRequest) returns (UpdateResponse); // List streams the entire set of content as Info objects and closes the // stream. @@ -111,6 +111,10 @@ message UpdateRequest { google.protobuf.FieldMask update_mask = 2; } +message UpdateResponse { + Info info = 1 [(gogoproto.nullable) = false]; +} + message ListContentRequest { // Filters contains one or more filters using the syntax defined in the // containerd filter package. diff --git a/cmd/dist/labels.go b/cmd/dist/labels.go index 3af2b1abf..4e1b17e33 100644 --- a/cmd/dist/labels.go +++ b/cmd/dist/labels.go @@ -4,6 +4,7 @@ import ( "fmt" "strings" + "github.com/containerd/containerd/content" digest "github.com/opencontainers/go-digest" "github.com/urfave/cli" ) @@ -16,8 +17,7 @@ var labelCommand = cli.Command{ Flags: []cli.Flag{}, Action: func(context *cli.Context) error { var ( - object = context.Args().First() - labelArgs = context.Args().Tail() + object, labels = objectWithLabelArgs(context) ) ctx, cancel := appContext(context) defer cancel() @@ -32,32 +32,36 @@ var labelCommand = cli.Command{ return err } - info, err := cs.Info(ctx, dgst) - if err != nil { - return err - } - - if info.Labels == nil { - info.Labels = map[string]string{} + info := content.Info{ + Digest: dgst, + Labels: map[string]string{}, } var paths []string - for _, arg := range labelArgs { - var k, v string - if idx := strings.IndexByte(arg, '='); idx > 0 { - k = arg[:idx] - v = arg[idx+1:] - } else { - k = arg - } + for k, v := range labels { paths = append(paths, fmt.Sprintf("labels.%s", k)) - if v == "" { - delete(info.Labels, k) - } else { + if v != "" { info.Labels[k] = v } } - return cs.Update(ctx, info, paths...) + // Nothing updated, do no clear + if len(paths) == 0 { + info, err = cs.Info(ctx, info.Digest) + } else { + info, err = cs.Update(ctx, info, paths...) + } + if err != nil { + return err + } + + var labelStrings []string + for k, v := range info.Labels { + labelStrings = append(labelStrings, fmt.Sprintf("%s=%s", k, v)) + } + + fmt.Println(strings.Join(labelStrings, ",")) + + return nil }, } diff --git a/content/content.go b/content/content.go index 9a5c65b6a..6037f6c4f 100644 --- a/content/content.go +++ b/content/content.go @@ -60,7 +60,7 @@ type Manager interface { // fields will be updated. // Mutable fields: // labels.* - Update(ctx context.Context, info Info, fieldpaths ...string) error + Update(ctx context.Context, info Info, fieldpaths ...string) (Info, error) // Walk will call fn for each item in the content store which // match the provided filters. If no filters are given all diff --git a/content/store.go b/content/store.go index 39bfd1c3d..3013c4e68 100644 --- a/content/store.go +++ b/content/store.go @@ -93,9 +93,9 @@ func (cs *store) Delete(ctx context.Context, dgst digest.Digest) error { return nil } -func (cs *store) Update(ctx context.Context, info Info, fieldpaths ...string) error { +func (cs *store) Update(ctx context.Context, info Info, fieldpaths ...string) (Info, error) { // TODO: Support persisting and updating mutable content data - return errors.Wrapf(errdefs.ErrFailedPrecondition, "update not supported on immutable content store") + return Info{}, errors.Wrapf(errdefs.ErrFailedPrecondition, "update not supported on immutable content store") } func (cs *store) Walk(ctx context.Context, fn WalkFunc, filters ...string) error { diff --git a/image.go b/image.go index a1905d054..0057e4dee 100644 --- a/image.go +++ b/image.go @@ -57,12 +57,12 @@ func (i *image) Unpack(ctx context.Context, snapshotterName string) error { if err != nil { return err } - if info.Labels["uncompressed"] != layer.Diff.Digest.String() { + if info.Labels["containerd.io/uncompressed"] != layer.Diff.Digest.String() { if info.Labels == nil { info.Labels = map[string]string{} } - info.Labels["uncompressed"] = layer.Diff.Digest.String() - if err := cs.Update(ctx, info, "labels.uncompressed"); err != nil { + info.Labels["containerd.io/uncompressed"] = layer.Diff.Digest.String() + if _, err := cs.Update(ctx, info, "labels.containerd.io/uncompressed"); err != nil { return err } } diff --git a/metadata/adaptors.go b/metadata/adaptors.go index e3df7df80..4e7ef673d 100644 --- a/metadata/adaptors.go +++ b/metadata/adaptors.go @@ -70,6 +70,25 @@ func adaptContainer(o interface{}) filters.Adaptor { }) } +func adaptContentInfo(info content.Info) filters.Adaptor { + return filters.AdapterFunc(func(fieldpath []string) (string, bool) { + if len(fieldpath) == 0 { + return "", false + } + + switch fieldpath[0] { + case "digest": + return info.Digest.String(), true + case "size": + // TODO: support size based filtering + case "labels": + return checkMap(fieldpath[1:], info.Labels) + } + + return "", false + }) +} + func adaptContentStatus(status content.Status) filters.Adaptor { return filters.AdapterFunc(func(fieldpath []string) (string, bool) { if len(fieldpath) == 0 { diff --git a/metadata/content.go b/metadata/content.go index 007d695ea..8aa24dade 100644 --- a/metadata/content.go +++ b/metadata/content.go @@ -52,22 +52,21 @@ func (cs *contentStore) Info(ctx context.Context, dgst digest.Digest) (content.I return info, nil } -func (cs *contentStore) Update(ctx context.Context, info content.Info, fieldpaths ...string) error { +func (cs *contentStore) Update(ctx context.Context, info content.Info, fieldpaths ...string) (content.Info, error) { ns, err := namespaces.NamespaceRequired(ctx) if err != nil { - return err + return content.Info{}, err } + updated := content.Info{ + Digest: info.Digest, + } if err := update(ctx, cs.db, func(tx *bolt.Tx) error { bkt := getBlobBucket(tx, ns, info.Digest) if bkt == nil { return errors.Wrapf(errdefs.ErrNotFound, "content digest %v", info.Digest) } - updated := content.Info{ - Digest: info.Digest, - } - if err := readInfo(&updated, bkt); err != nil { return errors.Wrapf(err, "info %q", info.Digest) } @@ -92,16 +91,16 @@ func (cs *contentStore) Update(ctx context.Context, info content.Info, fieldpath } } } else { - info.CommittedAt = updated.CommittedAt - updated = info + // Set mutable fields + updated.Labels = info.Labels } updated.UpdatedAt = time.Now().UTC() return writeInfo(&updated, bkt) }); err != nil { - return err + return content.Info{}, err } - return nil + return updated, nil } func (cs *contentStore) Walk(ctx context.Context, fn content.WalkFunc, fs ...string) error { @@ -110,17 +109,9 @@ func (cs *contentStore) Walk(ctx context.Context, fn content.WalkFunc, fs ...str return err } - var filter filters.Filter = filters.Always - if len(fs) > 0 { - fa := make([]filters.Filter, 0, len(fs)) - for _, s := range fs { - f, err := filters.Parse(s) - if err != nil { - return errors.Wrapf(errdefs.ErrInvalidArgument, "bad filter %q", s) - } - fa = append(fa, f) - } - filter = filters.Filter(filters.Any(fa)) + filter, err := filters.ParseAll(fs...) + if err != nil { + return err } // TODO: Batch results to keep from reading all info into memory @@ -481,22 +472,3 @@ func writeInfo(info *content.Info, bkt *bolt.Bucket) error { return nil } - -func adaptContentInfo(info content.Info) filters.Adaptor { - return filters.AdapterFunc(func(fieldpath []string) (string, bool) { - if len(fieldpath) == 0 { - return "", false - } - - switch fieldpath[0] { - case "digest": - return info.Digest.String(), true - case "size": - // TODO: support size based filtering - case "labels": - return checkMap(fieldpath[1:], info.Labels) - } - - return "", false - }) -} diff --git a/services/content/service.go b/services/content/service.go index 91173b3b8..293dc230f 100644 --- a/services/content/service.go +++ b/services/content/service.go @@ -83,16 +83,19 @@ func (s *Service) Info(ctx context.Context, req *api.InfoRequest) (*api.InfoResp }, nil } -func (s *Service) Update(ctx context.Context, req *api.UpdateRequest) (*empty.Empty, error) { +func (s *Service) Update(ctx context.Context, req *api.UpdateRequest) (*api.UpdateResponse, error) { if err := req.Info.Digest.Validate(); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%q failed validation", req.Info.Digest) } - if err := s.store.Update(ctx, infoFromGRPC(req.Info), req.UpdateMask.GetPaths()...); err != nil { + info, err := s.store.Update(ctx, infoFromGRPC(req.Info), req.UpdateMask.GetPaths()...) + if err != nil { return nil, errdefs.ToGRPC(err) } - return &empty.Empty{}, nil + return &api.UpdateResponse{ + Info: infoToGRPC(info), + }, nil } func (s *Service) List(req *api.ListContentRequest, session api.Content_ListServer) error { diff --git a/services/content/store.go b/services/content/store.go index be21bc53f..02b116885 100644 --- a/services/content/store.go +++ b/services/content/store.go @@ -108,16 +108,17 @@ func (rs *remoteStore) Status(ctx context.Context, ref string) (content.Status, }, nil } -func (rs *remoteStore) Update(ctx context.Context, info content.Info, fieldpaths ...string) error { - if _, err := rs.client.Update(ctx, &contentapi.UpdateRequest{ +func (rs *remoteStore) Update(ctx context.Context, info content.Info, fieldpaths ...string) (content.Info, error) { + resp, err := rs.client.Update(ctx, &contentapi.UpdateRequest{ Info: infoToGRPC(info), UpdateMask: &protobuftypes.FieldMask{ Paths: fieldpaths, }, - }); err != nil { - return errdefs.FromGRPC(err) + }) + if err != nil { + return content.Info{}, errdefs.FromGRPC(err) } - return nil + return infoFromGRPC(resp.Info), nil } func (rs *remoteStore) ListStatuses(ctx context.Context, filters ...string) ([]content.Status, error) {