images, containers: converge metadata API conventions
The primary feature we get with this PR is support for filters and labels on the image metadata store. In the process of doing this, the conventions for the API have been converged between containers and images, providing a model for other services. With images, `Put` (renamed to `Update` briefly) has been split into a `Create` and `Update`, allowing one to control the behavior around these operations. `Update` now includes support for masking fields at the datastore-level across both the containers and image service. Filters are now just string values to interpreted directly within the data store. This should allow for some interesting future use cases in which the datastore might use the syntax for more efficient query paths. The containers service has been updated to follow these conventions as closely as possible. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
34f7b29120
commit
7f4c4aecf7
@ -22,6 +22,7 @@
|
||||
ContentDelete
|
||||
StreamEventsRequest
|
||||
Envelope
|
||||
ImageCreate
|
||||
ImageUpdate
|
||||
ImageDelete
|
||||
NamespaceCreate
|
||||
|
@ -19,6 +19,15 @@ var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
type ImageCreate struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Labels map[string]string `protobuf:"bytes,2,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
}
|
||||
|
||||
func (m *ImageCreate) Reset() { *m = ImageCreate{} }
|
||||
func (*ImageCreate) ProtoMessage() {}
|
||||
func (*ImageCreate) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{0} }
|
||||
|
||||
type ImageUpdate struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Labels map[string]string `protobuf:"bytes,2,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
@ -26,7 +35,7 @@ type ImageUpdate struct {
|
||||
|
||||
func (m *ImageUpdate) Reset() { *m = ImageUpdate{} }
|
||||
func (*ImageUpdate) ProtoMessage() {}
|
||||
func (*ImageUpdate) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{0} }
|
||||
func (*ImageUpdate) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{1} }
|
||||
|
||||
type ImageDelete struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
@ -34,12 +43,54 @@ type ImageDelete struct {
|
||||
|
||||
func (m *ImageDelete) Reset() { *m = ImageDelete{} }
|
||||
func (*ImageDelete) ProtoMessage() {}
|
||||
func (*ImageDelete) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{1} }
|
||||
func (*ImageDelete) Descriptor() ([]byte, []int) { return fileDescriptorImage, []int{2} }
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*ImageCreate)(nil), "containerd.services.images.v1.ImageCreate")
|
||||
proto.RegisterType((*ImageUpdate)(nil), "containerd.services.images.v1.ImageUpdate")
|
||||
proto.RegisterType((*ImageDelete)(nil), "containerd.services.images.v1.ImageDelete")
|
||||
}
|
||||
func (m *ImageCreate) 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 *ImageCreate) MarshalTo(dAtA []byte) (int, error) {
|
||||
var i int
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Name) > 0 {
|
||||
dAtA[i] = 0xa
|
||||
i++
|
||||
i = encodeVarintImage(dAtA, i, uint64(len(m.Name)))
|
||||
i += copy(dAtA[i:], m.Name)
|
||||
}
|
||||
if len(m.Labels) > 0 {
|
||||
for k, _ := range m.Labels {
|
||||
dAtA[i] = 0x12
|
||||
i++
|
||||
v := m.Labels[k]
|
||||
mapSize := 1 + len(k) + sovImage(uint64(len(k))) + 1 + len(v) + sovImage(uint64(len(v)))
|
||||
i = encodeVarintImage(dAtA, i, uint64(mapSize))
|
||||
dAtA[i] = 0xa
|
||||
i++
|
||||
i = encodeVarintImage(dAtA, i, uint64(len(k)))
|
||||
i += copy(dAtA[i:], k)
|
||||
dAtA[i] = 0x12
|
||||
i++
|
||||
i = encodeVarintImage(dAtA, i, uint64(len(v)))
|
||||
i += copy(dAtA[i:], v)
|
||||
}
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *ImageUpdate) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
@ -132,6 +183,24 @@ func encodeVarintImage(dAtA []byte, offset int, v uint64) int {
|
||||
dAtA[offset] = uint8(v)
|
||||
return offset + 1
|
||||
}
|
||||
func (m *ImageCreate) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Name)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovImage(uint64(l))
|
||||
}
|
||||
if len(m.Labels) > 0 {
|
||||
for k, v := range m.Labels {
|
||||
_ = k
|
||||
_ = v
|
||||
mapEntrySize := 1 + len(k) + sovImage(uint64(len(k))) + 1 + len(v) + sovImage(uint64(len(v)))
|
||||
n += mapEntrySize + 1 + sovImage(uint64(mapEntrySize))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *ImageUpdate) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
@ -173,6 +242,27 @@ func sovImage(x uint64) (n int) {
|
||||
func sozImage(x uint64) (n int) {
|
||||
return sovImage(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (this *ImageCreate) String() string {
|
||||
if this == nil {
|
||||
return "nil"
|
||||
}
|
||||
keysForLabels := make([]string, 0, len(this.Labels))
|
||||
for k, _ := range this.Labels {
|
||||
keysForLabels = append(keysForLabels, k)
|
||||
}
|
||||
github_com_gogo_protobuf_sortkeys.Strings(keysForLabels)
|
||||
mapStringForLabels := "map[string]string{"
|
||||
for _, k := range keysForLabels {
|
||||
mapStringForLabels += fmt.Sprintf("%v: %v,", k, this.Labels[k])
|
||||
}
|
||||
mapStringForLabels += "}"
|
||||
s := strings.Join([]string{`&ImageCreate{`,
|
||||
`Name:` + fmt.Sprintf("%v", this.Name) + `,`,
|
||||
`Labels:` + mapStringForLabels + `,`,
|
||||
`}`,
|
||||
}, "")
|
||||
return s
|
||||
}
|
||||
func (this *ImageUpdate) String() string {
|
||||
if this == nil {
|
||||
return "nil"
|
||||
@ -212,6 +302,201 @@ func valueToStringImage(v interface{}) string {
|
||||
pv := reflect.Indirect(rv).Interface()
|
||||
return fmt.Sprintf("*%v", pv)
|
||||
}
|
||||
func (m *ImageCreate) 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 ErrIntOverflowImage
|
||||
}
|
||||
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: ImageCreate: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: ImageCreate: 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 ErrIntOverflowImage
|
||||
}
|
||||
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 ErrInvalidLengthImage
|
||||
}
|
||||
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 Labels", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowImage
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthImage
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
var keykey uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowImage
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
keykey |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
var stringLenmapkey uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowImage
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLenmapkey |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLenmapkey := int(stringLenmapkey)
|
||||
if intStringLenmapkey < 0 {
|
||||
return ErrInvalidLengthImage
|
||||
}
|
||||
postStringIndexmapkey := iNdEx + intStringLenmapkey
|
||||
if postStringIndexmapkey > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
mapkey := string(dAtA[iNdEx:postStringIndexmapkey])
|
||||
iNdEx = postStringIndexmapkey
|
||||
if m.Labels == nil {
|
||||
m.Labels = make(map[string]string)
|
||||
}
|
||||
if iNdEx < postIndex {
|
||||
var valuekey uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowImage
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
valuekey |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
var stringLenmapvalue uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowImage
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLenmapvalue |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLenmapvalue := int(stringLenmapvalue)
|
||||
if intStringLenmapvalue < 0 {
|
||||
return ErrInvalidLengthImage
|
||||
}
|
||||
postStringIndexmapvalue := iNdEx + intStringLenmapvalue
|
||||
if postStringIndexmapvalue > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
mapvalue := string(dAtA[iNdEx:postStringIndexmapvalue])
|
||||
iNdEx = postStringIndexmapvalue
|
||||
m.Labels[mapkey] = mapvalue
|
||||
} else {
|
||||
var mapvalue string
|
||||
m.Labels[mapkey] = mapvalue
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipImage(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthImage
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *ImageUpdate) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
@ -596,21 +881,22 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptorImage = []byte{
|
||||
// 251 bytes of a gzipped FileDescriptorProto
|
||||
// 263 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x4e, 0xcf, 0x2c, 0xc9,
|
||||
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
|
||||
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x17, 0xa7, 0x16, 0x95, 0x65, 0x26, 0xa7, 0x16, 0xeb,
|
||||
0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0xeb, 0x97, 0x19, 0xea, 0x67, 0xe6, 0x26, 0xa6, 0xa7, 0xea,
|
||||
0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xc9, 0x22, 0x94, 0xeb, 0xc1, 0x94, 0xea, 0x81, 0x15, 0x14,
|
||||
0xeb, 0x95, 0x19, 0x2a, 0xad, 0x61, 0xe4, 0xe2, 0xf6, 0x04, 0xf1, 0x42, 0x0b, 0x52, 0x12, 0x4b,
|
||||
0xeb, 0x95, 0x19, 0x2a, 0xad, 0x61, 0xe4, 0xe2, 0xf6, 0x04, 0xf1, 0x9c, 0x8b, 0x52, 0x13, 0x4b,
|
||||
0x52, 0x85, 0x84, 0xb8, 0x58, 0xf2, 0x12, 0x73, 0x53, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83,
|
||||
0xc0, 0x6c, 0x21, 0x3f, 0x2e, 0xb6, 0x9c, 0xc4, 0xa4, 0xd4, 0x9c, 0x62, 0x09, 0x26, 0x05, 0x66,
|
||||
0x0d, 0x6e, 0x23, 0x33, 0x3d, 0xbc, 0x66, 0xea, 0x21, 0x99, 0xa7, 0xe7, 0x03, 0xd6, 0xe8, 0x9a,
|
||||
0x57, 0x52, 0x54, 0x19, 0x04, 0x35, 0x45, 0xca, 0x92, 0x8b, 0x1b, 0x49, 0x58, 0x48, 0x80, 0x8b,
|
||||
0x39, 0x3b, 0xb5, 0x12, 0x6a, 0x23, 0x88, 0x29, 0x24, 0xc2, 0xc5, 0x5a, 0x96, 0x98, 0x53, 0x9a,
|
||||
0x2a, 0xc1, 0x04, 0x16, 0x83, 0x70, 0xac, 0x98, 0x2c, 0x18, 0x95, 0x14, 0xa1, 0xae, 0x75, 0x49,
|
||||
0xcd, 0x49, 0xc5, 0xee, 0x5a, 0xa7, 0x88, 0x13, 0x0f, 0xe5, 0x18, 0x6e, 0x3c, 0x94, 0x63, 0x68,
|
||||
0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31,
|
||||
0x46, 0xd9, 0x91, 0x19, 0x9e, 0xd6, 0x10, 0x56, 0x12, 0x1b, 0x38, 0x44, 0x8d, 0x01, 0x01, 0x00,
|
||||
0x00, 0xff, 0xff, 0x0c, 0x2f, 0x4e, 0xf3, 0x98, 0x01, 0x00, 0x00,
|
||||
0x2a, 0xc1, 0x04, 0x16, 0x83, 0x70, 0xac, 0x98, 0x2c, 0x18, 0x11, 0xce, 0x0d, 0x2d, 0x48, 0xa1,
|
||||
0xaa, 0x73, 0x21, 0xe6, 0x51, 0xdb, 0xb9, 0x8a, 0x50, 0xd7, 0xba, 0xa4, 0xe6, 0xa4, 0x62, 0x77,
|
||||
0xad, 0x53, 0xc4, 0x89, 0x87, 0x72, 0x0c, 0x37, 0x1e, 0xca, 0x31, 0x34, 0x3c, 0x92, 0x63, 0x3c,
|
||||
0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0xa3, 0xec, 0xc8, 0x8c,
|
||||
0x7e, 0x6b, 0x08, 0x2b, 0x89, 0x0d, 0x9c, 0x00, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x13,
|
||||
0x7c, 0x2c, 0x4a, 0x47, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
@ -4,6 +4,11 @@ package containerd.services.images.v1;
|
||||
|
||||
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
||||
|
||||
message ImageCreate {
|
||||
string name = 1;
|
||||
map<string, string> labels = 2;
|
||||
}
|
||||
|
||||
message ImageUpdate {
|
||||
string name = 1;
|
||||
map<string, string> labels = 2;
|
||||
|
@ -12,6 +12,8 @@
|
||||
Image
|
||||
GetImageRequest
|
||||
GetImageResponse
|
||||
CreateImageRequest
|
||||
CreateImageResponse
|
||||
UpdateImageRequest
|
||||
UpdateImageResponse
|
||||
ListImagesRequest
|
||||
@ -25,13 +27,19 @@ import fmt "fmt"
|
||||
import math "math"
|
||||
import _ "github.com/gogo/protobuf/gogoproto"
|
||||
import google_protobuf1 "github.com/golang/protobuf/ptypes/empty"
|
||||
import google_protobuf2 "github.com/gogo/protobuf/types"
|
||||
import _ "github.com/gogo/protobuf/types"
|
||||
import containerd_types "github.com/containerd/containerd/api/types"
|
||||
|
||||
import time "time"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
import github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
|
||||
|
||||
import strings "strings"
|
||||
import reflect "reflect"
|
||||
import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys"
|
||||
@ -42,6 +50,7 @@ import io "io"
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
var _ = time.Kitchen
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
@ -50,9 +59,21 @@ var _ = math.Inf
|
||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type Image struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Labels map[string]string `protobuf:"bytes,2,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
// Name provides a unique name for the image.
|
||||
//
|
||||
// Containerd treats this as the primary identifier.
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
// Labels provides free form labels for the image. These are runtime only
|
||||
// and do not get inherited into the package image in any way.
|
||||
//
|
||||
// Labels may be updated using the field mask.
|
||||
Labels map[string]string `protobuf:"bytes,2,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
// Target describes the content entry point of the image.
|
||||
Target containerd_types.Descriptor `protobuf:"bytes,3,opt,name=target" json:"target"`
|
||||
// CreatedAt is the time the image was first created.
|
||||
CreatedAt time.Time `protobuf:"bytes,7,opt,name=created_at,json=createdAt,stdtime" json:"created_at"`
|
||||
// UpdatedAt is the last time the image was mutated.
|
||||
UpdatedAt time.Time `protobuf:"bytes,8,opt,name=updated_at,json=updatedAt,stdtime" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (m *Image) Reset() { *m = Image{} }
|
||||
@ -75,13 +96,35 @@ func (m *GetImageResponse) Reset() { *m = GetImageResponse{}
|
||||
func (*GetImageResponse) ProtoMessage() {}
|
||||
func (*GetImageResponse) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{2} }
|
||||
|
||||
type UpdateImageRequest struct {
|
||||
type CreateImageRequest struct {
|
||||
Image Image `protobuf:"bytes,1,opt,name=image" json:"image"`
|
||||
}
|
||||
|
||||
func (m *CreateImageRequest) Reset() { *m = CreateImageRequest{} }
|
||||
func (*CreateImageRequest) ProtoMessage() {}
|
||||
func (*CreateImageRequest) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{3} }
|
||||
|
||||
type CreateImageResponse struct {
|
||||
Image Image `protobuf:"bytes,1,opt,name=image" json:"image"`
|
||||
}
|
||||
|
||||
func (m *CreateImageResponse) Reset() { *m = CreateImageResponse{} }
|
||||
func (*CreateImageResponse) ProtoMessage() {}
|
||||
func (*CreateImageResponse) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{4} }
|
||||
|
||||
type UpdateImageRequest struct {
|
||||
// Image provides a full or partial image for update.
|
||||
//
|
||||
// The name field must be set or an error will be returned.
|
||||
Image Image `protobuf:"bytes,1,opt,name=image" json:"image"`
|
||||
// UpdateMask specifies which fields to perform the update on. If empty,
|
||||
// the operation applies to all fields.
|
||||
UpdateMask *google_protobuf2.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask" json:"update_mask,omitempty"`
|
||||
}
|
||||
|
||||
func (m *UpdateImageRequest) Reset() { *m = UpdateImageRequest{} }
|
||||
func (*UpdateImageRequest) ProtoMessage() {}
|
||||
func (*UpdateImageRequest) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{3} }
|
||||
func (*UpdateImageRequest) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{5} }
|
||||
|
||||
type UpdateImageResponse struct {
|
||||
Image Image `protobuf:"bytes,1,opt,name=image" json:"image"`
|
||||
@ -89,15 +132,25 @@ type UpdateImageResponse struct {
|
||||
|
||||
func (m *UpdateImageResponse) Reset() { *m = UpdateImageResponse{} }
|
||||
func (*UpdateImageResponse) ProtoMessage() {}
|
||||
func (*UpdateImageResponse) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{4} }
|
||||
func (*UpdateImageResponse) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{6} }
|
||||
|
||||
type ListImagesRequest struct {
|
||||
Filter string `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"`
|
||||
// Filters contains one or more filters using the syntax defined in the
|
||||
// containerd filter package.
|
||||
//
|
||||
// The returned result will be those that match any of the provided
|
||||
// filters. Expanded, images that match the following will be
|
||||
// returned:
|
||||
//
|
||||
// filters[0] or filters[1] or ... or filters[n-1] or filters[n]
|
||||
//
|
||||
// If filters is zero-length or nil, all items will be returned.
|
||||
Filters []string `protobuf:"bytes,1,rep,name=filters" json:"filters,omitempty"`
|
||||
}
|
||||
|
||||
func (m *ListImagesRequest) Reset() { *m = ListImagesRequest{} }
|
||||
func (*ListImagesRequest) ProtoMessage() {}
|
||||
func (*ListImagesRequest) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{5} }
|
||||
func (*ListImagesRequest) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{7} }
|
||||
|
||||
type ListImagesResponse struct {
|
||||
Images []Image `protobuf:"bytes,1,rep,name=images" json:"images"`
|
||||
@ -105,7 +158,7 @@ type ListImagesResponse struct {
|
||||
|
||||
func (m *ListImagesResponse) Reset() { *m = ListImagesResponse{} }
|
||||
func (*ListImagesResponse) ProtoMessage() {}
|
||||
func (*ListImagesResponse) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{6} }
|
||||
func (*ListImagesResponse) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{8} }
|
||||
|
||||
type DeleteImageRequest struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
@ -113,12 +166,14 @@ type DeleteImageRequest struct {
|
||||
|
||||
func (m *DeleteImageRequest) Reset() { *m = DeleteImageRequest{} }
|
||||
func (*DeleteImageRequest) ProtoMessage() {}
|
||||
func (*DeleteImageRequest) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{7} }
|
||||
func (*DeleteImageRequest) Descriptor() ([]byte, []int) { return fileDescriptorImages, []int{9} }
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Image)(nil), "containerd.services.images.v1.Image")
|
||||
proto.RegisterType((*GetImageRequest)(nil), "containerd.services.images.v1.GetImageRequest")
|
||||
proto.RegisterType((*GetImageResponse)(nil), "containerd.services.images.v1.GetImageResponse")
|
||||
proto.RegisterType((*CreateImageRequest)(nil), "containerd.services.images.v1.CreateImageRequest")
|
||||
proto.RegisterType((*CreateImageResponse)(nil), "containerd.services.images.v1.CreateImageResponse")
|
||||
proto.RegisterType((*UpdateImageRequest)(nil), "containerd.services.images.v1.UpdateImageRequest")
|
||||
proto.RegisterType((*UpdateImageResponse)(nil), "containerd.services.images.v1.UpdateImageResponse")
|
||||
proto.RegisterType((*ListImagesRequest)(nil), "containerd.services.images.v1.ListImagesRequest")
|
||||
@ -141,6 +196,10 @@ type ImagesClient interface {
|
||||
Get(ctx context.Context, in *GetImageRequest, opts ...grpc.CallOption) (*GetImageResponse, error)
|
||||
// List returns a list of all images known to containerd.
|
||||
List(ctx context.Context, in *ListImagesRequest, opts ...grpc.CallOption) (*ListImagesResponse, error)
|
||||
// Create an image reocrd in the metadata store.
|
||||
//
|
||||
// The name of the image must be unique.
|
||||
Create(ctx context.Context, in *CreateImageRequest, opts ...grpc.CallOption) (*CreateImageResponse, error)
|
||||
// Update assigns the name to a given target image based on the provided
|
||||
// image.
|
||||
Update(ctx context.Context, in *UpdateImageRequest, opts ...grpc.CallOption) (*UpdateImageResponse, error)
|
||||
@ -174,6 +233,15 @@ func (c *imagesClient) List(ctx context.Context, in *ListImagesRequest, opts ...
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *imagesClient) Create(ctx context.Context, in *CreateImageRequest, opts ...grpc.CallOption) (*CreateImageResponse, error) {
|
||||
out := new(CreateImageResponse)
|
||||
err := grpc.Invoke(ctx, "/containerd.services.images.v1.Images/Create", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *imagesClient) Update(ctx context.Context, in *UpdateImageRequest, opts ...grpc.CallOption) (*UpdateImageResponse, error) {
|
||||
out := new(UpdateImageResponse)
|
||||
err := grpc.Invoke(ctx, "/containerd.services.images.v1.Images/Update", in, out, c.cc, opts...)
|
||||
@ -199,6 +267,10 @@ type ImagesServer interface {
|
||||
Get(context.Context, *GetImageRequest) (*GetImageResponse, error)
|
||||
// List returns a list of all images known to containerd.
|
||||
List(context.Context, *ListImagesRequest) (*ListImagesResponse, error)
|
||||
// Create an image reocrd in the metadata store.
|
||||
//
|
||||
// The name of the image must be unique.
|
||||
Create(context.Context, *CreateImageRequest) (*CreateImageResponse, error)
|
||||
// Update assigns the name to a given target image based on the provided
|
||||
// image.
|
||||
Update(context.Context, *UpdateImageRequest) (*UpdateImageResponse, error)
|
||||
@ -246,6 +318,24 @@ func _Images_List_Handler(srv interface{}, ctx context.Context, dec func(interfa
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Images_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateImageRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ImagesServer).Create(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/containerd.services.images.v1.Images/Create",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ImagesServer).Create(ctx, req.(*CreateImageRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Images_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateImageRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@ -294,6 +384,10 @@ var _Images_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "List",
|
||||
Handler: _Images_List_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Create",
|
||||
Handler: _Images_Create_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Update",
|
||||
Handler: _Images_Update_Handler,
|
||||
@ -353,6 +447,22 @@ func (m *Image) MarshalTo(dAtA []byte) (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
i += n1
|
||||
dAtA[i] = 0x3a
|
||||
i++
|
||||
i = encodeVarintImages(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.CreatedAt)))
|
||||
n2, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CreatedAt, dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n2
|
||||
dAtA[i] = 0x42
|
||||
i++
|
||||
i = encodeVarintImages(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt)))
|
||||
n3, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n3
|
||||
return i, nil
|
||||
}
|
||||
|
||||
@ -399,15 +509,67 @@ func (m *GetImageResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
dAtA[i] = 0xa
|
||||
i++
|
||||
i = encodeVarintImages(dAtA, i, uint64(m.Image.Size()))
|
||||
n2, err := m.Image.MarshalTo(dAtA[i:])
|
||||
n4, err := m.Image.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n2
|
||||
i += n4
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *CreateImageRequest) 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 *CreateImageRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||
var i int
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
dAtA[i] = 0xa
|
||||
i++
|
||||
i = encodeVarintImages(dAtA, i, uint64(m.Image.Size()))
|
||||
n5, err := m.Image.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n5
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *CreateImageResponse) 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 *CreateImageResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
var i int
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
dAtA[i] = 0xa
|
||||
i++
|
||||
i = encodeVarintImages(dAtA, i, uint64(m.Image.Size()))
|
||||
n6, err := m.Image.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n6
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *UpdateImageRequest) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
@ -426,11 +588,21 @@ func (m *UpdateImageRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||
dAtA[i] = 0xa
|
||||
i++
|
||||
i = encodeVarintImages(dAtA, i, uint64(m.Image.Size()))
|
||||
n3, err := m.Image.MarshalTo(dAtA[i:])
|
||||
n7, err := m.Image.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n3
|
||||
i += n7
|
||||
if m.UpdateMask != nil {
|
||||
dAtA[i] = 0x12
|
||||
i++
|
||||
i = encodeVarintImages(dAtA, i, uint64(m.UpdateMask.Size()))
|
||||
n8, err := m.UpdateMask.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n8
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
@ -452,11 +624,11 @@ func (m *UpdateImageResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
dAtA[i] = 0xa
|
||||
i++
|
||||
i = encodeVarintImages(dAtA, i, uint64(m.Image.Size()))
|
||||
n4, err := m.Image.MarshalTo(dAtA[i:])
|
||||
n9, err := m.Image.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n4
|
||||
i += n9
|
||||
return i, nil
|
||||
}
|
||||
|
||||
@ -475,11 +647,20 @@ func (m *ListImagesRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Filter) > 0 {
|
||||
dAtA[i] = 0xa
|
||||
i++
|
||||
i = encodeVarintImages(dAtA, i, uint64(len(m.Filter)))
|
||||
i += copy(dAtA[i:], m.Filter)
|
||||
if len(m.Filters) > 0 {
|
||||
for _, s := range m.Filters {
|
||||
dAtA[i] = 0xa
|
||||
i++
|
||||
l = len(s)
|
||||
for l >= 1<<7 {
|
||||
dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
|
||||
l >>= 7
|
||||
i++
|
||||
}
|
||||
dAtA[i] = uint8(l)
|
||||
i++
|
||||
i += copy(dAtA[i:], s)
|
||||
}
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
@ -582,6 +763,10 @@ func (m *Image) Size() (n int) {
|
||||
}
|
||||
l = m.Target.Size()
|
||||
n += 1 + l + sovImages(uint64(l))
|
||||
l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CreatedAt)
|
||||
n += 1 + l + sovImages(uint64(l))
|
||||
l = github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt)
|
||||
n += 1 + l + sovImages(uint64(l))
|
||||
return n
|
||||
}
|
||||
|
||||
@ -605,11 +790,31 @@ func (m *GetImageResponse) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *CreateImageRequest) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
l = m.Image.Size()
|
||||
n += 1 + l + sovImages(uint64(l))
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *CreateImageResponse) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
l = m.Image.Size()
|
||||
n += 1 + l + sovImages(uint64(l))
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *UpdateImageRequest) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
l = m.Image.Size()
|
||||
n += 1 + l + sovImages(uint64(l))
|
||||
if m.UpdateMask != nil {
|
||||
l = m.UpdateMask.Size()
|
||||
n += 1 + l + sovImages(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@ -624,9 +829,11 @@ func (m *UpdateImageResponse) Size() (n int) {
|
||||
func (m *ListImagesRequest) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Filter)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovImages(uint64(l))
|
||||
if len(m.Filters) > 0 {
|
||||
for _, s := range m.Filters {
|
||||
l = len(s)
|
||||
n += 1 + l + sovImages(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
@ -684,6 +891,8 @@ func (this *Image) String() string {
|
||||
`Name:` + fmt.Sprintf("%v", this.Name) + `,`,
|
||||
`Labels:` + mapStringForLabels + `,`,
|
||||
`Target:` + strings.Replace(strings.Replace(this.Target.String(), "Descriptor", "containerd_types.Descriptor", 1), `&`, ``, 1) + `,`,
|
||||
`CreatedAt:` + strings.Replace(strings.Replace(this.CreatedAt.String(), "Timestamp", "google_protobuf3.Timestamp", 1), `&`, ``, 1) + `,`,
|
||||
`UpdatedAt:` + strings.Replace(strings.Replace(this.UpdatedAt.String(), "Timestamp", "google_protobuf3.Timestamp", 1), `&`, ``, 1) + `,`,
|
||||
`}`,
|
||||
}, "")
|
||||
return s
|
||||
@ -708,12 +917,33 @@ func (this *GetImageResponse) String() string {
|
||||
}, "")
|
||||
return s
|
||||
}
|
||||
func (this *CreateImageRequest) String() string {
|
||||
if this == nil {
|
||||
return "nil"
|
||||
}
|
||||
s := strings.Join([]string{`&CreateImageRequest{`,
|
||||
`Image:` + strings.Replace(strings.Replace(this.Image.String(), "Image", "Image", 1), `&`, ``, 1) + `,`,
|
||||
`}`,
|
||||
}, "")
|
||||
return s
|
||||
}
|
||||
func (this *CreateImageResponse) String() string {
|
||||
if this == nil {
|
||||
return "nil"
|
||||
}
|
||||
s := strings.Join([]string{`&CreateImageResponse{`,
|
||||
`Image:` + strings.Replace(strings.Replace(this.Image.String(), "Image", "Image", 1), `&`, ``, 1) + `,`,
|
||||
`}`,
|
||||
}, "")
|
||||
return s
|
||||
}
|
||||
func (this *UpdateImageRequest) String() string {
|
||||
if this == nil {
|
||||
return "nil"
|
||||
}
|
||||
s := strings.Join([]string{`&UpdateImageRequest{`,
|
||||
`Image:` + strings.Replace(strings.Replace(this.Image.String(), "Image", "Image", 1), `&`, ``, 1) + `,`,
|
||||
`UpdateMask:` + strings.Replace(fmt.Sprintf("%v", this.UpdateMask), "FieldMask", "google_protobuf2.FieldMask", 1) + `,`,
|
||||
`}`,
|
||||
}, "")
|
||||
return s
|
||||
@ -733,7 +963,7 @@ func (this *ListImagesRequest) String() string {
|
||||
return "nil"
|
||||
}
|
||||
s := strings.Join([]string{`&ListImagesRequest{`,
|
||||
`Filter:` + fmt.Sprintf("%v", this.Filter) + `,`,
|
||||
`Filters:` + fmt.Sprintf("%v", this.Filters) + `,`,
|
||||
`}`,
|
||||
}, "")
|
||||
return s
|
||||
@ -970,6 +1200,66 @@ func (m *Image) Unmarshal(dAtA []byte) error {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 7:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowImages
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthImages
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.CreatedAt, dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 8:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowImages
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthImages
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.UpdatedAt, dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipImages(dAtA[iNdEx:])
|
||||
@ -1153,6 +1443,166 @@ func (m *GetImageResponse) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *CreateImageRequest) 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 ErrIntOverflowImages
|
||||
}
|
||||
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: CreateImageRequest: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: CreateImageRequest: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowImages
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthImages
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := m.Image.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipImages(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthImages
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *CreateImageResponse) 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 ErrIntOverflowImages
|
||||
}
|
||||
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: CreateImageResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: CreateImageResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowImages
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthImages
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := m.Image.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipImages(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthImages
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *UpdateImageRequest) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
@ -1212,6 +1662,39 @@ func (m *UpdateImageRequest) Unmarshal(dAtA []byte) error {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field UpdateMask", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowImages
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthImages
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.UpdateMask == nil {
|
||||
m.UpdateMask = &google_protobuf2.FieldMask{}
|
||||
}
|
||||
if err := m.UpdateMask.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipImages(dAtA[iNdEx:])
|
||||
@ -1344,7 +1827,7 @@ func (m *ListImagesRequest) Unmarshal(dAtA []byte) error {
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Filter", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Filters", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
@ -1369,7 +1852,7 @@ func (m *ListImagesRequest) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Filter = string(dAtA[iNdEx:postIndex])
|
||||
m.Filters = append(m.Filters, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
@ -1662,38 +2145,46 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptorImages = []byte{
|
||||
// 518 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4f, 0x8b, 0xd3, 0x40,
|
||||
0x14, 0xef, 0xf4, 0x4f, 0xc0, 0xd7, 0x83, 0xeb, 0xb8, 0x2c, 0x25, 0x6a, 0x2c, 0x41, 0xa1, 0x20,
|
||||
0x4c, 0x6c, 0xbc, 0x68, 0x17, 0x44, 0x4a, 0x97, 0x55, 0x58, 0x3c, 0x44, 0xd4, 0xc5, 0x5b, 0xda,
|
||||
0xbe, 0xc6, 0xb0, 0x69, 0x26, 0x66, 0xa6, 0x85, 0xde, 0xfc, 0x2e, 0x7e, 0x99, 0x1e, 0x3d, 0x7a,
|
||||
0x10, 0x71, 0xfb, 0x49, 0x24, 0x33, 0x53, 0xb7, 0xbb, 0x5d, 0x6c, 0xbb, 0xde, 0xde, 0xb4, 0xbf,
|
||||
0x7f, 0xef, 0xcd, 0xe4, 0x41, 0x2f, 0x8a, 0xe5, 0xe7, 0x49, 0x9f, 0x0d, 0xf8, 0xd8, 0x1b, 0xf0,
|
||||
0x54, 0x86, 0x71, 0x8a, 0xf9, 0x70, 0xb5, 0x0c, 0xb3, 0xd8, 0x13, 0x98, 0x4f, 0xe3, 0x01, 0x0a,
|
||||
0x2f, 0x1e, 0x87, 0x11, 0x0a, 0x6f, 0xda, 0x36, 0x15, 0xcb, 0x72, 0x2e, 0x39, 0x7d, 0x70, 0x81,
|
||||
0x67, 0x4b, 0x2c, 0x33, 0x88, 0x69, 0xdb, 0xde, 0x8f, 0x78, 0xc4, 0x15, 0xd2, 0x2b, 0x2a, 0x4d,
|
||||
0xb2, 0xef, 0x45, 0x9c, 0x47, 0x09, 0x7a, 0xea, 0xd4, 0x9f, 0x8c, 0x3c, 0x1c, 0x67, 0x72, 0x66,
|
||||
0xfe, 0x3c, 0xdc, 0x2a, 0x97, 0x9c, 0x65, 0x28, 0xbc, 0x21, 0x8a, 0x41, 0x1e, 0x67, 0x92, 0xe7,
|
||||
0x9a, 0xec, 0xfe, 0x24, 0x50, 0x7b, 0x53, 0xb8, 0x53, 0x0a, 0xd5, 0x34, 0x1c, 0x63, 0x83, 0x34,
|
||||
0x49, 0xeb, 0x56, 0xa0, 0x6a, 0xfa, 0x1a, 0xac, 0x24, 0xec, 0x63, 0x22, 0x1a, 0xe5, 0x66, 0xa5,
|
||||
0x55, 0xf7, 0x9f, 0xb2, 0x7f, 0xa6, 0x67, 0x4a, 0x89, 0x9d, 0x28, 0xca, 0x51, 0x2a, 0xf3, 0x59,
|
||||
0x60, 0xf8, 0xb4, 0x03, 0x96, 0x0c, 0xf3, 0x08, 0x65, 0xa3, 0xd2, 0x24, 0xad, 0xba, 0x7f, 0x7f,
|
||||
0x55, 0x49, 0x65, 0x63, 0xbd, 0xbf, 0xd9, 0xba, 0xd5, 0xf9, 0xaf, 0x87, 0xa5, 0xc0, 0x30, 0xec,
|
||||
0x17, 0x50, 0x5f, 0x91, 0xa4, 0x7b, 0x50, 0x39, 0xc3, 0x99, 0xc9, 0x59, 0x94, 0x74, 0x1f, 0x6a,
|
||||
0xd3, 0x30, 0x99, 0x60, 0xa3, 0xac, 0x7e, 0xd3, 0x87, 0x4e, 0xf9, 0x39, 0x71, 0x1f, 0xc3, 0xed,
|
||||
0x63, 0x94, 0x2a, 0x56, 0x80, 0x5f, 0x26, 0x28, 0xe4, 0x75, 0x7d, 0xba, 0x6f, 0x61, 0xef, 0x02,
|
||||
0x26, 0x32, 0x9e, 0x0a, 0xa4, 0x1d, 0xa8, 0xa9, 0xc6, 0x14, 0xb0, 0xee, 0x3f, 0xda, 0xa6, 0xf5,
|
||||
0x40, 0x53, 0xdc, 0x0f, 0x40, 0xdf, 0x67, 0xc3, 0x50, 0xe2, 0x25, 0xe7, 0x57, 0x37, 0x50, 0x34,
|
||||
0xa3, 0x30, 0xba, 0x1f, 0xe1, 0xee, 0x25, 0x5d, 0x13, 0xf5, 0xff, 0x85, 0x9f, 0xc0, 0x9d, 0x93,
|
||||
0x58, 0xe8, 0x09, 0x88, 0x65, 0xde, 0x03, 0xb0, 0x46, 0x71, 0x22, 0x31, 0x37, 0xb3, 0x32, 0x27,
|
||||
0xf7, 0x14, 0xe8, 0x2a, 0xd8, 0x84, 0xe8, 0x82, 0xa5, 0x2d, 0x1a, 0x44, 0xbd, 0x95, 0x5d, 0x52,
|
||||
0x18, 0xa6, 0xdb, 0x02, 0xda, 0xc3, 0x04, 0xaf, 0xcc, 0xed, 0x9a, 0x1b, 0xf3, 0xbf, 0x55, 0xc0,
|
||||
0xd2, 0x01, 0xe8, 0x08, 0x2a, 0xc7, 0x28, 0x29, 0xdb, 0xe0, 0x77, 0xe5, 0x1d, 0xd8, 0xde, 0xd6,
|
||||
0x78, 0xd3, 0xe0, 0x19, 0x54, 0x8b, 0xb6, 0xe9, 0xa6, 0x8f, 0x60, 0x6d, 0x90, 0x76, 0x7b, 0x07,
|
||||
0x86, 0x31, 0xe3, 0x60, 0xe9, 0x9b, 0xa6, 0x9b, 0xc8, 0xeb, 0x0f, 0xcd, 0xf6, 0x77, 0xa1, 0x18,
|
||||
0xc3, 0x77, 0x60, 0xe9, 0xd1, 0x6f, 0x34, 0x5c, 0xbf, 0x21, 0xfb, 0x80, 0xe9, 0x05, 0xc5, 0x96,
|
||||
0x0b, 0x8a, 0x1d, 0x15, 0x0b, 0xaa, 0x7b, 0x3a, 0x3f, 0x77, 0x4a, 0x3f, 0xce, 0x9d, 0xd2, 0xd7,
|
||||
0x85, 0x43, 0xe6, 0x0b, 0x87, 0x7c, 0x5f, 0x38, 0xe4, 0xf7, 0xc2, 0x21, 0x9f, 0x5e, 0xde, 0x70,
|
||||
0x99, 0x1e, 0xea, 0xaa, 0x6f, 0x29, 0xa7, 0x67, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x0f,
|
||||
0x7b, 0x86, 0x95, 0x05, 0x00, 0x00,
|
||||
// 648 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4f, 0x6f, 0xd3, 0x4e,
|
||||
0x10, 0xad, 0x93, 0xd4, 0x6d, 0x27, 0x87, 0x5f, 0x7f, 0x4b, 0x85, 0x2c, 0x03, 0x69, 0x14, 0x81,
|
||||
0x94, 0x0b, 0x6b, 0x1a, 0x2e, 0xd0, 0x4a, 0x88, 0xa6, 0x2d, 0x05, 0xa9, 0x70, 0x30, 0xff, 0x2a,
|
||||
0x2e, 0xd5, 0x26, 0x99, 0x18, 0x2b, 0x76, 0x6c, 0xbc, 0x9b, 0x48, 0xb9, 0xf1, 0x11, 0x90, 0xe0,
|
||||
0x43, 0xf5, 0xc8, 0x91, 0x13, 0xd0, 0x1c, 0xf8, 0x1c, 0xc8, 0xbb, 0x1b, 0x9a, 0x26, 0x11, 0x4e,
|
||||
0x4a, 0x6f, 0xe3, 0xf8, 0xbd, 0x79, 0x33, 0x6f, 0x66, 0x62, 0xd8, 0xf7, 0x7c, 0xf1, 0xbe, 0xd7,
|
||||
0xa0, 0xcd, 0x28, 0x74, 0x9a, 0x51, 0x57, 0x30, 0xbf, 0x8b, 0x49, 0x6b, 0x3c, 0x64, 0xb1, 0xef,
|
||||
0x70, 0x4c, 0xfa, 0x7e, 0x13, 0xb9, 0xe3, 0x87, 0xcc, 0x43, 0xee, 0xf4, 0xb7, 0x74, 0x44, 0xe3,
|
||||
0x24, 0x12, 0x11, 0xb9, 0x75, 0x8e, 0xa7, 0x23, 0x2c, 0xd5, 0x88, 0xfe, 0x96, 0xbd, 0xe1, 0x45,
|
||||
0x5e, 0x24, 0x91, 0x4e, 0x1a, 0x29, 0x92, 0x7d, 0xc3, 0x8b, 0x22, 0x2f, 0x40, 0x47, 0x3e, 0x35,
|
||||
0x7a, 0x6d, 0x07, 0xc3, 0x58, 0x0c, 0xf4, 0xcb, 0xf2, 0xe4, 0xcb, 0xb6, 0x8f, 0x41, 0xeb, 0x24,
|
||||
0x64, 0xbc, 0xa3, 0x11, 0x9b, 0x93, 0x08, 0xe1, 0x87, 0xc8, 0x05, 0x0b, 0x63, 0x0d, 0xd8, 0x99,
|
||||
0xab, 0x35, 0x31, 0x88, 0x91, 0x3b, 0x2d, 0xe4, 0xcd, 0xc4, 0x8f, 0x45, 0x94, 0x28, 0x72, 0xe5,
|
||||
0x57, 0x0e, 0x96, 0x9f, 0xa5, 0x0d, 0x10, 0x02, 0x85, 0x2e, 0x0b, 0xd1, 0x32, 0xca, 0x46, 0x75,
|
||||
0xcd, 0x95, 0x31, 0x79, 0x0a, 0x66, 0xc0, 0x1a, 0x18, 0x70, 0x2b, 0x57, 0xce, 0x57, 0x8b, 0xb5,
|
||||
0x7b, 0xf4, 0xaf, 0x06, 0x50, 0x99, 0x89, 0x1e, 0x49, 0xca, 0x41, 0x57, 0x24, 0x03, 0x57, 0xf3,
|
||||
0xc9, 0x36, 0x98, 0x82, 0x25, 0x1e, 0x0a, 0x2b, 0x5f, 0x36, 0xaa, 0xc5, 0xda, 0xcd, 0xf1, 0x4c,
|
||||
0xb2, 0x36, 0xba, 0xff, 0xa7, 0xb6, 0x7a, 0xe1, 0xf4, 0xfb, 0xe6, 0x92, 0xab, 0x19, 0x64, 0x0f,
|
||||
0xa0, 0x99, 0x20, 0x13, 0xd8, 0x3a, 0x61, 0xc2, 0x5a, 0x91, 0x7c, 0x9b, 0x2a, 0x5b, 0xe8, 0xc8,
|
||||
0x16, 0xfa, 0x6a, 0x64, 0x4b, 0x7d, 0x35, 0x65, 0x7f, 0xfa, 0xb1, 0x69, 0xb8, 0x6b, 0x9a, 0xb7,
|
||||
0x2b, 0x93, 0xf4, 0xe2, 0xd6, 0x28, 0xc9, 0xea, 0x22, 0x49, 0x34, 0x6f, 0x57, 0xd8, 0x0f, 0xa1,
|
||||
0x38, 0xd6, 0x1c, 0x59, 0x87, 0x7c, 0x07, 0x07, 0xda, 0xb1, 0x34, 0x24, 0x1b, 0xb0, 0xdc, 0x67,
|
||||
0x41, 0x0f, 0xad, 0x9c, 0xfc, 0x4d, 0x3d, 0x6c, 0xe7, 0x1e, 0x18, 0x95, 0x3b, 0xf0, 0xdf, 0x21,
|
||||
0x0a, 0x69, 0x90, 0x8b, 0x1f, 0x7a, 0xc8, 0xc5, 0x2c, 0xc7, 0x2b, 0x2f, 0x60, 0xfd, 0x1c, 0xc6,
|
||||
0xe3, 0xa8, 0xcb, 0x91, 0x6c, 0xc3, 0xb2, 0xb4, 0x58, 0x02, 0x8b, 0xb5, 0xdb, 0xf3, 0x0c, 0xc1,
|
||||
0x55, 0x94, 0xca, 0x1b, 0x20, 0x7b, 0xd2, 0x83, 0x0b, 0xca, 0x8f, 0x2f, 0x91, 0x51, 0x0f, 0x45,
|
||||
0xe7, 0x7d, 0x0b, 0xd7, 0x2e, 0xe4, 0xd5, 0xa5, 0xfe, 0x7b, 0xe2, 0xcf, 0x06, 0x90, 0xd7, 0xd2,
|
||||
0xf0, 0xab, 0xad, 0x98, 0xec, 0x40, 0x51, 0x0d, 0x52, 0x1e, 0x97, 0x1c, 0xd0, 0xac, 0x0d, 0x78,
|
||||
0x92, 0xde, 0xdf, 0x73, 0xc6, 0x3b, 0xae, 0xde, 0x97, 0x34, 0x4e, 0xdb, 0xbd, 0x50, 0xd4, 0x95,
|
||||
0xb5, 0x7b, 0x17, 0xfe, 0x3f, 0xf2, 0xb9, 0x1a, 0x38, 0x1f, 0x35, 0x6b, 0xc1, 0x4a, 0xdb, 0x0f,
|
||||
0x04, 0x26, 0xdc, 0x32, 0xca, 0xf9, 0xea, 0x9a, 0x3b, 0x7a, 0xac, 0x1c, 0x03, 0x19, 0x87, 0xeb,
|
||||
0x32, 0xea, 0x60, 0x2a, 0x11, 0x09, 0x5f, 0xac, 0x0e, 0xcd, 0xac, 0x54, 0x81, 0xec, 0x63, 0x80,
|
||||
0x13, 0xb6, 0xcf, 0x58, 0xd1, 0xda, 0x97, 0x02, 0x98, 0xaa, 0x00, 0xd2, 0x86, 0xfc, 0x21, 0x0a,
|
||||
0x42, 0x33, 0xf4, 0x26, 0x16, 0xdf, 0x76, 0xe6, 0xc6, 0xeb, 0x06, 0x3b, 0x50, 0x48, 0xdb, 0x26,
|
||||
0x59, 0xff, 0x3f, 0x53, 0x56, 0xda, 0x5b, 0x0b, 0x30, 0xb4, 0x58, 0x04, 0xa6, 0x5a, 0x6d, 0x92,
|
||||
0x45, 0x9e, 0xbe, 0x2c, 0xbb, 0xb6, 0x08, 0xe5, 0x5c, 0x50, 0x2d, 0x57, 0xa6, 0xe0, 0xf4, 0x61,
|
||||
0x64, 0x0a, 0xce, 0x5a, 0xdb, 0x97, 0x60, 0xaa, 0x59, 0x67, 0x0a, 0x4e, 0xaf, 0x84, 0x7d, 0x7d,
|
||||
0xea, 0x64, 0x0e, 0xd2, 0xef, 0x59, 0xfd, 0xf8, 0xf4, 0xac, 0xb4, 0xf4, 0xed, 0xac, 0xb4, 0xf4,
|
||||
0x71, 0x58, 0x32, 0x4e, 0x87, 0x25, 0xe3, 0xeb, 0xb0, 0x64, 0xfc, 0x1c, 0x96, 0x8c, 0x77, 0x8f,
|
||||
0x2e, 0xf9, 0xed, 0xdd, 0x51, 0x51, 0xc3, 0x94, 0x4a, 0xf7, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff,
|
||||
0x74, 0x4c, 0xf0, 0x24, 0xc4, 0x07, 0x00, 0x00,
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ package containerd.services.images.v1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "github.com/containerd/containerd/api/types/descriptor.proto";
|
||||
|
||||
option go_package = "github.com/containerd/containerd/api/services/images/v1;images";
|
||||
@ -26,6 +28,11 @@ service Images {
|
||||
// List returns a list of all images known to containerd.
|
||||
rpc List(ListImagesRequest) returns (ListImagesResponse);
|
||||
|
||||
// Create an image record in the metadata store.
|
||||
//
|
||||
// The name of the image must be unique.
|
||||
rpc Create(CreateImageRequest) returns (CreateImageResponse);
|
||||
|
||||
// Update assigns the name to a given target image based on the provided
|
||||
// image.
|
||||
rpc Update(UpdateImageRequest) returns (UpdateImageResponse);
|
||||
@ -35,9 +42,25 @@ service Images {
|
||||
}
|
||||
|
||||
message Image {
|
||||
// Name provides a unique name for the image.
|
||||
//
|
||||
// Containerd treats this as the primary identifier.
|
||||
string name = 1;
|
||||
|
||||
// Labels provides free form labels for the image. These are runtime only
|
||||
// and do not get inherited into the package image in any way.
|
||||
//
|
||||
// Labels may be updated using the field mask.
|
||||
map<string, string> labels = 2;
|
||||
|
||||
// Target describes the content entry point of the image.
|
||||
containerd.types.Descriptor target = 3 [(gogoproto.nullable) = false];
|
||||
|
||||
// CreatedAt is the time the image was first created.
|
||||
google.protobuf.Timestamp created_at = 7 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||
|
||||
// UpdatedAt is the last time the image was mutated.
|
||||
google.protobuf.Timestamp updated_at = 8 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
message GetImageRequest {
|
||||
@ -48,16 +71,41 @@ message GetImageResponse {
|
||||
Image image = 1;
|
||||
}
|
||||
|
||||
message UpdateImageRequest {
|
||||
message CreateImageRequest {
|
||||
Image image = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
message CreateImageResponse {
|
||||
Image image = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
message UpdateImageRequest {
|
||||
// Image provides a full or partial image for update.
|
||||
//
|
||||
// The name field must be set or an error will be returned.
|
||||
Image image = 1 [(gogoproto.nullable) = false];
|
||||
|
||||
// UpdateMask specifies which fields to perform the update on. If empty,
|
||||
// the operation applies to all fields.
|
||||
google.protobuf.FieldMask update_mask = 2;
|
||||
}
|
||||
|
||||
message UpdateImageResponse {
|
||||
Image image = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
message ListImagesRequest {
|
||||
string filter = 1;
|
||||
// Filters contains one or more filters using the syntax defined in the
|
||||
// containerd filter package.
|
||||
//
|
||||
// The returned result will be those that match any of the provided
|
||||
// filters. Expanded, images that match the following will be
|
||||
// returned:
|
||||
//
|
||||
// filters[0] or filters[1] or ... or filters[n-1] or filters[n]
|
||||
//
|
||||
// If filters is zero-length or nil, all items will be returned.
|
||||
repeated string filters = 1;
|
||||
}
|
||||
|
||||
message ListImagesResponse {
|
||||
|
28
client.go
28
client.go
@ -21,6 +21,7 @@ import (
|
||||
"github.com/containerd/containerd/api/services/tasks/v1"
|
||||
versionservice "github.com/containerd/containerd/api/services/version/v1"
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/images"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/remotes"
|
||||
@ -365,17 +366,30 @@ func (c *Client) Pull(ctx context.Context, ref string, opts ...RemoteOpts) (Imag
|
||||
}
|
||||
}
|
||||
|
||||
imgrec := images.Image{
|
||||
Name: name,
|
||||
Target: desc,
|
||||
}
|
||||
|
||||
is := c.ImageService()
|
||||
if err := is.Update(ctx, name, desc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
i, err := is.Get(ctx, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if updated, err := is.Update(ctx, imgrec, "target"); err != nil {
|
||||
if !errdefs.IsNotFound(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
created, err := is.Create(ctx, imgrec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
imgrec = created
|
||||
} else {
|
||||
imgrec = updated
|
||||
}
|
||||
|
||||
img := &image{
|
||||
client: c,
|
||||
i: i,
|
||||
i: imgrec,
|
||||
}
|
||||
if pullCtx.Unpack {
|
||||
if err := img.Unpack(ctx); err != nil {
|
||||
|
109
cmd/dist/images.go
vendored
109
cmd/dist/images.go
vendored
@ -3,9 +3,12 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/images"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/progress"
|
||||
"github.com/pkg/errors"
|
||||
@ -18,6 +21,7 @@ var imageCommand = cli.Command{
|
||||
Subcommands: cli.Commands{
|
||||
imagesListCommand,
|
||||
imageRemoveCommand,
|
||||
imagesSetLabelsCommand,
|
||||
},
|
||||
}
|
||||
|
||||
@ -29,7 +33,10 @@ var imagesListCommand = cli.Command{
|
||||
Description: `List images registered with containerd.`,
|
||||
Flags: []cli.Flag{},
|
||||
Action: func(clicontext *cli.Context) error {
|
||||
ctx, cancel := appContext(clicontext)
|
||||
var (
|
||||
filters = clicontext.Args()
|
||||
ctx, cancel = appContext(clicontext)
|
||||
)
|
||||
defer cancel()
|
||||
|
||||
client, err := getClient(clicontext)
|
||||
@ -40,26 +47,93 @@ var imagesListCommand = cli.Command{
|
||||
imageStore := client.ImageService()
|
||||
cs := client.ContentStore()
|
||||
|
||||
images, err := imageStore.List(ctx)
|
||||
images, err := imageStore.List(ctx, filters...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to list images")
|
||||
}
|
||||
|
||||
tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, ' ', 0)
|
||||
fmt.Fprintln(tw, "REF\tTYPE\tDIGEST\tSIZE\t")
|
||||
fmt.Fprintln(tw, "REF\tTYPE\tDIGEST\tSIZE\tLABELS\t")
|
||||
for _, image := range images {
|
||||
size, err := image.Size(ctx, cs)
|
||||
if err != nil {
|
||||
log.G(ctx).WithError(err).Errorf("failed calculating size for image %s", image.Name)
|
||||
}
|
||||
|
||||
fmt.Fprintf(tw, "%v\t%v\t%v\t%v\t\n", image.Name, image.Target.MediaType, image.Target.Digest, progress.Bytes(size))
|
||||
labels := "-"
|
||||
if len(image.Labels) > 0 {
|
||||
var pairs []string
|
||||
for k, v := range image.Labels {
|
||||
pairs = append(pairs, fmt.Sprintf("%v=%v", k, v))
|
||||
}
|
||||
sort.Strings(pairs)
|
||||
labels = strings.Join(pairs, ",")
|
||||
}
|
||||
|
||||
fmt.Fprintf(tw, "%v\t%v\t%v\t%v\t%s\t\n",
|
||||
image.Name,
|
||||
image.Target.MediaType,
|
||||
image.Target.Digest,
|
||||
progress.Bytes(size),
|
||||
labels)
|
||||
}
|
||||
|
||||
return tw.Flush()
|
||||
},
|
||||
}
|
||||
|
||||
var imagesSetLabelsCommand = cli.Command{
|
||||
Name: "set-labels",
|
||||
Usage: "Set and clear labels for an image.",
|
||||
ArgsUsage: "[flags] <name> [<key>=<value>, ...]",
|
||||
Description: "Set and clear labels for an image.",
|
||||
Flags: []cli.Flag{},
|
||||
Action: func(clicontext *cli.Context) error {
|
||||
var (
|
||||
ctx, cancel = appContext(clicontext)
|
||||
name, labels = objectWithLabelArgs(clicontext)
|
||||
)
|
||||
defer cancel()
|
||||
|
||||
client, err := getClient(clicontext)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if name == "" {
|
||||
return errors.New("please specify an image")
|
||||
}
|
||||
|
||||
var (
|
||||
is = client.ImageService()
|
||||
fieldpaths []string
|
||||
)
|
||||
|
||||
for k := range labels {
|
||||
fieldpaths = append(fieldpaths, strings.Join([]string{"labels", k}, "."))
|
||||
}
|
||||
|
||||
image := images.Image{
|
||||
Name: name,
|
||||
Labels: labels,
|
||||
}
|
||||
|
||||
updated, err := is.Update(ctx, image, fieldpaths...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var labelStrings []string
|
||||
for k, v := range updated.Labels {
|
||||
labelStrings = append(labelStrings, fmt.Sprintf("%s=%s", k, v))
|
||||
}
|
||||
|
||||
fmt.Println(strings.Join(labelStrings, ","))
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var imageRemoveCommand = cli.Command{
|
||||
Name: "remove",
|
||||
Aliases: []string{"rm"},
|
||||
@ -98,3 +172,30 @@ var imageRemoveCommand = cli.Command{
|
||||
return exitErr
|
||||
},
|
||||
}
|
||||
|
||||
// TODO(stevvooe): These helpers should go away when we merge dist and ctr.
|
||||
|
||||
func objectWithLabelArgs(clicontext *cli.Context) (string, map[string]string) {
|
||||
var (
|
||||
name = clicontext.Args().First()
|
||||
labelStrings = clicontext.Args().Tail()
|
||||
)
|
||||
|
||||
return name, labelArgs(labelStrings)
|
||||
}
|
||||
|
||||
func labelArgs(labelStrings []string) map[string]string {
|
||||
labels := make(map[string]string, len(labelStrings))
|
||||
for _, label := range labelStrings {
|
||||
parts := strings.SplitN(label, "=", 2)
|
||||
key := parts[0]
|
||||
value := "true"
|
||||
if len(parts) > 1 {
|
||||
value = parts[1]
|
||||
}
|
||||
|
||||
labels[key] = value
|
||||
}
|
||||
|
||||
return labels
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd/filters"
|
||||
"github.com/gogo/protobuf/types"
|
||||
)
|
||||
|
||||
@ -32,9 +31,15 @@ type Store interface {
|
||||
Get(ctx context.Context, id string) (Container, error)
|
||||
|
||||
// List returns containers that match one or more of the provided filters.
|
||||
List(ctx context.Context, filters ...filters.Filter) ([]Container, error)
|
||||
List(ctx context.Context, filters ...string) ([]Container, error)
|
||||
|
||||
Create(ctx context.Context, container Container) (Container, error)
|
||||
Update(ctx context.Context, container Container) (Container, error)
|
||||
|
||||
// Update the container with the provided container object. ID must be set.
|
||||
//
|
||||
// If one or more fieldpaths are provided, only the field corresponding to
|
||||
// the fieldpaths will be mutated.
|
||||
Update(ctx context.Context, container Container, fieldpaths ...string) (Container, error)
|
||||
|
||||
Delete(ctx context.Context, id string) error
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"strconv"
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@ -42,6 +43,28 @@ func Parse(s string) (Filter, error) {
|
||||
return p.parse()
|
||||
}
|
||||
|
||||
// ParseAll parses each filter in ss and returns a filter that will return true
|
||||
// if any filter matches the expression.
|
||||
//
|
||||
// If no fitlers are provided, the filter will match anything.
|
||||
func ParseAll(ss ...string) (Filter, error) {
|
||||
if len(ss) == 0 {
|
||||
return Always, nil
|
||||
}
|
||||
|
||||
var fs []Filter
|
||||
for _, s := range ss {
|
||||
f, err := Parse(s)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(errdefs.ErrInvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
fs = append(fs, f)
|
||||
}
|
||||
|
||||
return Any(fs), nil
|
||||
}
|
||||
|
||||
type parser struct {
|
||||
input string
|
||||
scanner scanner
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd/content"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
@ -13,14 +14,21 @@ import (
|
||||
|
||||
// Image provides the model for how containerd views container images.
|
||||
type Image struct {
|
||||
Name string
|
||||
Target ocispec.Descriptor
|
||||
Name string
|
||||
Labels map[string]string
|
||||
Target ocispec.Descriptor
|
||||
CreatedAt, UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type Store interface {
|
||||
Update(ctx context.Context, name string, desc ocispec.Descriptor) error
|
||||
Get(ctx context.Context, name string) (Image, error)
|
||||
List(ctx context.Context) ([]Image, error)
|
||||
List(ctx context.Context, filters ...string) ([]Image, error)
|
||||
Create(ctx context.Context, image Image) (Image, error)
|
||||
|
||||
// Update will replace the data in the store with the provided image. If
|
||||
// one or more fieldpaths are provided, only those fields will be updated.
|
||||
Update(ctx context.Context, image Image, fieldpaths ...string) (Image, error)
|
||||
|
||||
Delete(ctx context.Context, name string) error
|
||||
}
|
||||
|
||||
|
79
metadata/adaptors.go
Normal file
79
metadata/adaptors.go
Normal file
@ -0,0 +1,79 @@
|
||||
package metadata
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/filters"
|
||||
"github.com/containerd/containerd/images"
|
||||
)
|
||||
|
||||
func adaptImage(o interface{}) filters.Adaptor {
|
||||
obj := o.(images.Image)
|
||||
return filters.AdapterFunc(func(fieldpath []string) (string, bool) {
|
||||
if len(fieldpath) == 0 {
|
||||
return "", false
|
||||
}
|
||||
|
||||
switch fieldpath[0] {
|
||||
case "name":
|
||||
return obj.Name, len(obj.Name) > 0
|
||||
case "target":
|
||||
if len(fieldpath) < 2 {
|
||||
return "", false
|
||||
}
|
||||
|
||||
switch fieldpath[1] {
|
||||
case "digest":
|
||||
return obj.Target.Digest.String(), len(obj.Target.Digest) > 0
|
||||
case "mediatype":
|
||||
return obj.Target.MediaType, len(obj.Target.MediaType) > 0
|
||||
}
|
||||
case "labels":
|
||||
return checkMap(fieldpath[1:], obj.Labels)
|
||||
// TODO(stevvooe): Greater/Less than filters would be awesome for
|
||||
// size. Let's do it!
|
||||
}
|
||||
|
||||
return "", false
|
||||
})
|
||||
}
|
||||
func adaptContainer(o interface{}) filters.Adaptor {
|
||||
obj := o.(containers.Container)
|
||||
return filters.AdapterFunc(func(fieldpath []string) (string, bool) {
|
||||
if len(fieldpath) == 0 {
|
||||
return "", false
|
||||
}
|
||||
|
||||
switch fieldpath[0] {
|
||||
case "id":
|
||||
return obj.ID, len(obj.ID) > 0
|
||||
case "runtime":
|
||||
if len(fieldpath) <= 1 {
|
||||
return "", false
|
||||
}
|
||||
|
||||
switch fieldpath[1] {
|
||||
case "name":
|
||||
return obj.Runtime.Name, len(obj.Runtime.Name) > 0
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
case "image":
|
||||
return obj.Image, len(obj.Image) > 0
|
||||
case "labels":
|
||||
return checkMap(fieldpath[1:], obj.Labels)
|
||||
}
|
||||
|
||||
return "", false
|
||||
})
|
||||
}
|
||||
|
||||
func checkMap(fieldpath []string, m map[string]string) (string, bool) {
|
||||
if len(m) == 0 {
|
||||
return "", false
|
||||
}
|
||||
|
||||
value, ok := m[strings.Join(fieldpath, ".")]
|
||||
return value, ok
|
||||
}
|
@ -44,6 +44,7 @@ var (
|
||||
bucketKeyOptions = []byte("options")
|
||||
bucketKeySpec = []byte("spec")
|
||||
bucketKeyRootFS = []byte("rootfs")
|
||||
bucketKeyTarget = []byte("target")
|
||||
bucketKeyCreatedAt = []byte("createdat")
|
||||
bucketKeyUpdatedAt = []byte("updatedat")
|
||||
)
|
||||
|
@ -45,25 +45,23 @@ func (s *containerStore) Get(ctx context.Context, id string) (containers.Contain
|
||||
return container, nil
|
||||
}
|
||||
|
||||
func (s *containerStore) List(ctx context.Context, fs ...filters.Filter) ([]containers.Container, error) {
|
||||
func (s *containerStore) List(ctx context.Context, fs ...string) ([]containers.Container, error) {
|
||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
m []containers.Container
|
||||
filter = filters.Filter(filters.Any(fs))
|
||||
bkt = getContainersBucket(s.tx, namespace)
|
||||
)
|
||||
|
||||
if len(fs) == 0 {
|
||||
filter = filters.Always
|
||||
filter, err := filters.ParseAll(fs...)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(errdefs.ErrInvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
bkt := getContainersBucket(s.tx, namespace)
|
||||
if bkt == nil {
|
||||
return m, nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var m []containers.Container
|
||||
if err := bkt.ForEach(func(k, v []byte) error {
|
||||
cbkt := bkt.Bucket(k)
|
||||
if cbkt == nil {
|
||||
@ -86,46 +84,6 @@ func (s *containerStore) List(ctx context.Context, fs ...filters.Filter) ([]cont
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func adaptContainer(o interface{}) filters.Adaptor {
|
||||
obj := o.(containers.Container)
|
||||
return filters.AdapterFunc(func(fieldpath []string) (string, bool) {
|
||||
if len(fieldpath) == 0 {
|
||||
return "", false
|
||||
}
|
||||
|
||||
switch fieldpath[0] {
|
||||
case "id":
|
||||
return obj.ID, len(obj.ID) > 0
|
||||
case "runtime":
|
||||
if len(fieldpath) <= 1 {
|
||||
return "", false
|
||||
}
|
||||
|
||||
switch fieldpath[1] {
|
||||
case "name":
|
||||
return obj.Runtime.Name, len(obj.Runtime.Name) > 0
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
case "image":
|
||||
return obj.Image, len(obj.Image) > 0
|
||||
case "labels":
|
||||
return checkMap(fieldpath[1:], obj.Labels)
|
||||
}
|
||||
|
||||
return "", false
|
||||
})
|
||||
}
|
||||
|
||||
func checkMap(fieldpath []string, m map[string]string) (string, bool) {
|
||||
if len(m) == 0 {
|
||||
return "", false
|
||||
}
|
||||
|
||||
value, ok := m[strings.Join(fieldpath, ".")]
|
||||
return value, ok
|
||||
}
|
||||
|
||||
func (s *containerStore) Create(ctx context.Context, container containers.Container) (containers.Container, error) {
|
||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||
if err != nil {
|
||||
@ -149,16 +107,16 @@ func (s *containerStore) Create(ctx context.Context, container containers.Contai
|
||||
return containers.Container{}, err
|
||||
}
|
||||
|
||||
container.CreatedAt = time.Now()
|
||||
container.CreatedAt = time.Now().UTC()
|
||||
container.UpdatedAt = container.CreatedAt
|
||||
if err := writeContainer(&container, cbkt); err != nil {
|
||||
if err := writeContainer(cbkt, &container); err != nil {
|
||||
return containers.Container{}, errors.Wrap(err, "failed to write container")
|
||||
}
|
||||
|
||||
return container, nil
|
||||
}
|
||||
|
||||
func (s *containerStore) Update(ctx context.Context, container containers.Container) (containers.Container, error) {
|
||||
func (s *containerStore) Update(ctx context.Context, container containers.Container, fieldpaths ...string) (containers.Container, error) {
|
||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||
if err != nil {
|
||||
return containers.Container{}, err
|
||||
@ -178,8 +136,50 @@ func (s *containerStore) Update(ctx context.Context, container containers.Contai
|
||||
return containers.Container{}, errors.Wrapf(errdefs.ErrNotFound, "container %q", container.ID)
|
||||
}
|
||||
|
||||
container.UpdatedAt = time.Now()
|
||||
if err := writeContainer(&container, cbkt); err != nil {
|
||||
var updated containers.Container
|
||||
if err := readContainer(&updated, cbkt); err != nil {
|
||||
return updated, errors.Wrapf(err, "failed to read container from bucket")
|
||||
}
|
||||
updated.ID = container.ID
|
||||
|
||||
// apply the field mask. If you update this code, you better follow the
|
||||
// field mask rules in field_mask.proto. If you don't know what this
|
||||
// is, do not update this code.
|
||||
if len(fieldpaths) > 0 {
|
||||
// TODO(stevvooe): Move this logic into the store itself.
|
||||
for _, path := range fieldpaths {
|
||||
if strings.HasPrefix(path, "labels.") {
|
||||
if updated.Labels == nil {
|
||||
updated.Labels = map[string]string{}
|
||||
}
|
||||
key := strings.TrimPrefix(path, "labels.")
|
||||
updated.Labels[key] = container.Labels[key]
|
||||
continue
|
||||
}
|
||||
|
||||
switch path {
|
||||
case "labels":
|
||||
updated.Labels = container.Labels
|
||||
case "image":
|
||||
updated.Image = container.Image
|
||||
case "runtime":
|
||||
// TODO(stevvooe): Should this actually be allowed?
|
||||
updated.Runtime = container.Runtime
|
||||
case "spec":
|
||||
updated.Spec = container.Spec
|
||||
case "rootfs":
|
||||
updated.RootFS = container.RootFS
|
||||
default:
|
||||
return containers.Container{}, errors.Wrapf(errdefs.ErrInvalidArgument, "cannot update %q field on %q", path, container.ID)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// no field mask present, just replace everything
|
||||
updated = container
|
||||
}
|
||||
|
||||
updated.UpdatedAt = time.Now().UTC()
|
||||
if err := writeContainer(cbkt, &updated); err != nil {
|
||||
return containers.Container{}, errors.Wrap(err, "failed to write container")
|
||||
}
|
||||
|
||||
@ -251,10 +251,8 @@ func readContainer(container *containers.Container, bkt *bolt.Bucket) error {
|
||||
return nil
|
||||
}
|
||||
container.Labels = map[string]string{}
|
||||
if err := lbkt.ForEach(func(k, v []byte) error {
|
||||
container.Labels[string(k)] = string(v)
|
||||
return nil
|
||||
}); err != nil {
|
||||
|
||||
if err := readLabels(container.Labels, lbkt); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -263,15 +261,11 @@ func readContainer(container *containers.Container, bkt *bolt.Bucket) error {
|
||||
})
|
||||
}
|
||||
|
||||
func writeContainer(container *containers.Container, bkt *bolt.Bucket) error {
|
||||
createdAt, err := container.CreatedAt.MarshalBinary()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
updatedAt, err := container.UpdatedAt.MarshalBinary()
|
||||
if err != nil {
|
||||
func writeContainer(bkt *bolt.Bucket, container *containers.Container) error {
|
||||
if err := writeTimestamps(bkt, container.CreatedAt, container.UpdatedAt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
spec, err := container.Spec.Marshal()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -281,8 +275,6 @@ func writeContainer(container *containers.Container, bkt *bolt.Bucket) error {
|
||||
{bucketKeyImage, []byte(container.Image)},
|
||||
{bucketKeySpec, spec},
|
||||
{bucketKeyRootFS, []byte(container.RootFS)},
|
||||
{bucketKeyCreatedAt, createdAt},
|
||||
{bucketKeyUpdatedAt, updatedAt},
|
||||
} {
|
||||
if err := bkt.Put(v[0], v[1]); err != nil {
|
||||
return err
|
||||
@ -320,28 +312,5 @@ func writeContainer(container *containers.Container, bkt *bolt.Bucket) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Remove existing labels to keep from merging
|
||||
if lbkt := bkt.Bucket(bucketKeyLabels); lbkt != nil {
|
||||
if err := bkt.DeleteBucket(bucketKeyLabels); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
lbkt, err := bkt.CreateBucket(bucketKeyLabels)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for k, v := range container.Labels {
|
||||
if v == "" {
|
||||
delete(container.Labels, k) // remove since we don't actually set it
|
||||
continue
|
||||
}
|
||||
|
||||
if err := lbkt.Put([]byte(k), []byte(v)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return writeLabels(bkt, container.Labels)
|
||||
}
|
||||
|
86
metadata/helpers.go
Normal file
86
metadata/helpers.go
Normal file
@ -0,0 +1,86 @@
|
||||
package metadata
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func readLabels(m map[string]string, bkt *bolt.Bucket) error {
|
||||
return bkt.ForEach(func(k, v []byte) error {
|
||||
m[string(k)] = string(v)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// writeLabels will write a new labels bucket to the provided bucket at key
|
||||
// bucketKeyLabels, replacing the contents of the bucket with the provided map.
|
||||
//
|
||||
// The provide map labels will be modified to have the final contents of the
|
||||
// bucket. Typically, this removes zero-value entries.
|
||||
func writeLabels(bkt *bolt.Bucket, labels map[string]string) error {
|
||||
// Remove existing labels to keep from merging
|
||||
if lbkt := bkt.Bucket(bucketKeyLabels); lbkt != nil {
|
||||
if err := bkt.DeleteBucket(bucketKeyLabels); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
lbkt, err := bkt.CreateBucket(bucketKeyLabels)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for k, v := range labels {
|
||||
if v == "" {
|
||||
delete(labels, k) // remove since we don't actually set it
|
||||
continue
|
||||
}
|
||||
|
||||
if err := lbkt.Put([]byte(k), []byte(v)); err != nil {
|
||||
return errors.Wrapf(err, "failed to set label %q=%q", k, v)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func readTimestamps(created, updated *time.Time, bkt *bolt.Bucket) error {
|
||||
for _, f := range []struct {
|
||||
b []byte
|
||||
t *time.Time
|
||||
}{
|
||||
{bucketKeyCreatedAt, created},
|
||||
{bucketKeyUpdatedAt, updated},
|
||||
} {
|
||||
v := bkt.Get(f.b)
|
||||
if v != nil {
|
||||
if err := f.t.UnmarshalBinary(v); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func writeTimestamps(bkt *bolt.Bucket, created, updated time.Time) error {
|
||||
createdAt, err := created.MarshalBinary()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
updatedAt, err := updated.MarshalBinary()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, v := range [][2][]byte{
|
||||
{bucketKeyCreatedAt, createdAt},
|
||||
{bucketKeyUpdatedAt, updatedAt},
|
||||
} {
|
||||
if err := bkt.Put(v[0], v[1]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -4,13 +4,15 @@ import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/filters"
|
||||
"github.com/containerd/containerd/images"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@ -42,60 +44,29 @@ func (s *imageStore) Get(ctx context.Context, name string) (images.Image, error)
|
||||
|
||||
image.Name = name
|
||||
if err := readImage(&image, ibkt); err != nil {
|
||||
return images.Image{}, err
|
||||
return images.Image{}, errors.Wrapf(err, "image %q", name)
|
||||
}
|
||||
|
||||
return image, nil
|
||||
}
|
||||
|
||||
func (s *imageStore) Update(ctx context.Context, name string, desc ocispec.Descriptor) error {
|
||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return withImagesBucket(s.tx, namespace, func(bkt *bolt.Bucket) error {
|
||||
ibkt, err := bkt.CreateBucketIfNotExists([]byte(name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var (
|
||||
buf [binary.MaxVarintLen64]byte
|
||||
sizeEncoded []byte = buf[:]
|
||||
)
|
||||
sizeEncoded = sizeEncoded[:binary.PutVarint(sizeEncoded, desc.Size)]
|
||||
|
||||
if len(sizeEncoded) == 0 {
|
||||
return fmt.Errorf("failed encoding size = %v", desc.Size)
|
||||
}
|
||||
|
||||
for _, v := range [][2][]byte{
|
||||
{bucketKeyDigest, []byte(desc.Digest)},
|
||||
{bucketKeyMediaType, []byte(desc.MediaType)},
|
||||
{bucketKeySize, sizeEncoded},
|
||||
} {
|
||||
if err := ibkt.Put(v[0], v[1]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (s *imageStore) List(ctx context.Context) ([]images.Image, error) {
|
||||
var m []images.Image
|
||||
func (s *imageStore) List(ctx context.Context, fs ...string) ([]images.Image, error) {
|
||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
filter, err := filters.ParseAll(fs...)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(errdefs.ErrInvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
bkt := getImagesBucket(s.tx, namespace)
|
||||
if bkt == nil {
|
||||
return nil, nil // empty store
|
||||
}
|
||||
|
||||
var m []images.Image
|
||||
if err := bkt.ForEach(func(k, v []byte) error {
|
||||
var (
|
||||
image = images.Image{
|
||||
@ -108,7 +79,9 @@ func (s *imageStore) List(ctx context.Context) ([]images.Image, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
m = append(m, image)
|
||||
if filter.Match(adaptImage(image)) {
|
||||
m = append(m, image)
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
@ -117,6 +90,90 @@ func (s *imageStore) List(ctx context.Context) ([]images.Image, error) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (s *imageStore) Create(ctx context.Context, image images.Image) (images.Image, error) {
|
||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||
if err != nil {
|
||||
return images.Image{}, err
|
||||
}
|
||||
|
||||
if image.Name == "" {
|
||||
return images.Image{}, errors.Wrapf(errdefs.ErrInvalidArgument, "image name is required for create")
|
||||
}
|
||||
|
||||
return image, withImagesBucket(s.tx, namespace, func(bkt *bolt.Bucket) error {
|
||||
ibkt, err := bkt.CreateBucket([]byte(image.Name))
|
||||
if err != nil {
|
||||
if err != bolt.ErrBucketExists {
|
||||
return err
|
||||
}
|
||||
|
||||
return errors.Wrapf(errdefs.ErrAlreadyExists, "image %q", image.Name)
|
||||
}
|
||||
|
||||
image.CreatedAt = time.Now().UTC()
|
||||
image.UpdatedAt = image.CreatedAt
|
||||
return writeImage(ibkt, &image)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *imageStore) Update(ctx context.Context, image images.Image, fieldpaths ...string) (images.Image, error) {
|
||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||
if err != nil {
|
||||
return images.Image{}, err
|
||||
}
|
||||
|
||||
if image.Name == "" {
|
||||
return images.Image{}, errors.Wrapf(errdefs.ErrInvalidArgument, "image name is required for update")
|
||||
}
|
||||
|
||||
var updated images.Image
|
||||
return updated, withImagesBucket(s.tx, namespace, func(bkt *bolt.Bucket) error {
|
||||
ibkt := bkt.Bucket([]byte(image.Name))
|
||||
if ibkt == nil {
|
||||
return errors.Wrapf(errdefs.ErrNotFound, "image %q", image.Name)
|
||||
}
|
||||
|
||||
if err := readImage(&updated, ibkt); err != nil {
|
||||
return errors.Wrapf(err, "image %q", image.Name)
|
||||
}
|
||||
updated.Name = image.Name
|
||||
|
||||
if len(fieldpaths) > 0 {
|
||||
for _, path := range fieldpaths {
|
||||
if strings.HasPrefix(path, "labels.") {
|
||||
if updated.Labels == nil {
|
||||
updated.Labels = map[string]string{}
|
||||
}
|
||||
|
||||
key := strings.TrimPrefix(path, "labels.")
|
||||
updated.Labels[key] = image.Labels[key]
|
||||
continue
|
||||
}
|
||||
|
||||
switch path {
|
||||
case "labels":
|
||||
updated.Labels = image.Labels
|
||||
case "target":
|
||||
// NOTE(stevvooe): While we allow setting individual labels, we
|
||||
// only support replacing the target as a unit, since that is
|
||||
// commonly pulled as a unit from other sources. It often doesn't
|
||||
// make sense to modify the size or digest without touching the
|
||||
// mediatype, as well, for example.
|
||||
updated.Target = image.Target
|
||||
default:
|
||||
return errors.Wrapf(errdefs.ErrInvalidArgument, "cannot update %q field on image %q", path, image.Name)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
updated = image
|
||||
}
|
||||
|
||||
// TODO(stevvooe): Should only mark as updated if we have actual changes.
|
||||
updated.UpdatedAt = time.Now().UTC()
|
||||
return writeImage(ibkt, &updated)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *imageStore) Delete(ctx context.Context, name string) error {
|
||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||
if err != nil {
|
||||
@ -133,7 +190,23 @@ func (s *imageStore) Delete(ctx context.Context, name string) error {
|
||||
}
|
||||
|
||||
func readImage(image *images.Image, bkt *bolt.Bucket) error {
|
||||
return bkt.ForEach(func(k, v []byte) error {
|
||||
if err := readTimestamps(&image.CreatedAt, &image.UpdatedAt, bkt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
lbkt := bkt.Bucket(bucketKeyLabels)
|
||||
if lbkt != nil {
|
||||
image.Labels = map[string]string{}
|
||||
if err := readLabels(image.Labels, lbkt); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
tbkt := bkt.Bucket(bucketKeyTarget)
|
||||
if tbkt == nil {
|
||||
return errors.New("unable to read target bucket")
|
||||
}
|
||||
return tbkt.ForEach(func(k, v []byte) error {
|
||||
if v == nil {
|
||||
return nil // skip it? a bkt maybe?
|
||||
}
|
||||
@ -152,3 +225,43 @@ func readImage(image *images.Image, bkt *bolt.Bucket) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func writeImage(bkt *bolt.Bucket, image *images.Image) error {
|
||||
if err := writeTimestamps(bkt, image.CreatedAt, image.UpdatedAt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(image.Labels) > 0 {
|
||||
if err := writeLabels(bkt, image.Labels); err != nil {
|
||||
return errors.Wrapf(err, "writing labels for image %v", image.Name)
|
||||
}
|
||||
}
|
||||
|
||||
// write the target bucket
|
||||
tbkt, err := bkt.CreateBucketIfNotExists([]byte(bucketKeyTarget))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var (
|
||||
buf [binary.MaxVarintLen64]byte
|
||||
sizeEncoded []byte = buf[:]
|
||||
)
|
||||
sizeEncoded = sizeEncoded[:binary.PutVarint(sizeEncoded, image.Target.Size)]
|
||||
|
||||
if len(sizeEncoded) == 0 {
|
||||
return fmt.Errorf("failed encoding size = %v", image.Target.Size)
|
||||
}
|
||||
|
||||
for _, v := range [][2][]byte{
|
||||
{bucketKeyDigest, []byte(image.Target.Digest)},
|
||||
{bucketKeyMediaType, []byte(image.Target.MediaType)},
|
||||
{bucketKeySize, sizeEncoded},
|
||||
} {
|
||||
if err := tbkt.Put(v[0], v[1]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -1,21 +1,19 @@
|
||||
package containers
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
api "github.com/containerd/containerd/api/services/containers/v1"
|
||||
eventsapi "github.com/containerd/containerd/api/services/events/v1"
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/events"
|
||||
"github.com/containerd/containerd/filters"
|
||||
"github.com/containerd/containerd/metadata"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -68,18 +66,8 @@ func (s *Service) Get(ctx context.Context, req *api.GetContainerRequest) (*api.G
|
||||
func (s *Service) List(ctx context.Context, req *api.ListContainersRequest) (*api.ListContainersResponse, error) {
|
||||
var resp api.ListContainersResponse
|
||||
|
||||
var fs []filters.Filter
|
||||
for _, s := range req.Filters {
|
||||
f, err := filters.Parse(s)
|
||||
if err != nil {
|
||||
return nil, grpc.Errorf(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
fs = append(fs, f)
|
||||
}
|
||||
|
||||
return &resp, errdefs.ToGRPC(s.withStoreView(ctx, func(ctx context.Context, store containers.Store) error {
|
||||
containers, err := store.List(ctx, fs...)
|
||||
containers, err := store.List(ctx, req.Filters...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -121,52 +109,20 @@ func (s *Service) Create(ctx context.Context, req *api.CreateContainerRequest) (
|
||||
}
|
||||
|
||||
func (s *Service) Update(ctx context.Context, req *api.UpdateContainerRequest) (*api.UpdateContainerResponse, error) {
|
||||
if req.Container.ID == "" {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "Container.ID required")
|
||||
}
|
||||
var (
|
||||
resp api.UpdateContainerResponse
|
||||
incoming = containerFromProto(&req.Container)
|
||||
resp api.UpdateContainerResponse
|
||||
container = containerFromProto(&req.Container)
|
||||
)
|
||||
|
||||
if err := s.withStoreUpdate(ctx, func(ctx context.Context, store containers.Store) error {
|
||||
|
||||
container, err := store.Get(ctx, incoming.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if container.ID != incoming.ID {
|
||||
return grpc.Errorf(codes.InvalidArgument, "container ids must match: %v != %v", container.ID, incoming.ID)
|
||||
}
|
||||
|
||||
// apply the field mask. If you update this code, you better follow the
|
||||
// field mask rules in field_mask.proto. If you don't know what this
|
||||
// is, do not update this code.
|
||||
var fieldpaths []string
|
||||
if req.UpdateMask != nil && len(req.UpdateMask.Paths) > 0 {
|
||||
for _, path := range req.UpdateMask.Paths {
|
||||
if strings.HasPrefix(path, "labels.") {
|
||||
key := strings.TrimPrefix(path, "labels.")
|
||||
container.Labels[key] = incoming.Labels[key]
|
||||
continue
|
||||
}
|
||||
|
||||
switch path {
|
||||
case "labels":
|
||||
container.Labels = incoming.Labels
|
||||
case "image":
|
||||
container.Image = incoming.Image
|
||||
case "runtime":
|
||||
// TODO(stevvooe): Should this actually be allowed?
|
||||
container.Runtime = incoming.Runtime
|
||||
case "spec":
|
||||
container.Spec = incoming.Spec
|
||||
case "rootfs":
|
||||
container.RootFS = incoming.RootFS
|
||||
default:
|
||||
return grpc.Errorf(codes.InvalidArgument, "cannot update %q field", path)
|
||||
}
|
||||
fieldpaths = append(fieldpaths, path)
|
||||
}
|
||||
} else {
|
||||
// no field mask present, just replace everything
|
||||
container = incoming
|
||||
}
|
||||
|
||||
updated, err := store.Update(ctx, container)
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
imagesapi "github.com/containerd/containerd/api/services/images/v1"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/images"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
)
|
||||
|
||||
type remoteStore struct {
|
||||
@ -19,19 +19,6 @@ func NewStoreFromClient(client imagesapi.ImagesClient) images.Store {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *remoteStore) Update(ctx context.Context, name string, desc ocispec.Descriptor) error {
|
||||
// TODO(stevvooe): Consider that the remote may want to augment and return
|
||||
// a modified image.
|
||||
_, err := s.client.Update(ctx, &imagesapi.UpdateImageRequest{
|
||||
Image: imagesapi.Image{
|
||||
Name: name,
|
||||
Target: descToProto(&desc),
|
||||
},
|
||||
})
|
||||
|
||||
return errdefs.FromGRPC(err)
|
||||
}
|
||||
|
||||
func (s *remoteStore) Get(ctx context.Context, name string) (images.Image, error) {
|
||||
resp, err := s.client.Get(ctx, &imagesapi.GetImageRequest{
|
||||
Name: name,
|
||||
@ -43,8 +30,10 @@ func (s *remoteStore) Get(ctx context.Context, name string) (images.Image, error
|
||||
return imageFromProto(resp.Image), nil
|
||||
}
|
||||
|
||||
func (s *remoteStore) List(ctx context.Context) ([]images.Image, error) {
|
||||
resp, err := s.client.List(ctx, &imagesapi.ListImagesRequest{})
|
||||
func (s *remoteStore) List(ctx context.Context, filters ...string) ([]images.Image, error) {
|
||||
resp, err := s.client.List(ctx, &imagesapi.ListImagesRequest{
|
||||
Filters: filters,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errdefs.FromGRPC(err)
|
||||
}
|
||||
@ -52,6 +41,36 @@ func (s *remoteStore) List(ctx context.Context) ([]images.Image, error) {
|
||||
return imagesFromProto(resp.Images), nil
|
||||
}
|
||||
|
||||
func (s *remoteStore) Create(ctx context.Context, image images.Image) (images.Image, error) {
|
||||
created, err := s.client.Create(ctx, &imagesapi.CreateImageRequest{
|
||||
Image: imageToProto(&image),
|
||||
})
|
||||
if err != nil {
|
||||
return images.Image{}, errdefs.FromGRPC(err)
|
||||
}
|
||||
|
||||
return imageFromProto(&created.Image), nil
|
||||
}
|
||||
|
||||
func (s *remoteStore) Update(ctx context.Context, image images.Image, fieldpaths ...string) (images.Image, error) {
|
||||
var updateMask *ptypes.FieldMask
|
||||
if len(fieldpaths) > 0 {
|
||||
updateMask = &ptypes.FieldMask{
|
||||
Paths: fieldpaths,
|
||||
}
|
||||
}
|
||||
|
||||
updated, err := s.client.Update(ctx, &imagesapi.UpdateImageRequest{
|
||||
Image: imageToProto(&image),
|
||||
UpdateMask: updateMask,
|
||||
})
|
||||
if err != nil {
|
||||
return images.Image{}, errdefs.FromGRPC(err)
|
||||
}
|
||||
|
||||
return imageFromProto(&updated.Image), nil
|
||||
}
|
||||
|
||||
func (s *remoteStore) Delete(ctx context.Context, name string) error {
|
||||
_, err := s.client.Delete(ctx, &imagesapi.DeleteImageRequest{
|
||||
Name: name,
|
||||
|
@ -29,15 +29,21 @@ func imagesFromProto(imagespb []imagesapi.Image) []images.Image {
|
||||
|
||||
func imageToProto(image *images.Image) imagesapi.Image {
|
||||
return imagesapi.Image{
|
||||
Name: image.Name,
|
||||
Target: descToProto(&image.Target),
|
||||
Name: image.Name,
|
||||
Labels: image.Labels,
|
||||
Target: descToProto(&image.Target),
|
||||
CreatedAt: image.CreatedAt,
|
||||
UpdatedAt: image.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func imageFromProto(imagepb *imagesapi.Image) images.Image {
|
||||
return images.Image{
|
||||
Name: imagepb.Name,
|
||||
Target: descFromProto(&imagepb.Target),
|
||||
Name: imagepb.Name,
|
||||
Labels: imagepb.Labels,
|
||||
Target: descFromProto(&imagepb.Target),
|
||||
CreatedAt: imagepb.CreatedAt,
|
||||
UpdatedAt: imagepb.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,8 @@ import (
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -63,38 +65,88 @@ func (s *Service) Get(ctx context.Context, req *imagesapi.GetImageRequest) (*ima
|
||||
}))
|
||||
}
|
||||
|
||||
func (s *Service) Update(ctx context.Context, req *imagesapi.UpdateImageRequest) (*imagesapi.UpdateImageResponse, error) {
|
||||
func (s *Service) List(ctx context.Context, req *imagesapi.ListImagesRequest) (*imagesapi.ListImagesResponse, error) {
|
||||
var resp imagesapi.ListImagesResponse
|
||||
|
||||
return &resp, errdefs.ToGRPC(s.withStoreView(ctx, func(ctx context.Context, store images.Store) error {
|
||||
images, err := store.List(ctx, req.Filters...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp.Images = imagesToProto(images)
|
||||
return nil
|
||||
}))
|
||||
}
|
||||
|
||||
func (s *Service) Create(ctx context.Context, req *imagesapi.CreateImageRequest) (*imagesapi.CreateImageResponse, error) {
|
||||
if req.Image.Name == "" {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "Image.Name required")
|
||||
}
|
||||
|
||||
var (
|
||||
image = imageFromProto(&req.Image)
|
||||
resp imagesapi.CreateImageResponse
|
||||
)
|
||||
if err := s.withStoreUpdate(ctx, func(ctx context.Context, store images.Store) error {
|
||||
return store.Update(ctx, req.Image.Name, descFromProto(&req.Image.Target))
|
||||
created, err := store.Create(ctx, image)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp.Image = imageToProto(&created)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
if err := s.emit(ctx, "/images/create", &eventsapi.ImageCreate{
|
||||
Name: resp.Image.Name,
|
||||
Labels: resp.Image.Labels,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &resp, nil
|
||||
|
||||
}
|
||||
|
||||
func (s *Service) Update(ctx context.Context, req *imagesapi.UpdateImageRequest) (*imagesapi.UpdateImageResponse, error) {
|
||||
if req.Image.Name == "" {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "Image.Name required")
|
||||
}
|
||||
|
||||
var (
|
||||
image = imageFromProto(&req.Image)
|
||||
resp imagesapi.UpdateImageResponse
|
||||
)
|
||||
if err := s.withStoreUpdate(ctx, func(ctx context.Context, store images.Store) error {
|
||||
var fieldpaths []string
|
||||
if req.UpdateMask != nil && len(req.UpdateMask.Paths) > 0 {
|
||||
for _, path := range req.UpdateMask.Paths {
|
||||
fieldpaths = append(fieldpaths, path)
|
||||
}
|
||||
}
|
||||
|
||||
updated, err := store.Update(ctx, image, fieldpaths...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp.Image = imageToProto(&updated)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
if err := s.emit(ctx, "/images/update", &eventsapi.ImageUpdate{
|
||||
Name: req.Image.Name,
|
||||
Labels: req.Image.Labels,
|
||||
Name: resp.Image.Name,
|
||||
Labels: resp.Image.Labels,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: get image back out to return
|
||||
return &imagesapi.UpdateImageResponse{
|
||||
//Image: nil,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) List(ctx context.Context, _ *imagesapi.ListImagesRequest) (*imagesapi.ListImagesResponse, error) {
|
||||
var resp imagesapi.ListImagesResponse
|
||||
|
||||
return &resp, s.withStoreView(ctx, func(ctx context.Context, store images.Store) error {
|
||||
images, err := store.List(ctx)
|
||||
if err != nil {
|
||||
return errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
resp.Images = imagesToProto(images)
|
||||
return nil
|
||||
})
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (s *Service) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest) (*empty.Empty, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user