diff --git a/api/services/control.pb.go b/api/services/control.pb.go index cb46112dcde4a93b5c2a931f3ad2f194df0eccba..6f305565171aecad9b39e540902445ff0c8f44c2 100644 --- a/api/services/control.pb.go +++ b/api/services/control.pb.go @@ -50,7 +50,7 @@ func (x HealthCheckResponse_ServingStatus) String() string { } func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{12, 0} + return fileDescriptor_d71ef680555cb937, []int{13, 0} } type BuildRequest struct { @@ -473,6 +473,54 @@ func (m *ListRequest) GetImageName() string { return "" } +type TagRequest struct { + // image refers to the image to be tagged + Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` + // tag is the tag added to image + Tag string `protobuf:"bytes,2,opt,name=tag,proto3" json:"tag,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TagRequest) Reset() { *m = TagRequest{} } +func (m *TagRequest) String() string { return proto.CompactTextString(m) } +func (*TagRequest) ProtoMessage() {} +func (*TagRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d71ef680555cb937, []int{8} +} +func (m *TagRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TagRequest.Unmarshal(m, b) +} +func (m *TagRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TagRequest.Marshal(b, m, deterministic) +} +func (m *TagRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_TagRequest.Merge(m, src) +} +func (m *TagRequest) XXX_Size() int { + return xxx_messageInfo_TagRequest.Size(m) +} +func (m *TagRequest) XXX_DiscardUnknown() { + xxx_messageInfo_TagRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_TagRequest proto.InternalMessageInfo + +func (m *TagRequest) GetImage() string { + if m != nil { + return m.Image + } + return "" +} + +func (m *TagRequest) GetTag() string { + if m != nil { + return m.Tag + } + return "" +} + type ListResponse struct { // ImageInfo carries the basic info of an image Images []*ListResponse_ImageInfo `protobuf:"bytes,1,rep,name=images,proto3" json:"images,omitempty"` @@ -485,7 +533,7 @@ func (m *ListResponse) Reset() { *m = ListResponse{} } func (m *ListResponse) String() string { return proto.CompactTextString(m) } func (*ListResponse) ProtoMessage() {} func (*ListResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{8} + return fileDescriptor_d71ef680555cb937, []int{9} } func (m *ListResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ListResponse.Unmarshal(m, b) @@ -527,7 +575,7 @@ func (m *ListResponse_ImageInfo) Reset() { *m = ListResponse_ImageInfo{} func (m *ListResponse_ImageInfo) String() string { return proto.CompactTextString(m) } func (*ListResponse_ImageInfo) ProtoMessage() {} func (*ListResponse_ImageInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{8, 0} + return fileDescriptor_d71ef680555cb937, []int{9, 0} } func (m *ListResponse_ImageInfo) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ListResponse_ImageInfo.Unmarshal(m, b) @@ -602,7 +650,7 @@ func (m *VersionResponse) Reset() { *m = VersionResponse{} } func (m *VersionResponse) String() string { return proto.CompactTextString(m) } func (*VersionResponse) ProtoMessage() {} func (*VersionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{9} + return fileDescriptor_d71ef680555cb937, []int{10} } func (m *VersionResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_VersionResponse.Unmarshal(m, b) @@ -673,7 +721,7 @@ func (m *RemoveRequest) Reset() { *m = RemoveRequest{} } func (m *RemoveRequest) String() string { return proto.CompactTextString(m) } func (*RemoveRequest) ProtoMessage() {} func (*RemoveRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{10} + return fileDescriptor_d71ef680555cb937, []int{11} } func (m *RemoveRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_RemoveRequest.Unmarshal(m, b) @@ -726,7 +774,7 @@ func (m *RemoveResponse) Reset() { *m = RemoveResponse{} } func (m *RemoveResponse) String() string { return proto.CompactTextString(m) } func (*RemoveResponse) ProtoMessage() {} func (*RemoveResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{11} + return fileDescriptor_d71ef680555cb937, []int{12} } func (m *RemoveResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_RemoveResponse.Unmarshal(m, b) @@ -765,7 +813,7 @@ func (m *HealthCheckResponse) Reset() { *m = HealthCheckResponse{} } func (m *HealthCheckResponse) String() string { return proto.CompactTextString(m) } func (*HealthCheckResponse) ProtoMessage() {} func (*HealthCheckResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{12} + return fileDescriptor_d71ef680555cb937, []int{13} } func (m *HealthCheckResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HealthCheckResponse.Unmarshal(m, b) @@ -810,7 +858,7 @@ func (m *LoginRequest) Reset() { *m = LoginRequest{} } func (m *LoginRequest) String() string { return proto.CompactTextString(m) } func (*LoginRequest) ProtoMessage() {} func (*LoginRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{13} + return fileDescriptor_d71ef680555cb937, []int{14} } func (m *LoginRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LoginRequest.Unmarshal(m, b) @@ -870,7 +918,7 @@ func (m *LoginResponse) Reset() { *m = LoginResponse{} } func (m *LoginResponse) String() string { return proto.CompactTextString(m) } func (*LoginResponse) ProtoMessage() {} func (*LoginResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{14} + return fileDescriptor_d71ef680555cb937, []int{15} } func (m *LoginResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LoginResponse.Unmarshal(m, b) @@ -911,7 +959,7 @@ func (m *LogoutRequest) Reset() { *m = LogoutRequest{} } func (m *LogoutRequest) String() string { return proto.CompactTextString(m) } func (*LogoutRequest) ProtoMessage() {} func (*LogoutRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{15} + return fileDescriptor_d71ef680555cb937, []int{16} } func (m *LogoutRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LogoutRequest.Unmarshal(m, b) @@ -957,7 +1005,7 @@ func (m *LogoutResponse) Reset() { *m = LogoutResponse{} } func (m *LogoutResponse) String() string { return proto.CompactTextString(m) } func (*LogoutResponse) ProtoMessage() {} func (*LogoutResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{16} + return fileDescriptor_d71ef680555cb937, []int{17} } func (m *LogoutResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LogoutResponse.Unmarshal(m, b) @@ -996,7 +1044,7 @@ func (m *LoadRequest) Reset() { *m = LoadRequest{} } func (m *LoadRequest) String() string { return proto.CompactTextString(m) } func (*LoadRequest) ProtoMessage() {} func (*LoadRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{17} + return fileDescriptor_d71ef680555cb937, []int{18} } func (m *LoadRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LoadRequest.Unmarshal(m, b) @@ -1035,7 +1083,7 @@ func (m *LoadResponse) Reset() { *m = LoadResponse{} } func (m *LoadResponse) String() string { return proto.CompactTextString(m) } func (*LoadResponse) ProtoMessage() {} func (*LoadResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d71ef680555cb937, []int{18} + return fileDescriptor_d71ef680555cb937, []int{19} } func (m *LoadResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LoadResponse.Unmarshal(m, b) @@ -1072,6 +1120,7 @@ func init() { proto.RegisterType((*StatusRequest)(nil), "isula.build.v1.StatusRequest") proto.RegisterType((*StatusResponse)(nil), "isula.build.v1.StatusResponse") proto.RegisterType((*ListRequest)(nil), "isula.build.v1.ListRequest") + proto.RegisterType((*TagRequest)(nil), "isula.build.v1.TagRequest") proto.RegisterType((*ListResponse)(nil), "isula.build.v1.ListResponse") proto.RegisterType((*ListResponse_ImageInfo)(nil), "isula.build.v1.ListResponse.ImageInfo") proto.RegisterType((*VersionResponse)(nil), "isula.build.v1.VersionResponse") @@ -1089,70 +1138,72 @@ func init() { func init() { proto.RegisterFile("api/services/control.proto", fileDescriptor_d71ef680555cb937) } var fileDescriptor_d71ef680555cb937 = []byte{ - // 1005 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0xeb, 0x6e, 0xe3, 0x44, - 0x14, 0xc6, 0x4d, 0xe3, 0xb4, 0xc7, 0x49, 0xb6, 0x1a, 0x50, 0x65, 0x65, 0xcb, 0x6e, 0x30, 0x08, - 0x05, 0x90, 0xdc, 0xdd, 0xc0, 0x0f, 0x40, 0x5a, 0xa4, 0x5e, 0x96, 0x12, 0xb6, 0x64, 0x85, 0x5b, - 0x96, 0x9f, 0x68, 0x9a, 0x4c, 0xdd, 0xd1, 0xda, 0x1e, 0x33, 0x33, 0x2e, 0x1b, 0x78, 0x15, 0x78, - 0x22, 0x1e, 0x80, 0x07, 0xe1, 0x05, 0xd0, 0x8c, 0xc7, 0xb7, 0x38, 0xa5, 0xfb, 0x6f, 0xce, 0x65, - 0xce, 0x9c, 0xcb, 0xf7, 0x1d, 0x1b, 0x46, 0x38, 0xa5, 0x87, 0x82, 0xf0, 0x5b, 0xba, 0x20, 0xe2, - 0x70, 0xc1, 0x12, 0xc9, 0x59, 0xe4, 0xa7, 0x9c, 0x49, 0x86, 0x86, 0x54, 0x64, 0x11, 0xf6, 0xaf, - 0x32, 0x1a, 0x2d, 0xfd, 0xdb, 0xa7, 0xa3, 0x87, 0x21, 0x63, 0x61, 0x44, 0x0e, 0xb5, 0xf5, 0x2a, - 0xbb, 0x3e, 0x24, 0x71, 0x2a, 0x57, 0xb9, 0xf3, 0xe8, 0xf1, 0xba, 0x51, 0xd2, 0x98, 0x08, 0x89, - 0xe3, 0x34, 0x77, 0xf0, 0xfe, 0xdd, 0x82, 0xfe, 0xb1, 0x0a, 0x15, 0x90, 0x5f, 0x33, 0x22, 0x24, - 0x3a, 0x80, 0x5d, 0x1d, 0xfa, 0x72, 0x95, 0x12, 0xd7, 0x1a, 0x5b, 0x93, 0xdd, 0xa0, 0x52, 0x20, - 0x17, 0x7a, 0x5a, 0x98, 0x9d, 0xba, 0x5b, 0xda, 0x56, 0x88, 0xe8, 0x11, 0x80, 0xca, 0x93, 0xbc, - 0x91, 0xa7, 0x94, 0xbb, 0x1d, 0x6d, 0xac, 0x69, 0xd0, 0x18, 0x9c, 0x6b, 0x1a, 0x91, 0x13, 0xa5, - 0x49, 0xa4, 0xbb, 0xad, 0x1d, 0xea, 0x2a, 0xb4, 0x0f, 0x36, 0xcb, 0x64, 0x9a, 0x49, 0xb7, 0xab, - 0x8d, 0x46, 0x2a, 0x33, 0x3a, 0xe2, 0xa1, 0x70, 0xed, 0x71, 0xa7, 0xcc, 0x48, 0x29, 0xd0, 0x7b, - 0xd0, 0x4d, 0x39, 0x7b, 0xb3, 0x72, 0x7b, 0x63, 0x6b, 0xb2, 0x13, 0xe4, 0x82, 0xca, 0x93, 0xd2, - 0xa5, 0x8a, 0xee, 0xee, 0xe4, 0x79, 0x1a, 0x11, 0x3d, 0x03, 0x47, 0x5f, 0xbe, 0x90, 0x58, 0xd2, - 0x85, 0xbb, 0x3b, 0xb6, 0x26, 0xce, 0xf4, 0xa1, 0xdf, 0x6c, 0xaa, 0x7f, 0x5c, 0xb9, 0x04, 0x75, - 0x7f, 0x55, 0x26, 0x49, 0x16, 0x7c, 0x95, 0xca, 0x17, 0x64, 0xe5, 0x42, 0x5e, 0x66, 0xa5, 0x41, - 0x1f, 0xc1, 0x00, 0x2f, 0x97, 0x54, 0x52, 0x96, 0xe0, 0xe8, 0x12, 0x87, 0xae, 0xa3, 0x5d, 0x9a, - 0x4a, 0xef, 0x08, 0x06, 0xb3, 0x38, 0x65,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xd2, 0xf0, 0x65, - 0x8b, 0x2e, 0x75, 0x99, 0x9c, 0x60, 0x49, 0x96, 0x86, 0x23, 0x85, 0xa8, 0x3a, 0x2a, 0xe8, 0xef, - 0xc4, 0xb0, 0x43, 0x9f, 0xbd, 0xbf, 0x2c, 0x78, 0xf0, 0x8a, 0x70, 0x41, 0x59, 0x52, 0x6f, 0xd4, - 0x6d, 0xae, 0x2a, 0x1a, 0x65, 0x44, 0xd5, 0x99, 0x90, 0x19, 0x77, 0x93, 0x43, 0xa5, 0xd0, 0x56, - 0x2a, 0x4f, 0x58, 0x1c, 0x53, 0x69, 0x12, 0xaa, 0x14, 0xd5, 0x5e, 0x50, 0xa0, 0xd9, 0xae, 0xef, - 0x05, 0x1a, 0x13, 0xcd, 0x5d, 0x71, 0xc4, 0x17, 0x37, 0x25, 0x77, 0xb5, 0xe4, 0xfd, 0x08, 0x83, - 0x80, 0xc4, 0xec, 0x96, 0xd4, 0x26, 0x5e, 0x01, 0xa6, 0x53, 0x07, 0xcc, 0x1e, 0x74, 0x70, 0x14, - 0xe9, 0xb4, 0x76, 0x02, 0x75, 0xcc, 0xa9, 0x9d, 0x25, 0x44, 0x27, 0xa3, 0xa9, 0x9d, 0x25, 0xc4, - 0xfb, 0x02, 0x86, 0x45, 0x48, 0x53, 0xb0, 0x07, 0xfd, 0x08, 0xaf, 0x08, 0xff, 0x81, 0x08, 0x81, - 0xc3, 0x62, 0xe6, 0x0d, 0x9d, 0xf7, 0xa7, 0x05, 0xef, 0x7e, 0x47, 0x70, 0x24, 0x6f, 0x4e, 0x6e, - 0xc8, 0xe2, 0x75, 0x79, 0x77, 0x06, 0xb6, 0xd0, 0x38, 0xd3, 0xb7, 0x86, 0xd3, 0xa7, 0xeb, 0xd3, - 0xdf, 0x70, 0xc9, 0xbf, 0x50, 0x9b, 0x39, 0x09, 0x0d, 0x40, 0x4d, 0x00, 0xef, 0x6b, 0x18, 0x34, - 0x0c, 0xc8, 0x81, 0xde, 0x4f, 0xf3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3, 0xaa, 0xc9, 0xc3, 0x1c, 0xfc, - 0xdf, 0x1e, 0x42, 0xc7, 0xd0, 0x2b, 0x78, 0xbb, 0xdf, 0xda, 0xdd, 0xcf, 0xd5, 0x1f, 0xc0, 0xe8, - 0xf1, 0x7a, 0x80, 0xf5, 0x45, 0x31, 0x03, 0x3b, 0x67, 0x52, 0xbb, 0xa2, 0x06, 0x69, 0xdb, 0x15, - 0x35, 0x09, 0xf8, 0xc4, 0x42, 0xdf, 0x83, 0x53, 0x23, 0xca, 0x9d, 0x29, 0x7d, 0xf8, 0x16, 0xec, - 0x42, 0xa7, 0xd0, 0xd5, 0xc8, 0x6c, 0x0f, 0xac, 0x4e, 0x91, 0xf6, 0xc0, 0x9a, 0x70, 0x3e, 0x03, - 0x3b, 0x47, 0x1e, 0xda, 0xe4, 0x58, 0x81, 0xb9, 0x5d, 0xdc, 0x1a, 0x60, 0xd5, 0xb0, 0x18, 0x5e, - 0x6e, 0x18, 0x56, 0x05, 0xd7, 0x0d, 0xc3, 0xaa, 0x03, 0x75, 0x06, 0x76, 0xfe, 0xad, 0x6e, 0xe7, - 0xd2, 0xf8, 0x0d, 0x68, 0xe7, 0xd2, 0xfc, 0xc4, 0x4f, 0xac, 0x2b, 0x5b, 0x77, 0xf4, 0xf3, 0xff, - 0x02, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x22, 0xc1, 0x44, 0x22, 0x0a, 0x00, 0x00, + // 1034 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0x6d, 0x6f, 0xdc, 0x44, + 0x10, 0xc6, 0xb9, 0xc4, 0x49, 0xc6, 0xb9, 0x6b, 0xb4, 0x54, 0x91, 0xe5, 0x84, 0xf6, 0x30, 0x08, + 0x1d, 0x20, 0x39, 0x6d, 0xe0, 0x03, 0x45, 0x2a, 0x52, 0x5e, 0x4a, 0x38, 0x1a, 0xae, 0xc2, 0x39, + 0xca, 0x47, 0xb4, 0xb9, 0xdb, 0x38, 0xab, 0xda, 0x5e, 0xb3, 0xbb, 0x0e, 0x3d, 0xf8, 0x17, 0x7c, + 0x86, 0x5f, 0xc4, 0xcf, 0xe1, 0x0f, 0xa0, 0x5d, 0xaf, 0xdf, 0xce, 0x17, 0xd2, 0x6f, 0x9e, 0x97, + 0x9d, 0x7d, 0x66, 0xe6, 0x99, 0x59, 0x83, 0x87, 0x33, 0x7a, 0x28, 0x08, 0xbf, 0xa5, 0x33, 0x22, + 0x0e, 0x67, 0x2c, 0x95, 0x9c, 0xc5, 0x41, 0xc6, 0x99, 0x64, 0x68, 0x40, 0x45, 0x1e, 0xe3, 0xe0, + 0x2a, 0xa7, 0xf1, 0x3c, 0xb8, 0x7d, 0xea, 0xed, 0x47, 0x8c, 0x45, 0x31, 0x39, 0xd4, 0xd6, 0xab, + 0xfc, 0xfa, 0x90, 0x24, 0x99, 0x5c, 0x14, 0xce, 0xde, 0xe3, 0x65, 0xa3, 0xa4, 0x09, 0x11, 0x12, + 0x27, 0x59, 0xe1, 0xe0, 0xff, 0xbb, 0x06, 0x3b, 0x27, 0x2a, 0x54, 0x48, 0x7e, 0xcd, 0x89, 0x90, + 0xe8, 0x00, 0xb6, 0x75, 0xe8, 0xe9, 0x22, 0x23, 0xae, 0x35, 0xb4, 0x46, 0xdb, 0x61, 0xad, 0x40, + 0x2e, 0x6c, 0x6a, 0x61, 0x7c, 0xe6, 0xae, 0x69, 0x5b, 0x29, 0xa2, 0x47, 0x00, 0x0a, 0x27, 0x79, + 0x2b, 0xcf, 0x28, 0x77, 0x7b, 0xda, 0xd8, 0xd0, 0xa0, 0x21, 0x38, 0xd7, 0x34, 0x26, 0xa7, 0x4a, + 0x93, 0x4a, 0x77, 0x5d, 0x3b, 0x34, 0x55, 0x68, 0x0f, 0x6c, 0x96, 0xcb, 0x2c, 0x97, 0xee, 0x86, + 0x36, 0x1a, 0xa9, 0x42, 0x74, 0xcc, 0x23, 0xe1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 0x79, 0x68, 0x95, 0x63, 0x4d, 0xe6, 0x6e, 0x72, 0x4b, 0x84, 0x55, 0xcd, 0x62, 0x78, + 0xbe, 0xa2, 0x59, 0x35, 0x5d, 0x57, 0x34, 0xab, 0x49, 0xd4, 0x31, 0xd8, 0xc5, 0x0b, 0xdf, 0xc5, + 0xd2, 0xfa, 0x79, 0xe8, 0x62, 0x69, 0xff, 0x18, 0x8c, 0x2c, 0xf4, 0x4c, 0x3f, 0x20, 0xc8, 0x5b, + 0x76, 0xac, 0x5f, 0x42, 0xef, 0x8e, 0xe2, 0x5f, 0xd9, 0x5a, 0xfe, 0xe2, 0xbf, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x9f, 0xe9, 0xe5, 0xf2, 0x93, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1187,6 +1238,8 @@ type ControlClient interface { Load(ctx context.Context, in *LoadRequest, opts ...grpc.CallOption) (*LoadResponse, error) // Import requests import a new image Import(ctx context.Context, opts ...grpc.CallOption) (Control_ImportClient, error) + // Tag requests to tag an image + Tag(ctx context.Context, in *TagRequest, opts ...grpc.CallOption) (*types.Empty, error) } type controlClient struct { @@ -1381,6 +1434,15 @@ func (x *controlImportClient) CloseAndRecv() (*ImportResponse, error) { return m, nil } +func (c *controlClient) Tag(ctx context.Context, in *TagRequest, opts ...grpc.CallOption) (*types.Empty, error) { + out := new(types.Empty) + err := c.cc.Invoke(ctx, "/isula.build.v1.Control/tag", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ControlServer is the server API for Control service. type ControlServer interface { // Build requests a new image building @@ -1403,6 +1465,8 @@ type ControlServer interface { Load(context.Context, *LoadRequest) (*LoadResponse, error) // Import requests import a new image Import(Control_ImportServer) error + // Tag requests to tag an image + Tag(context.Context, *TagRequest) (*types.Empty, error) } // UnimplementedControlServer can be embedded to have forward compatible implementations. @@ -1439,6 +1503,9 @@ func (*UnimplementedControlServer) Load(ctx context.Context, req *LoadRequest) ( func (*UnimplementedControlServer) Import(srv Control_ImportServer) error { return status.Errorf(codes.Unimplemented, "method Import not implemented") } +func (*UnimplementedControlServer) Tag(ctx context.Context, req *TagRequest) (*types.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Tag not implemented") +} func RegisterControlServer(s *grpc.Server, srv ControlServer) { s.RegisterService(&_Control_serviceDesc, srv) @@ -1641,6 +1708,24 @@ func (x *controlImportServer) Recv() (*ImportRequest, error) { return m, nil } +func _Control_Tag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TagRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ControlServer).Tag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/isula.build.v1.Control/Tag", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ControlServer).Tag(ctx, req.(*TagRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Control_serviceDesc = grpc.ServiceDesc{ ServiceName: "isula.build.v1.Control", HandlerType: (*ControlServer)(nil), @@ -1669,6 +1754,10 @@ var _Control_serviceDesc = grpc.ServiceDesc{ MethodName: "Load", Handler: _Control_Load_Handler, }, + { + MethodName: "tag", + Handler: _Control_Tag_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/api/services/control.proto b/api/services/control.proto index 05e8e85a5fbb6371e8f4e03a3ec7310a5a7c69a4..1b5362e7f39e646cf6fed62e126409d8137eedc8 100644 --- a/api/services/control.proto +++ b/api/services/control.proto @@ -38,6 +38,8 @@ service Control { rpc Load(LoadRequest) returns (LoadResponse); // Import requests import a new image rpc Import(stream ImportRequest) returns (ImportResponse); + // Tag requests to tag an image + rpc tag(TagRequest) returns (google.protobuf.Empty); } message BuildRequest { @@ -104,6 +106,13 @@ message ListRequest { string imageName = 1; } +message TagRequest { + // image refers to the image to be tagged + string image = 1; + // tag is the tag added to image + string tag = 2; +} + message ListResponse { message ImageInfo { string repository = 1; diff --git a/builder/dockerfile/builder.go b/builder/dockerfile/builder.go index af522890250f88d4eb662bc14bd81c1eb4b07250..8515fabd9c92a33d904cd3cc31f0e5a165de4784 100644 --- a/builder/dockerfile/builder.go +++ b/builder/dockerfile/builder.go @@ -136,13 +136,13 @@ func NewBuilder(ctx context.Context, store store.Store, req *pb.BuildRequest, ru func (b *Builder) parseTag(output, additionalTag string) error { var err error if tag := parseOutputTag(output); tag != "" { - if b.buildOpts.Tag, err = expandTag(tag, b.localStore); err != nil { + if b.buildOpts.Tag, err = ExpandTag(tag, b.localStore); err != nil { return err } } if additionalTag != "" { - if b.buildOpts.AdditionalTag, err = expandTag(additionalTag, b.localStore); err != nil { + if b.buildOpts.AdditionalTag, err = ExpandTag(additionalTag, b.localStore); err != nil { return err } } @@ -570,9 +570,9 @@ func parseOutputTag(output string) string { return tag } -// expandTag resolves tag name, if it not include a domain, "localhost" will be +// ExpandTag resolves tag name, if it not include a domain, "localhost" will be // added, and if it not include a tag, "latest" will be added. -func expandTag(tag string, store store.Store) (string, error) { +func ExpandTag(tag string, store store.Store) (string, error) { candidates, _, err := image.ResolveName(tag, nil, store) if err != nil || len(candidates) == 0 { return "", errors.Errorf("resolve tag %v err: %v", tag, err) diff --git a/cmd/cli/build.go b/cmd/cli/build.go index 2e174d6a636c991e22e18eaa76e493f2e32532ea..6f5a323c5c1b4c74849f3e6ac5e396ed41984d44 100644 --- a/cmd/cli/build.go +++ b/cmd/cli/build.go @@ -86,6 +86,7 @@ func NewContainerImageBuildCmd() *cobra.Command { NewRemoveCmd(), NewLoadCmd(), NewImportCmd(), + NewTagCmd(), ) return ctrImgBuildCmd diff --git a/cmd/cli/grpc_client_test.go b/cmd/cli/grpc_client_test.go index 2c88cdd6ab4265da0792168299fa78ea04d91cb9..c7a38bfcdfef7cf3d4e675a6a89798c04fe747be 100644 --- a/cmd/cli/grpc_client_test.go +++ b/cmd/cli/grpc_client_test.go @@ -19,7 +19,7 @@ import ( "testing" "time" - types "github.com/gogo/protobuf/types" + "github.com/gogo/protobuf/types" "google.golang.org/grpc" pb "isula.org/isula-build/api/services" @@ -86,6 +86,10 @@ func (gcli *mockGrpcClient) Version(ctx context.Context, in *types.Empty, opts . }, nil } +func (gcli *mockGrpcClient) Tag(ctx context.Context, in *pb.TagRequest, opts ...grpc.CallOption) (*types.Empty, error) { + return &types.Empty{}, nil +} + func (gcli *mockGrpcClient) Status(ctx context.Context, in *pb.StatusRequest, opts ...grpc.CallOption) (pb.Control_StatusClient, error) { if gcli.statusFunc != nil { return gcli.statusFunc(ctx, in, opts...) diff --git a/cmd/cli/tag.go b/cmd/cli/tag.go new file mode 100644 index 0000000000000000000000000000000000000000..b2be385fac2e9083779ec94cc7f9739c40e060b8 --- /dev/null +++ b/cmd/cli/tag.go @@ -0,0 +1,67 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. +// isula-build licensed under the Mulan PSL v2. +// You can use this software according to the terms and conditions of the Mulan PSL v2. +// You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +// PURPOSE. +// See the Mulan PSL v2 for more details. +// Author: Danni Xia +// Create: 2020-07-20 +// Description: This file is used for tag command + +package main + +import ( + "context" + + "github.com/pkg/errors" + "github.com/spf13/cobra" + + pb "isula.org/isula-build/api/services" +) + +const ( + tagExample = `isula-build ctr-img tag busybox:latest +isula-build ctr-img tag busybox:latest` +) + +// NewTagCmd returns tag command +func NewTagCmd() *cobra.Command { + // tagCmd represents the "tag" command + tagCmd := &cobra.Command{ + Use: "tag", + Short: "create a tag for source image", + RunE: tagCommand, + Example: tagExample, + } + return tagCmd +} + +func tagCommand(cmd *cobra.Command, args []string) error { + const validTagArgsLen = 2 + if len(args) != validTagArgsLen { + return errors.New("invalid args for tag command") + } + + ctx := context.Background() + cli, err := NewClient(ctx) + if err != nil { + return err + } + + return runTag(ctx, cli, args) +} + +func runTag(ctx context.Context, cli Cli, args []string) error { + _, err := cli.Client().Tag(ctx, &pb.TagRequest{ + Image: args[0], + Tag: args[1], + }) + if err != nil { + return err + } + + return nil +} diff --git a/cmd/cli/tag_test.go b/cmd/cli/tag_test.go new file mode 100644 index 0000000000000000000000000000000000000000..29649452e64640d65bb12e5d4c296ad92360ac68 --- /dev/null +++ b/cmd/cli/tag_test.go @@ -0,0 +1,41 @@ +// You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +// PURPOSE. +// See the Mulan PSL v2 for more details. +// Author: Danni Xia +// Create: 2020-07-20 +// Description: This file is used for testing command tag + +package main + +import ( + "context" + "testing" + + "gotest.tools/assert" +) + +func TestTagCommand(t *testing.T) { + tagCmd := NewTagCmd() + args := []string{"abc", "abc"} + err := tagCommand(tagCmd, args) + assert.ErrorContains(t, err, "isula_build.sock") + + args = []string{"abc", "abc", "abc"} + err = tagCommand(tagCmd, args) + assert.ErrorContains(t, err, "invalid args for tag command") + + args = []string{"abc"} + err = tagCommand(tagCmd, args) + assert.ErrorContains(t, err, "invalid args for tag command") +} + +func TestRuntag(t *testing.T) { + ctx := context.Background() + cli := newMockClient(&mockGrpcClient{}) + args := []string{"abc", "abc"} + err := runTag(ctx, &cli, args) + assert.NilError(t, err) +} diff --git a/daemon/tag.go b/daemon/tag.go new file mode 100644 index 0000000000000000000000000000000000000000..b921614c8e52aed7797125256b36c6785f018fad --- /dev/null +++ b/daemon/tag.go @@ -0,0 +1,53 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. +// isula-build licensed under the Mulan PSL v2. +// You can use this software according to the terms and conditions of the Mulan PSL v2. +// You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +// PURPOSE. +// See the Mulan PSL v2 for more details. +// Author: Danni Xia +// Create: 2020-07-20 +// Description: This file is "tag" command for backend + +package daemon + +import ( + "context" + + gogotypes "github.com/gogo/protobuf/types" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + + pb "isula.org/isula-build/api/services" + "isula.org/isula-build/builder/dockerfile" + "isula.org/isula-build/image" +) + +// Tag adds an additional tag to an image +func (b *Backend) Tag(ctx context.Context, req *pb.TagRequest) (*gogotypes.Empty, error) { + logrus.WithFields(logrus.Fields{ + "Image": req.GetImage(), + "Tag": req.GetTag(), + }).Info("TagRequest received") + + var emptyResp = &gogotypes.Empty{} + s := b.daemon.localStore + + _, img, err := image.FindImage(s, req.Image) + if err != nil { + return emptyResp, errors.Wrapf(err, "find local image %v error", req.Image) + } + + imageName, err := dockerfile.ExpandTag(req.Tag, s) + if err != nil { + return emptyResp, err + } + + if err := s.SetNames(img.ID, append(img.Names, imageName)); err != nil { + return emptyResp, errors.Wrapf(err, "set name %v to image %q error", req.Tag, req.Image) + } + + return emptyResp, nil +} diff --git a/doc/usage.md b/doc/usage.md index 412b2d5753bf8ea38050369e507a54d22ebcf8e2..344760f3979537fc697eca9b52ccdccb98f5328a 100644 --- a/doc/usage.md +++ b/doc/usage.md @@ -21,6 +21,7 @@ * [Authentication of the Remote Image Repository](#authentication-of-the-remote-image-repository) * [-a, --all](#-a---all-1) * [Version query](#version-query) + * [Tag an image](#tag-an-image) # Usage @@ -340,3 +341,29 @@ Server: Built: Thu Jun 11 19:02:45 2020 OS/Arch: linux/amd64 ``` + +### Tag an image + +We can use the `tag` command to add an additional tag to an image. + +Usage: + +`isula-build ctr-img tag / busybox:latest` + +```bash +$ sudo isula-build ctr-img images +---------------------------------------------- ----------- ----------------- -------------------------- ------------ + REPOSITORY TAG IMAGE ID CREATED SIZE +---------------------------------------------- ----------- ----------------- -------------------------- ------------ + docker.io/library/alpine latest a24bb4013296 2020-05-29 21:19:46 5.85 MB +---------------------------------------------- ----------- ----------------- -------------------------- ------------ +$ sudo isula-build ctr-img tag a24bb4013296 alpine:latest +$ sudo isula-build ctr-img images +---------------------------------------------- ----------- ----------------- -------------------------- ------------ + REPOSITORY TAG IMAGE ID CREATED SIZE +---------------------------------------------- ----------- ----------------- -------------------------- ------------ + docker.io/library/alpine latest a24bb4013296 2020-05-29 21:19:46 5.85 MB + localhost/alpine latest a24bb4013296 2020-05-29 21:19:46 5.85 MB +---------------------------------------------- ----------- ----------------- -------------------------- ------------ +``` +