events: autogenerate fieldpath filters
To ensure consistent fieldpath matching for events, we generate the fieldpath matching using protobuf definitions. This is done through a plugin called "fieldpath" that defines a `Field` method for each type with the plugin enabled. Generated code handles top-level envelope fields, as well as deferred serialization for matching any types. In practice, this means that we can cheaply match events on `topic` and `namespace`. If we want to match on attributes within the event, we can use the `event` prefix to address these fields. For example, the following will match all envelopes that have a field named `container_id` that has the value `testing`: ``` ctr events "event.container_id==testing" ``` The above will decode the underlying event and check that particular field. Accordingly, if only `topic` or `namespace` is used, the event will not be decoded and only match on the envelope. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
bb7b41ad7b
commit
c857ba2d0b
@ -1,6 +1,6 @@
|
|||||||
version = "unstable"
|
version = "unstable"
|
||||||
generator = "gogoctrd"
|
generator = "gogoctrd"
|
||||||
plugins = ["grpc"]
|
plugins = ["grpc", "fieldpath"]
|
||||||
|
|
||||||
# Control protoc include paths. Below are usually some good defaults, but feel
|
# Control protoc include paths. Below are usually some good defaults, but feel
|
||||||
# free to try it without them if it works for your project.
|
# free to try it without them if it works for your project.
|
||||||
|
@ -50,6 +50,9 @@ import fmt "fmt"
|
|||||||
import math "math"
|
import math "math"
|
||||||
import _ "github.com/gogo/protobuf/gogoproto"
|
import _ "github.com/gogo/protobuf/gogoproto"
|
||||||
import google_protobuf1 "github.com/gogo/protobuf/types"
|
import google_protobuf1 "github.com/gogo/protobuf/types"
|
||||||
|
import _ "github.com/containerd/containerd/protobuf/plugin"
|
||||||
|
|
||||||
|
import github_com_containerd_containerd_typeurl "github.com/containerd/containerd/typeurl"
|
||||||
|
|
||||||
import strings "strings"
|
import strings "strings"
|
||||||
import reflect "reflect"
|
import reflect "reflect"
|
||||||
@ -114,6 +117,101 @@ func init() {
|
|||||||
proto.RegisterType((*ContainerUpdate)(nil), "containerd.services.events.v1.ContainerUpdate")
|
proto.RegisterType((*ContainerUpdate)(nil), "containerd.services.events.v1.ContainerUpdate")
|
||||||
proto.RegisterType((*ContainerDelete)(nil), "containerd.services.events.v1.ContainerDelete")
|
proto.RegisterType((*ContainerDelete)(nil), "containerd.services.events.v1.ContainerDelete")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *ContainerCreate) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "id":
|
||||||
|
return string(m.ID), len(m.ID) > 0
|
||||||
|
case "image":
|
||||||
|
return string(m.Image), len(m.Image) > 0
|
||||||
|
case "runtime":
|
||||||
|
// NOTE(stevvooe): This is probably not correct in many cases.
|
||||||
|
// We assume that the target message also implements the Field
|
||||||
|
// method, which isn't likely true in a lot of cases.
|
||||||
|
//
|
||||||
|
// If you have a broken build and have found this comment,
|
||||||
|
// you may be closer to a solution.
|
||||||
|
if m.Runtime == nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
return m.Runtime.Field(fieldpath[1:])
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *ContainerCreate_Runtime) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "name":
|
||||||
|
return string(m.Name), len(m.Name) > 0
|
||||||
|
case "options":
|
||||||
|
decoded, err := github_com_containerd_containerd_typeurl.UnmarshalAny(m.Options)
|
||||||
|
if err != nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
adaptor, ok := decoded.(interface {
|
||||||
|
Field([]string) (string, bool)
|
||||||
|
})
|
||||||
|
if !ok {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
return adaptor.Field(fieldpath[1:])
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *ContainerUpdate) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "id":
|
||||||
|
return string(m.ID), len(m.ID) > 0
|
||||||
|
case "image":
|
||||||
|
return string(m.Image), len(m.Image) > 0
|
||||||
|
case "labels":
|
||||||
|
// Labels fields have been special-cased by name. If this breaks,
|
||||||
|
// add better special casing to fieldpath plugin.
|
||||||
|
if len(m.Labels) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
value, ok := m.Labels[strings.Join(fieldpath[1:], ".")]
|
||||||
|
return value, ok
|
||||||
|
case "rootfs":
|
||||||
|
return string(m.RootFS), len(m.RootFS) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *ContainerDelete) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "id":
|
||||||
|
return string(m.ID), len(m.ID) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
func (m *ContainerCreate) Marshal() (dAtA []byte, err error) {
|
func (m *ContainerCreate) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
dAtA = make([]byte, size)
|
dAtA = make([]byte, size)
|
||||||
@ -1132,31 +1230,32 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorContainer = []byte{
|
var fileDescriptorContainer = []byte{
|
||||||
// 401 bytes of a gzipped FileDescriptorProto
|
// 429 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0x41, 0x8b, 0xd4, 0x30,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0x4d, 0x8b, 0xd4, 0x40,
|
||||||
0x18, 0xdd, 0xb4, 0x6b, 0x07, 0xd3, 0x83, 0x12, 0x06, 0xa9, 0x05, 0xbb, 0x43, 0x4f, 0xe3, 0x25,
|
0x10, 0xdd, 0xce, 0xac, 0x19, 0xec, 0x39, 0x28, 0xcd, 0x20, 0x71, 0xc0, 0xec, 0x30, 0xa7, 0xf1,
|
||||||
0x65, 0x47, 0x10, 0x5d, 0x41, 0x70, 0x77, 0x55, 0x04, 0x05, 0x89, 0x08, 0xe2, 0x2d, 0x9d, 0x66,
|
0xd2, 0xcd, 0x8e, 0x20, 0xba, 0x82, 0xe8, 0xee, 0xaa, 0x08, 0x0a, 0xd2, 0xe2, 0x45, 0xbc, 0xf4,
|
||||||
0x6a, 0xb0, 0x4d, 0x4a, 0x9b, 0x16, 0x7a, 0xf3, 0xe7, 0xcd, 0xd1, 0xa3, 0xa7, 0x61, 0xa6, 0x3f,
|
0x4c, 0x6a, 0xb2, 0x8d, 0x49, 0x77, 0x48, 0x3a, 0x81, 0xdc, 0xfc, 0x29, 0xfe, 0x9c, 0x3d, 0x7a,
|
||||||
0xc1, 0x5f, 0x20, 0x4d, 0x5a, 0xa7, 0x08, 0x8a, 0x7a, 0x7b, 0x5f, 0xbe, 0xf7, 0xbe, 0xef, 0xbd,
|
0xf4, 0xb4, 0xec, 0xe6, 0x27, 0x88, 0x3f, 0x40, 0xd2, 0x9d, 0xec, 0x06, 0xc1, 0xcf, 0xdb, 0xab,
|
||||||
0x24, 0xf0, 0x65, 0xca, 0xd5, 0xa7, 0x3a, 0xc6, 0x6b, 0x99, 0x47, 0x6b, 0x29, 0x14, 0xe5, 0x82,
|
0xd4, 0x7b, 0x55, 0xef, 0x55, 0x1a, 0xbf, 0x88, 0xa5, 0x39, 0x29, 0xd7, 0x74, 0xa3, 0x53, 0xb6,
|
||||||
0x95, 0xc9, 0x14, 0xd2, 0x82, 0x47, 0x15, 0x2b, 0x1b, 0xbe, 0x66, 0x55, 0xc4, 0x1a, 0x26, 0x54,
|
0xd1, 0xca, 0x08, 0xa9, 0x20, 0x8f, 0x86, 0x50, 0x64, 0x92, 0x15, 0x90, 0x57, 0x72, 0x03, 0x05,
|
||||||
0x15, 0x35, 0xe7, 0x47, 0x06, 0x2e, 0x4a, 0xa9, 0x24, 0xba, 0x77, 0x94, 0xe0, 0x91, 0x8e, 0x0d,
|
0x83, 0x0a, 0x94, 0x29, 0x58, 0xb5, 0x7f, 0xc5, 0xa0, 0x59, 0xae, 0x8d, 0x26, 0x77, 0xae, 0x24,
|
||||||
0x1d, 0x37, 0xe7, 0xfe, 0x3c, 0x95, 0xa9, 0xd4, 0xcc, 0xa8, 0x47, 0x46, 0xe4, 0xdf, 0x4d, 0xa5,
|
0xb4, 0xa7, 0x53, 0x47, 0xa7, 0xd5, 0xfe, 0x6c, 0x1a, 0xeb, 0x58, 0x5b, 0x26, 0x6b, 0x91, 0x13,
|
||||||
0x4c, 0x33, 0x16, 0xe9, 0x2a, 0xae, 0x37, 0x11, 0x15, 0xad, 0x69, 0x85, 0x7b, 0x00, 0x6f, 0x5d,
|
0xcd, 0x6e, 0xc7, 0x5a, 0xc7, 0x09, 0x30, 0x5b, 0xad, 0xcb, 0x2d, 0x13, 0xaa, 0xee, 0x5a, 0x4f,
|
||||||
0x8d, 0x23, 0xaf, 0x4a, 0x46, 0x15, 0x43, 0x77, 0xa0, 0xc5, 0x13, 0x0f, 0x2c, 0xc0, 0xf2, 0xe6,
|
0xfe, 0x68, 0xec, 0x52, 0x94, 0x25, 0x65, 0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 0x4f, 0x06, 0x52, 0x72, 0x13, 0x8f, 0x3e, 0x42, 0xdd,
|
||||||
0xf9, 0xf2, 0xc3, 0xf6, 0x10, 0x9c, 0x7c, 0x3b, 0x04, 0x27, 0x5f, 0xba, 0x00, 0x6c, 0xbb, 0x00,
|
0xdd, 0xa2, 0x85, 0xad, 0xdd, 0x4a, 0x24, 0xe5, 0xa5, 0x5d, 0x5b, 0x1c, 0x78, 0x0f, 0xd0, 0xe2,
|
||||||
0x7c, 0xed, 0x02, 0xb0, 0xef, 0x02, 0xf0, 0xf1, 0xe9, 0x7f, 0xfe, 0xda, 0x27, 0x06, 0xc5, 0x8e,
|
0xee, 0x20, 0xf3, 0x31, 0x24, 0xf0, 0xeb, 0xcc, 0x87, 0x1f, 0x4e, 0x2f, 0xc2, 0x9d, 0xaf, 0x17,
|
||||||
0x7e, 0x90, 0x07, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x68, 0xeb, 0xf5, 0x3f, 0xfe, 0x02, 0x00,
|
0xe1, 0xce, 0xa7, 0x26, 0x44, 0xa7, 0x4d, 0x88, 0xbe, 0x34, 0x21, 0x3a, 0x6f, 0x42, 0xf4, 0xf9,
|
||||||
0x00,
|
0x7b, 0x88, 0xde, 0x3f, 0xfe, 0xcf, 0xb7, 0xff, 0xc8, 0xa1, 0xb5, 0x6f, 0x7f, 0xca, 0xbd, 0x1f,
|
||||||
|
0x01, 0x00, 0x00, 0xff, 0xff, 0x8e, 0xae, 0x41, 0x3c, 0x44, 0x03, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,10 @@ package containerd.services.events.v1;
|
|||||||
|
|
||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
import "google/protobuf/any.proto";
|
import "google/protobuf/any.proto";
|
||||||
|
import "github.com/containerd/containerd/protobuf/plugin/fieldpath.proto";
|
||||||
|
|
||||||
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
||||||
|
option (containerd.plugin.fieldpath_all) = true;
|
||||||
|
|
||||||
message ContainerCreate {
|
message ContainerCreate {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
|
@ -8,6 +8,7 @@ import proto "github.com/gogo/protobuf/proto"
|
|||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
import _ "github.com/gogo/protobuf/gogoproto"
|
import _ "github.com/gogo/protobuf/gogoproto"
|
||||||
|
import _ "github.com/containerd/containerd/protobuf/plugin"
|
||||||
|
|
||||||
import github_com_opencontainers_go_digest "github.com/opencontainers/go-digest"
|
import github_com_opencontainers_go_digest "github.com/opencontainers/go-digest"
|
||||||
|
|
||||||
@ -32,6 +33,20 @@ func (*ContentDelete) Descriptor() ([]byte, []int) { return fileDescriptorConten
|
|||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*ContentDelete)(nil), "containerd.services.events.v1.ContentDelete")
|
proto.RegisterType((*ContentDelete)(nil), "containerd.services.events.v1.ContentDelete")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *ContentDelete) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "digest":
|
||||||
|
return string(m.Digest), len(m.Digest) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
func (m *ContentDelete) Marshal() (dAtA []byte, err error) {
|
func (m *ContentDelete) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
dAtA = make([]byte, size)
|
dAtA = make([]byte, size)
|
||||||
@ -313,19 +328,21 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorContent = []byte{
|
var fileDescriptorContent = []byte{
|
||||||
// 210 bytes of a gzipped FileDescriptorProto
|
// 242 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x4d, 0xcf, 0x2c, 0xc9,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x4d, 0xcf, 0x2c, 0xc9,
|
||||||
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
|
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,
|
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, 0x82, 0x55, 0xa4, 0xe6, 0x95, 0xe8, 0x15,
|
0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0xeb, 0x97, 0x19, 0x82, 0x55, 0xa4, 0xe6, 0x95, 0xe8, 0x15,
|
||||||
0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xc9, 0x22, 0x34, 0xe8, 0xc1, 0x14, 0xeb, 0x41, 0x14, 0xeb, 0x95,
|
0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xc9, 0x22, 0x34, 0xe8, 0xc1, 0x14, 0xeb, 0x41, 0x14, 0xeb, 0x95,
|
||||||
0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x55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a3, 0x58, 0x3f, 0x3d, 0x5f, 0x17,
|
||||||
0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x46, 0xd9, 0x91, 0xe9, 0x65, 0x6b, 0x08, 0x2b, 0x89,
|
0xa2, 0x45, 0xcf, 0x05, 0x4c, 0x05, 0x41, 0x4d, 0x70, 0x8a, 0x39, 0xf1, 0x50, 0x8e, 0xe1, 0xc6,
|
||||||
0x0d, 0xec, 0x7a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x41, 0x46, 0x06, 0x3b, 0x01,
|
0x43, 0x39, 0x86, 0x86, 0x47, 0x72, 0x8c, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8,
|
||||||
|
0xe0, 0x91, 0x1c, 0xe3, 0x82, 0x2f, 0x72, 0x8c, 0x51, 0x76, 0x64, 0x06, 0x9c, 0x35, 0x84, 0x95,
|
||||||
|
0xc4, 0x06, 0xf6, 0x81, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x51, 0xce, 0xec, 0x89, 0x81, 0x01,
|
||||||
0x00, 0x00,
|
0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,10 @@ syntax = "proto3";
|
|||||||
package containerd.services.events.v1;
|
package containerd.services.events.v1;
|
||||||
|
|
||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
|
import "github.com/containerd/containerd/protobuf/plugin/fieldpath.proto";
|
||||||
|
|
||||||
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
||||||
|
option (containerd.plugin.fieldpath_all) = true;
|
||||||
|
|
||||||
message ContentDelete {
|
message ContentDelete {
|
||||||
string digest = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
|
string digest = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
|
||||||
|
@ -7,6 +7,7 @@ package events
|
|||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
|
import _ "github.com/containerd/containerd/protobuf/plugin"
|
||||||
import _ "github.com/gogo/protobuf/gogoproto"
|
import _ "github.com/gogo/protobuf/gogoproto"
|
||||||
import google_protobuf1 "github.com/gogo/protobuf/types"
|
import google_protobuf1 "github.com/gogo/protobuf/types"
|
||||||
import google_protobuf2 "github.com/golang/protobuf/ptypes/empty"
|
import google_protobuf2 "github.com/golang/protobuf/ptypes/empty"
|
||||||
@ -14,6 +15,8 @@ import _ "github.com/gogo/protobuf/types"
|
|||||||
|
|
||||||
import time "time"
|
import time "time"
|
||||||
|
|
||||||
|
import github_com_containerd_containerd_typeurl "github.com/containerd/containerd/typeurl"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "golang.org/x/net/context"
|
context "golang.org/x/net/context"
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
@ -75,6 +78,36 @@ func init() {
|
|||||||
proto.RegisterType((*Envelope)(nil), "containerd.services.events.v1.Envelope")
|
proto.RegisterType((*Envelope)(nil), "containerd.services.events.v1.Envelope")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *Envelope) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
// unhandled: timestamp
|
||||||
|
case "namespace":
|
||||||
|
return string(m.Namespace), len(m.Namespace) > 0
|
||||||
|
case "topic":
|
||||||
|
return string(m.Topic), len(m.Topic) > 0
|
||||||
|
case "event":
|
||||||
|
decoded, err := github_com_containerd_containerd_typeurl.UnmarshalAny(m.Event)
|
||||||
|
if err != nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
adaptor, ok := decoded.(interface {
|
||||||
|
Field([]string) (string, bool)
|
||||||
|
})
|
||||||
|
if !ok {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
return adaptor.Field(fieldpath[1:])
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
var _ context.Context
|
var _ context.Context
|
||||||
var _ grpc.ClientConn
|
var _ grpc.ClientConn
|
||||||
@ -1119,33 +1152,34 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorEvents = []byte{
|
var fileDescriptorEvents = []byte{
|
||||||
// 438 bytes of a gzipped FileDescriptorProto
|
// 462 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x41, 0x6f, 0xd3, 0x30,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0xcd, 0x8e, 0xd3, 0x30,
|
||||||
0x14, 0xc7, 0xeb, 0x8d, 0x6d, 0x8d, 0x27, 0x4d, 0xc8, 0xaa, 0x50, 0x08, 0x90, 0x56, 0xb9, 0x50,
|
0x14, 0x85, 0xeb, 0xf9, 0x6d, 0x3c, 0xd2, 0x08, 0x45, 0x15, 0x2a, 0x01, 0xd2, 0xaa, 0x1b, 0x2a,
|
||||||
0x21, 0xb0, 0x59, 0x39, 0x22, 0x21, 0x51, 0x28, 0xe7, 0xc9, 0x80, 0x84, 0xb8, 0x25, 0xd9, 0x5b,
|
0x04, 0x0e, 0x53, 0x76, 0x20, 0x21, 0x28, 0x94, 0xf5, 0x28, 0x80, 0x84, 0xd8, 0x25, 0xe9, 0x6d,
|
||||||
0x66, 0x29, 0x89, 0x43, 0xec, 0x04, 0xed, 0xc6, 0x47, 0xe0, 0xc2, 0xd7, 0xe0, 0x73, 0xf4, 0xc8,
|
0x6a, 0x29, 0xb1, 0x4d, 0xec, 0x04, 0xcd, 0x6e, 0x1e, 0x81, 0x0d, 0x6f, 0xc2, 0x86, 0x37, 0xe8,
|
||||||
0x91, 0x13, 0xb0, 0x7c, 0x12, 0xd4, 0x24, 0x6e, 0x58, 0x0b, 0x04, 0x71, 0x7b, 0xce, 0xfb, 0xbf,
|
0x92, 0x25, 0x2b, 0x60, 0xfa, 0x24, 0xa8, 0x89, 0xdd, 0x30, 0x2d, 0x10, 0x34, 0xbb, 0x6b, 0xdf,
|
||||||
0x5f, 0xfc, 0xfe, 0xff, 0x04, 0x3f, 0x8f, 0x84, 0x3e, 0x2f, 0x02, 0x1a, 0xca, 0x84, 0x85, 0x32,
|
0xe3, 0xcf, 0xb9, 0xe7, 0x38, 0xf8, 0x45, 0x4c, 0xd5, 0x3c, 0x0f, 0x49, 0xc4, 0x53, 0x2f, 0xe2,
|
||||||
0xd5, 0xbe, 0x48, 0x21, 0x3f, 0xfd, 0xb5, 0xf4, 0x33, 0xc1, 0x14, 0xe4, 0xa5, 0x08, 0x41, 0x31,
|
0x4c, 0x05, 0x94, 0x41, 0x36, 0xfd, 0xbd, 0x0c, 0x04, 0xf5, 0x24, 0x64, 0x05, 0x8d, 0x40, 0x7a,
|
||||||
0x28, 0x21, 0xd5, 0x8a, 0x95, 0xc7, 0x6d, 0x45, 0xb3, 0x5c, 0x6a, 0x49, 0xee, 0x74, 0x7a, 0x6a,
|
0x50, 0x00, 0x53, 0xd2, 0x2b, 0x4e, 0x74, 0x45, 0x44, 0xc6, 0x15, 0xb7, 0x6f, 0xd7, 0x7a, 0x62,
|
||||||
0xb4, 0xb4, 0x55, 0x94, 0xc7, 0xce, 0x28, 0x92, 0x91, 0xac, 0x95, 0x6c, 0x55, 0x35, 0x43, 0xce,
|
0xb4, 0x44, 0x2b, 0x8a, 0x13, 0xe7, 0x69, 0xe3, 0x25, 0x25, 0x26, 0xcc, 0x67, 0x9e, 0x48, 0xf2,
|
||||||
0xcd, 0x48, 0xca, 0x28, 0x06, 0x56, 0x9f, 0x82, 0xe2, 0x8c, 0xf9, 0xe9, 0x45, 0xdb, 0xba, 0xb5,
|
0x98, 0x32, 0x6f, 0x46, 0x21, 0x99, 0x8a, 0x40, 0xcd, 0xab, 0x0b, 0x9c, 0x4e, 0xcc, 0x63, 0x5e,
|
||||||
0xd9, 0x82, 0x24, 0xd3, 0xa6, 0x39, 0xde, 0x6c, 0x6a, 0x91, 0x80, 0xd2, 0x7e, 0x92, 0x35, 0x02,
|
0x96, 0xde, 0xaa, 0xd2, 0xbb, 0x37, 0x62, 0xce, 0xe3, 0x04, 0xea, 0xd3, 0x01, 0x3b, 0xd3, 0xad,
|
||||||
0x8f, 0xe3, 0xa3, 0x93, 0x22, 0x88, 0x85, 0x3a, 0xe7, 0xf0, 0xae, 0x00, 0xa5, 0xc9, 0x08, 0xef,
|
0x9b, 0x9b, 0x2d, 0x48, 0x85, 0x32, 0xcd, 0xde, 0x66, 0x53, 0xd1, 0x14, 0xa4, 0x0a, 0x52, 0x51,
|
||||||
0x69, 0x99, 0x89, 0xd0, 0x46, 0x13, 0x34, 0xb5, 0x78, 0x73, 0x20, 0xf7, 0xf0, 0x5e, 0x7d, 0x47,
|
0x09, 0x06, 0x3e, 0x3e, 0x3e, 0xcd, 0xc3, 0x84, 0xca, 0xb9, 0x0f, 0xef, 0x73, 0x90, 0xca, 0xee,
|
||||||
0x7b, 0x67, 0x82, 0xa6, 0x87, 0xb3, 0x11, 0x6d, 0xc0, 0xd4, 0x80, 0xe9, 0xd3, 0xf4, 0x82, 0x37,
|
0xe0, 0x7d, 0xc5, 0x05, 0x8d, 0xba, 0xa8, 0x8f, 0x86, 0x96, 0x5f, 0x2d, 0xec, 0xbb, 0x78, 0xbf,
|
||||||
0x12, 0xef, 0x35, 0x3e,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, 0x8b, 0xbe, 0x54, 0x2e, 0xfa, 0x51, 0xb9, 0xe8, 0xed, 0x93, 0xff, 0xfc, 0x1f,
|
0x3a, 0x13, 0xdb, 0x6b, 0x60, 0x6e, 0xa6, 0xe7, 0xfc, 0xef, 0x23, 0x78, 0x80, 0xc6, 0x6f, 0x17,
|
||||||
0x1f, 0x37, 0x55, 0xb0, 0x5f, 0xaf, 0xf4, 0xe8, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3b, 0x5d,
|
0x17, 0x6e, 0xeb, 0xdb, 0x85, 0xdb, 0x3a, 0x5f, 0xba, 0x68, 0xb1, 0x74, 0xd1, 0xd7, 0xa5, 0x8b,
|
||||||
0x09, 0xd6, 0xd8, 0x03, 0x00, 0x00,
|
0x7e, 0x2e, 0x5d, 0xf4, 0xee, 0xc9, 0x15, 0xff, 0xeb, 0xc7, 0x55, 0x15, 0x1e, 0x94, 0x23, 0x3d,
|
||||||
|
0xfc, 0x15, 0x00, 0x00, 0xff, 0xff, 0x1c, 0x38, 0x37, 0x72, 0x20, 0x04, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ syntax = "proto3";
|
|||||||
|
|
||||||
package containerd.services.events.v1;
|
package containerd.services.events.v1;
|
||||||
|
|
||||||
|
import "github.com/containerd/containerd/protobuf/plugin/fieldpath.proto";
|
||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
import "google/protobuf/any.proto";
|
import "google/protobuf/any.proto";
|
||||||
import "google/protobuf/empty.proto";
|
import "google/protobuf/empty.proto";
|
||||||
@ -47,6 +48,7 @@ message SubscribeRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message Envelope {
|
message Envelope {
|
||||||
|
option (containerd.plugin.fieldpath) = true;
|
||||||
google.protobuf.Timestamp timestamp = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
google.protobuf.Timestamp timestamp = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||||
string namespace = 2;
|
string namespace = 2;
|
||||||
string topic = 3;
|
string topic = 3;
|
||||||
|
@ -7,6 +7,7 @@ package events
|
|||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
|
import _ "github.com/containerd/containerd/protobuf/plugin"
|
||||||
|
|
||||||
import strings "strings"
|
import strings "strings"
|
||||||
import reflect "reflect"
|
import reflect "reflect"
|
||||||
@ -50,6 +51,64 @@ func init() {
|
|||||||
proto.RegisterType((*ImageUpdate)(nil), "containerd.services.images.v1.ImageUpdate")
|
proto.RegisterType((*ImageUpdate)(nil), "containerd.services.images.v1.ImageUpdate")
|
||||||
proto.RegisterType((*ImageDelete)(nil), "containerd.services.images.v1.ImageDelete")
|
proto.RegisterType((*ImageDelete)(nil), "containerd.services.images.v1.ImageDelete")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *ImageCreate) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "name":
|
||||||
|
return string(m.Name), len(m.Name) > 0
|
||||||
|
case "labels":
|
||||||
|
// Labels fields have been special-cased by name. If this breaks,
|
||||||
|
// add better special casing to fieldpath plugin.
|
||||||
|
if len(m.Labels) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
value, ok := m.Labels[strings.Join(fieldpath[1:], ".")]
|
||||||
|
return value, ok
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *ImageUpdate) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "name":
|
||||||
|
return string(m.Name), len(m.Name) > 0
|
||||||
|
case "labels":
|
||||||
|
// Labels fields have been special-cased by name. If this breaks,
|
||||||
|
// add better special casing to fieldpath plugin.
|
||||||
|
if len(m.Labels) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
value, ok := m.Labels[strings.Join(fieldpath[1:], ".")]
|
||||||
|
return value, ok
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *ImageDelete) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "name":
|
||||||
|
return string(m.Name), len(m.Name) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
func (m *ImageCreate) Marshal() (dAtA []byte, err error) {
|
func (m *ImageCreate) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
dAtA = make([]byte, size)
|
dAtA = make([]byte, size)
|
||||||
@ -881,22 +940,24 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorImage = []byte{
|
var fileDescriptorImage = []byte{
|
||||||
// 263 bytes of a gzipped FileDescriptorProto
|
// 296 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x4e, 0xcf, 0x2c, 0xc9,
|
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,
|
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,
|
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,
|
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,
|
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, 0x9c, 0x8b, 0x52, 0x13, 0x4b,
|
0xeb, 0x95, 0x19, 0x4a, 0x39, 0x10, 0xb4, 0x03, 0x6c, 0x4c, 0x52, 0x69, 0x9a, 0x7e, 0x41, 0x4e,
|
||||||
0x52, 0x85, 0x84, 0xb8, 0x58, 0xf2, 0x12, 0x73, 0x53, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83,
|
0x69, 0x7a, 0x66, 0x9e, 0x7e, 0x5a, 0x66, 0x6a, 0x4e, 0x4a, 0x41, 0x62, 0x49, 0x06, 0xc4, 0x02,
|
||||||
0xc0, 0x6c, 0x21, 0x3f, 0x2e, 0xb6, 0x9c, 0xc4, 0xa4, 0xd4, 0x9c, 0x62, 0x09, 0x26, 0x05, 0x66,
|
0xa5, 0x35, 0x8c, 0x5c, 0xdc, 0x9e, 0x20, 0xf3, 0x9c, 0x8b, 0x52, 0x13, 0x4b, 0x52, 0x85, 0x84,
|
||||||
0x0d, 0x6e, 0x23, 0x33, 0x3d, 0xbc, 0x66, 0xea, 0x21, 0x99, 0xa7, 0xe7, 0x03, 0xd6, 0xe8, 0x9a,
|
0xb8, 0x58, 0xf2, 0x12, 0x73, 0x53, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xc0, 0x6c, 0x21,
|
||||||
0x57, 0x52, 0x54, 0x19, 0x04, 0x35, 0x45, 0xca, 0x92, 0x8b, 0x1b, 0x49, 0x58, 0x48, 0x80, 0x8b,
|
0x3f, 0x2e, 0xb6, 0x9c, 0xc4, 0xa4, 0xd4, 0x9c, 0x62, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23,
|
||||||
0x39, 0x3b, 0xb5, 0x12, 0x6a, 0x23, 0x88, 0x29, 0x24, 0xc2, 0xc5, 0x5a, 0x96, 0x98, 0x53, 0x9a,
|
0x33, 0x3d, 0xbc, 0xae, 0xd2, 0x43, 0x32, 0x4f, 0xcf, 0x07, 0xac, 0xd1, 0x35, 0xaf, 0xa4, 0xa8,
|
||||||
0x2a, 0xc1, 0x04, 0x16, 0x83, 0x70, 0xac, 0x98, 0x2c, 0x18, 0x11, 0xce, 0x0d, 0x2d, 0x48, 0xa1,
|
0x32, 0x08, 0x6a, 0x8a, 0x94, 0x25, 0x17, 0x37, 0x92, 0xb0, 0x90, 0x00, 0x17, 0x73, 0x76, 0x6a,
|
||||||
0xaa, 0x73, 0x21, 0xe6, 0x51, 0xdb, 0xb9, 0x8a, 0x50, 0xd7, 0xba, 0xa4, 0xe6, 0xa4, 0x62, 0x77,
|
0x25, 0xd4, 0x46, 0x10, 0x53, 0x48, 0x84, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, 0x34, 0x55, 0x82, 0x09,
|
||||||
0xad, 0x53, 0xc4, 0x89, 0x87, 0x72, 0x0c, 0x37, 0x1e, 0xca, 0x31, 0x34, 0x3c, 0x92, 0x63, 0x3c,
|
0x2c, 0x06, 0xe1, 0x58, 0x31, 0x59, 0x30, 0x22, 0x9c, 0x1b, 0x5a, 0x90, 0x42, 0x55, 0xe7, 0x42,
|
||||||
0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0xa3, 0xec, 0xc8, 0x8c,
|
0xcc, 0xa3, 0xb6, 0x73, 0x15, 0xa1, 0xae, 0x75, 0x49, 0xcd, 0x49, 0xc5, 0xee, 0x5a, 0xa7, 0x98,
|
||||||
0x7e, 0x6b, 0x08, 0x2b, 0x89, 0x0d, 0x9c, 0x00, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x13,
|
0x13, 0x0f, 0xe5, 0x18, 0x6e, 0x3c, 0x94, 0x63, 0x68, 0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c,
|
||||||
0x7c, 0x2c, 0x4a, 0x47, 0x02, 0x00, 0x00,
|
0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x2e, 0xf8, 0x22, 0xc7, 0x18, 0x65, 0x47,
|
||||||
|
0x66, 0x22, 0xb2, 0x86, 0xb0, 0x92, 0xd8, 0xc0, 0xb1, 0x6c, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff,
|
||||||
|
0x44, 0x99, 0x59, 0x31, 0x8d, 0x02, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,10 @@ syntax = "proto3";
|
|||||||
|
|
||||||
package containerd.services.images.v1;
|
package containerd.services.images.v1;
|
||||||
|
|
||||||
|
import "github.com/containerd/containerd/protobuf/plugin/fieldpath.proto";
|
||||||
|
|
||||||
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
||||||
|
option (containerd.plugin.fieldpath_all) = true;
|
||||||
|
|
||||||
message ImageCreate {
|
message ImageCreate {
|
||||||
string name = 1;
|
string name = 1;
|
||||||
|
@ -8,6 +8,7 @@ import proto "github.com/gogo/protobuf/proto"
|
|||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
import _ "github.com/gogo/protobuf/gogoproto"
|
import _ "github.com/gogo/protobuf/gogoproto"
|
||||||
|
import _ "github.com/containerd/containerd/protobuf/plugin"
|
||||||
|
|
||||||
import strings "strings"
|
import strings "strings"
|
||||||
import reflect "reflect"
|
import reflect "reflect"
|
||||||
@ -51,6 +52,64 @@ func init() {
|
|||||||
proto.RegisterType((*NamespaceUpdate)(nil), "containerd.services.events.v1.NamespaceUpdate")
|
proto.RegisterType((*NamespaceUpdate)(nil), "containerd.services.events.v1.NamespaceUpdate")
|
||||||
proto.RegisterType((*NamespaceDelete)(nil), "containerd.services.events.v1.NamespaceDelete")
|
proto.RegisterType((*NamespaceDelete)(nil), "containerd.services.events.v1.NamespaceDelete")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *NamespaceCreate) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "name":
|
||||||
|
return string(m.Name), len(m.Name) > 0
|
||||||
|
case "labels":
|
||||||
|
// Labels fields have been special-cased by name. If this breaks,
|
||||||
|
// add better special casing to fieldpath plugin.
|
||||||
|
if len(m.Labels) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
value, ok := m.Labels[strings.Join(fieldpath[1:], ".")]
|
||||||
|
return value, ok
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *NamespaceUpdate) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "name":
|
||||||
|
return string(m.Name), len(m.Name) > 0
|
||||||
|
case "labels":
|
||||||
|
// Labels fields have been special-cased by name. If this breaks,
|
||||||
|
// add better special casing to fieldpath plugin.
|
||||||
|
if len(m.Labels) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
value, ok := m.Labels[strings.Join(fieldpath[1:], ".")]
|
||||||
|
return value, ok
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *NamespaceDelete) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "name":
|
||||||
|
return string(m.Name), len(m.Name) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
func (m *NamespaceCreate) Marshal() (dAtA []byte, err error) {
|
func (m *NamespaceCreate) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
dAtA = make([]byte, size)
|
dAtA = make([]byte, size)
|
||||||
@ -882,23 +941,25 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorNamespace = []byte{
|
var fileDescriptorNamespace = []byte{
|
||||||
// 277 bytes of a gzipped FileDescriptorProto
|
// 310 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x4f, 0xcf, 0x2c, 0xc9,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x4f, 0xcf, 0x2c, 0xc9,
|
||||||
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
|
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,
|
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, 0xe7, 0x25, 0xe6, 0xa6, 0x16, 0x17,
|
0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0xeb, 0x97, 0x19, 0xea, 0xe7, 0x25, 0xe6, 0xa6, 0x16, 0x17,
|
||||||
0x24, 0x26, 0xa7, 0xea, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xc9, 0x22, 0xb4, 0xe8, 0xc1, 0x94,
|
0x24, 0x26, 0xa7, 0xea, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xc9, 0x22, 0xb4, 0xe8, 0xc1, 0x94,
|
||||||
0xeb, 0x41, 0x94, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x55, 0xea, 0x83,
|
0xeb, 0x41, 0x94, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x55, 0xea, 0x83,
|
||||||
0x58, 0x10, 0x4d, 0x4a, 0x5b, 0x18, 0xb9, 0xf8, 0xfd, 0x60, 0x06, 0x39, 0x17, 0xa5, 0x26, 0x96,
|
0x58, 0x10, 0x4d, 0x52, 0x0e, 0x04, 0x6d, 0x07, 0xab, 0x4b, 0x2a, 0x4d, 0xd3, 0x2f, 0xc8, 0x29,
|
||||||
0xa4, 0x0a, 0x09, 0x71, 0xb1, 0x80, 0xcc, 0x96, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3,
|
0x4d, 0xcf, 0xcc, 0xd3, 0x4f, 0xcb, 0x4c, 0xcd, 0x49, 0x29, 0x48, 0x2c, 0xc9, 0x80, 0x98, 0xa0,
|
||||||
0x85, 0x82, 0xb8, 0xd8, 0x72, 0x12, 0x93, 0x52, 0x73, 0x8a, 0x25, 0x98, 0x14, 0x98, 0x35, 0xb8,
|
0xb4, 0x85, 0x91, 0x8b, 0xdf, 0x0f, 0xe6, 0x14, 0xe7, 0xa2, 0xd4, 0xc4, 0x92, 0x54, 0x21, 0x21,
|
||||||
0x8d, 0xac, 0xf4, 0xf0, 0xda, 0xa6, 0x87, 0x66, 0xa6, 0x9e, 0x0f, 0x58, 0xb3, 0x6b, 0x5e, 0x49,
|
0x2e, 0x16, 0x90, 0xeb, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xc0, 0x6c, 0xa1, 0x20, 0x2e,
|
||||||
0x51, 0x65, 0x10, 0xd4, 0x24, 0x29, 0x4b, 0x2e, 0x6e, 0x24, 0x61, 0x21, 0x01, 0x2e, 0xe6, 0xec,
|
0xb6, 0x9c, 0xc4, 0xa4, 0xd4, 0x9c, 0x62, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x2b, 0x3d,
|
||||||
0xd4, 0x4a, 0xa8, 0xad, 0x20, 0xa6, 0x90, 0x08, 0x17, 0x6b, 0x59, 0x62, 0x4e, 0x69, 0xaa, 0x04,
|
0xbc, 0xee, 0xd5, 0x43, 0x33, 0x53, 0xcf, 0x07, 0xac, 0xd9, 0x35, 0xaf, 0xa4, 0xa8, 0x32, 0x08,
|
||||||
0x13, 0x58, 0x0c, 0xc2, 0xb1, 0x62, 0xb2, 0x60, 0x44, 0x75, 0x76, 0x68, 0x41, 0x0a, 0xd5, 0x9d,
|
0x6a, 0x92, 0x94, 0x25, 0x17, 0x37, 0x92, 0xb0, 0x90, 0x00, 0x17, 0x73, 0x76, 0x6a, 0x25, 0xd4,
|
||||||
0x0d, 0x31, 0x93, 0xda, 0xce, 0x56, 0x45, 0x72, 0xb5, 0x4b, 0x6a, 0x4e, 0x2a, 0x76, 0x57, 0x3b,
|
0x56, 0x10, 0x53, 0x48, 0x84, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, 0x34, 0x55, 0x82, 0x09, 0x2c, 0x06,
|
||||||
0x45, 0x9c, 0x78, 0x28, 0xc7, 0x70, 0xe3, 0xa1, 0x1c, 0x43, 0xc3, 0x23, 0x39, 0xc6, 0x13, 0x8f,
|
0xe1, 0x58, 0x31, 0x59, 0x30, 0xa2, 0x3a, 0x3b, 0xb4, 0x20, 0x85, 0xea, 0xce, 0x86, 0x98, 0x49,
|
||||||
0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x31, 0xca, 0x8e, 0xcc, 0xc4, 0x62,
|
0x6d, 0x67, 0xab, 0x22, 0xb9, 0xda, 0x25, 0x35, 0x27, 0x15, 0xbb, 0xab, 0x9d, 0x62, 0x4e, 0x3c,
|
||||||
0x0d, 0x61, 0x25, 0xb1, 0x81, 0x63, 0xdd, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xbe, 0xf0, 0x68,
|
0x94, 0x63, 0xb8, 0xf1, 0x50, 0x8e, 0xa1, 0xe1, 0x91, 0x1c, 0xe3, 0x89, 0x47, 0x72, 0x8c, 0x17,
|
||||||
0xa6, 0x75, 0x02, 0x00, 0x00,
|
0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0xb8, 0xe0, 0x8b, 0x1c, 0x63, 0x94, 0x1d, 0x99, 0x49,
|
||||||
|
0xce, 0x1a, 0xc2, 0x4a, 0x62, 0x03, 0xc7, 0xbc, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x58, 0x7e,
|
||||||
|
0x6c, 0xc6, 0xbb, 0x02, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,10 @@ syntax = "proto3";
|
|||||||
package containerd.services.events.v1;
|
package containerd.services.events.v1;
|
||||||
|
|
||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
|
import "github.com/containerd/containerd/protobuf/plugin/fieldpath.proto";
|
||||||
|
|
||||||
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
||||||
|
option (containerd.plugin.fieldpath_all) = true;
|
||||||
|
|
||||||
message NamespaceCreate {
|
message NamespaceCreate {
|
||||||
string name = 1;
|
string name = 1;
|
||||||
|
@ -7,6 +7,7 @@ package events
|
|||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
|
import _ "github.com/containerd/containerd/protobuf/plugin"
|
||||||
|
|
||||||
import strings "strings"
|
import strings "strings"
|
||||||
import reflect "reflect"
|
import reflect "reflect"
|
||||||
@ -49,6 +50,52 @@ func init() {
|
|||||||
proto.RegisterType((*SnapshotCommit)(nil), "containerd.services.events.v1.SnapshotCommit")
|
proto.RegisterType((*SnapshotCommit)(nil), "containerd.services.events.v1.SnapshotCommit")
|
||||||
proto.RegisterType((*SnapshotRemove)(nil), "containerd.services.events.v1.SnapshotRemove")
|
proto.RegisterType((*SnapshotRemove)(nil), "containerd.services.events.v1.SnapshotRemove")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *SnapshotPrepare) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "key":
|
||||||
|
return string(m.Key), len(m.Key) > 0
|
||||||
|
case "parent":
|
||||||
|
return string(m.Parent), len(m.Parent) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *SnapshotCommit) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "key":
|
||||||
|
return string(m.Key), len(m.Key) > 0
|
||||||
|
case "name":
|
||||||
|
return string(m.Name), len(m.Name) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *SnapshotRemove) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "key":
|
||||||
|
return string(m.Key), len(m.Key) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
func (m *SnapshotPrepare) Marshal() (dAtA []byte, err error) {
|
func (m *SnapshotPrepare) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
dAtA = make([]byte, size)
|
dAtA = make([]byte, size)
|
||||||
@ -656,19 +703,21 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorSnapshot = []byte{
|
var fileDescriptorSnapshot = []byte{
|
||||||
// 219 bytes of a gzipped FileDescriptorProto
|
// 252 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x4b, 0xcf, 0x2c, 0xc9,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x4b, 0xcf, 0x2c, 0xc9,
|
||||||
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
|
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,
|
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, 0x17, 0xe7, 0x25, 0x16, 0x14, 0x67,
|
0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0xeb, 0x97, 0x19, 0xea, 0x17, 0xe7, 0x25, 0x16, 0x14, 0x67,
|
||||||
0xe4, 0x97, 0xe8, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xc9, 0x22, 0x74, 0xe8, 0xc1, 0x54, 0xeb,
|
0xe4, 0x97, 0xe8, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xc9, 0x22, 0x74, 0xe8, 0xc1, 0x54, 0xeb,
|
||||||
0x41, 0x54, 0xeb, 0x95, 0x19, 0x2a, 0x59, 0x73, 0xf1, 0x07, 0x43, 0x35, 0x04, 0x14, 0xa5, 0x16,
|
0x41, 0x54, 0xeb, 0x95, 0x19, 0x4a, 0x39, 0x10, 0xb4, 0x06, 0x6c, 0x4c, 0x52, 0x69, 0x9a, 0x7e,
|
||||||
0x24, 0x16, 0xa5, 0x0a, 0x09, 0x70, 0x31, 0x67, 0xa7, 0x56, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70,
|
0x41, 0x4e, 0x69, 0x7a, 0x66, 0x9e, 0x7e, 0x5a, 0x66, 0x6a, 0x4e, 0x4a, 0x41, 0x62, 0x49, 0x06,
|
||||||
0x06, 0x81, 0x98, 0x42, 0x62, 0x5c, 0x6c, 0x20, 0x99, 0xbc, 0x12, 0x09, 0x26, 0xb0, 0x20, 0x94,
|
0xc4, 0x02, 0x25, 0x6b, 0x2e, 0xfe, 0x60, 0xa8, 0x95, 0x01, 0x45, 0xa9, 0x05, 0x89, 0x45, 0xa9,
|
||||||
0xa7, 0x64, 0xc6, 0xc5, 0x07, 0xd3, 0xec, 0x9c, 0x9f, 0x9b, 0x9b, 0x59, 0x82, 0x45, 0xaf, 0x10,
|
0x42, 0x02, 0x5c, 0xcc, 0xd9, 0xa9, 0x95, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x20, 0xa6,
|
||||||
0x17, 0x4b, 0x5e, 0x62, 0x6e, 0x2a, 0x54, 0x27, 0x98, 0xad, 0xa4, 0x84, 0xd0, 0x17, 0x94, 0x9a,
|
0x90, 0x18, 0x17, 0x1b, 0x48, 0x26, 0xaf, 0x44, 0x82, 0x09, 0x2c, 0x08, 0xe5, 0x29, 0x99, 0x71,
|
||||||
0x9b, 0x5f, 0x86, 0xc5, 0x4e, 0xa7, 0x88, 0x13, 0x0f, 0xe5, 0x18, 0x6e, 0x3c, 0x94, 0x63, 0x68,
|
0xf1, 0xc1, 0x34, 0x3b, 0xe7, 0xe7, 0xe6, 0x66, 0x96, 0x60, 0xd1, 0x2b, 0xc4, 0xc5, 0x92, 0x97,
|
||||||
0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31,
|
0x98, 0x9b, 0x0a, 0xd5, 0x09, 0x66, 0x2b, 0x29, 0x21, 0xf4, 0x05, 0xa5, 0xe6, 0xe6, 0x97, 0x61,
|
||||||
0x46, 0xd9, 0x91, 0x19, 0x32, 0xd6, 0x10, 0x56, 0x12, 0x1b, 0x38, 0x60, 0x8c, 0x01, 0x01, 0x00,
|
0xb1, 0xd3, 0x29, 0xe6, 0xc4, 0x43, 0x39, 0x86, 0x1b, 0x0f, 0xe5, 0x18, 0x1a, 0x1e, 0xc9, 0x31,
|
||||||
0x00, 0xff, 0xff, 0x10, 0x4c, 0x3d, 0xb2, 0x62, 0x01, 0x00, 0x00,
|
0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x0b, 0xbe, 0xc8,
|
||||||
|
0x31, 0x46, 0xd9, 0x91, 0x19, 0xbe, 0xd6, 0x10, 0x56, 0x12, 0x1b, 0xd8, 0xf7, 0xc6, 0x80, 0x00,
|
||||||
|
0x00, 0x00, 0xff, 0xff, 0x3a, 0x82, 0x7a, 0xa7, 0xa8, 0x01, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,10 @@ syntax = "proto3";
|
|||||||
|
|
||||||
package containerd.services.events.v1;
|
package containerd.services.events.v1;
|
||||||
|
|
||||||
|
import "github.com/containerd/containerd/protobuf/plugin/fieldpath.proto";
|
||||||
|
|
||||||
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
||||||
|
option (containerd.plugin.fieldpath_all) = true;
|
||||||
|
|
||||||
message SnapshotPrepare {
|
message SnapshotPrepare {
|
||||||
string key = 1;
|
string key = 1;
|
||||||
|
@ -10,6 +10,7 @@ import math "math"
|
|||||||
import _ "github.com/gogo/protobuf/gogoproto"
|
import _ "github.com/gogo/protobuf/gogoproto"
|
||||||
import _ "github.com/gogo/protobuf/types"
|
import _ "github.com/gogo/protobuf/types"
|
||||||
import containerd_types "github.com/containerd/containerd/api/types"
|
import containerd_types "github.com/containerd/containerd/api/types"
|
||||||
|
import _ "github.com/containerd/containerd/protobuf/plugin"
|
||||||
|
|
||||||
import time "time"
|
import time "time"
|
||||||
|
|
||||||
@ -137,6 +138,184 @@ func init() {
|
|||||||
proto.RegisterType((*TaskResumed)(nil), "containerd.services.events.v1.TaskResumed")
|
proto.RegisterType((*TaskResumed)(nil), "containerd.services.events.v1.TaskResumed")
|
||||||
proto.RegisterType((*TaskCheckpointed)(nil), "containerd.services.events.v1.TaskCheckpointed")
|
proto.RegisterType((*TaskCheckpointed)(nil), "containerd.services.events.v1.TaskCheckpointed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *TaskCreate) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
// unhandled: rootfs
|
||||||
|
// unhandled: pid
|
||||||
|
case "container_id":
|
||||||
|
return string(m.ContainerID), len(m.ContainerID) > 0
|
||||||
|
case "bundle":
|
||||||
|
return string(m.Bundle), len(m.Bundle) > 0
|
||||||
|
case "io":
|
||||||
|
// NOTE(stevvooe): This is probably not correct in many cases.
|
||||||
|
// We assume that the target message also implements the Field
|
||||||
|
// method, which isn't likely true in a lot of cases.
|
||||||
|
//
|
||||||
|
// If you have a broken build and have found this comment,
|
||||||
|
// you may be closer to a solution.
|
||||||
|
if m.IO == nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
return m.IO.Field(fieldpath[1:])
|
||||||
|
case "checkpoint":
|
||||||
|
return string(m.Checkpoint), len(m.Checkpoint) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *TaskStart) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
// unhandled: pid
|
||||||
|
case "container_id":
|
||||||
|
return string(m.ContainerID), len(m.ContainerID) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *TaskDelete) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
// unhandled: pid
|
||||||
|
// unhandled: exit_status
|
||||||
|
// unhandled: exited_at
|
||||||
|
case "container_id":
|
||||||
|
return string(m.ContainerID), len(m.ContainerID) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *TaskIO) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "stdin":
|
||||||
|
return string(m.Stdin), len(m.Stdin) > 0
|
||||||
|
case "stdout":
|
||||||
|
return string(m.Stdout), len(m.Stdout) > 0
|
||||||
|
case "stderr":
|
||||||
|
return string(m.Stderr), len(m.Stderr) > 0
|
||||||
|
case "terminal":
|
||||||
|
return fmt.Sprint(m.Terminal), true
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *TaskExit) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
// unhandled: pid
|
||||||
|
// unhandled: exit_status
|
||||||
|
// unhandled: exited_at
|
||||||
|
case "container_id":
|
||||||
|
return string(m.ContainerID), len(m.ContainerID) > 0
|
||||||
|
case "id":
|
||||||
|
return string(m.ID), len(m.ID) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *TaskOOM) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "container_id":
|
||||||
|
return string(m.ContainerID), len(m.ContainerID) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *TaskExecAdded) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
// unhandled: pid
|
||||||
|
case "container_id":
|
||||||
|
return string(m.ContainerID), len(m.ContainerID) > 0
|
||||||
|
case "exec_id":
|
||||||
|
return string(m.ExecID), len(m.ExecID) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *TaskPaused) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "container_id":
|
||||||
|
return string(m.ContainerID), len(m.ContainerID) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *TaskResumed) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "container_id":
|
||||||
|
return string(m.ContainerID), len(m.ContainerID) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value for the given fieldpath as a string, if defined.
|
||||||
|
// If the value is not defined, the second value will be false.
|
||||||
|
func (m *TaskCheckpointed) Field(fieldpath []string) (string, bool) {
|
||||||
|
if len(fieldpath) == 0 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fieldpath[0] {
|
||||||
|
case "container_id":
|
||||||
|
return string(m.ContainerID), len(m.ContainerID) > 0
|
||||||
|
case "checkpoint":
|
||||||
|
return string(m.Checkpoint), len(m.Checkpoint) > 0
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
func (m *TaskCreate) Marshal() (dAtA []byte, err error) {
|
func (m *TaskCreate) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
dAtA = make([]byte, size)
|
dAtA = make([]byte, size)
|
||||||
@ -2215,43 +2394,45 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorTask = []byte{
|
var fileDescriptorTask = []byte{
|
||||||
// 607 bytes of a gzipped FileDescriptorProto
|
// 634 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x6e, 0xd3, 0x40,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x95, 0xcd, 0x6e, 0xd3, 0x40,
|
||||||
0x10, 0xc6, 0x6b, 0xa7, 0x75, 0x93, 0x09, 0x15, 0x95, 0x55, 0x41, 0x14, 0x09, 0x3b, 0x32, 0x42,
|
0x10, 0xc7, 0x6b, 0xa7, 0x75, 0x93, 0x0d, 0x15, 0x95, 0x55, 0x41, 0x14, 0x09, 0x3b, 0x32, 0x42,
|
||||||
0xca, 0xc9, 0x56, 0x8b, 0xc4, 0x05, 0x15, 0x91, 0x34, 0x1c, 0x72, 0xa8, 0x02, 0x6e, 0x0f, 0x88,
|
0xca, 0xc9, 0x56, 0x8b, 0xc4, 0x05, 0x15, 0x35, 0x69, 0x38, 0xe4, 0x50, 0x05, 0xdc, 0x9e, 0x10,
|
||||||
0x4b, 0xe4, 0xd8, 0xd3, 0x74, 0x69, 0xe2, 0x8d, 0xbc, 0xe3, 0xa8, 0x70, 0xe2, 0x11, 0x78, 0x1a,
|
0x52, 0xe4, 0xd8, 0x93, 0x74, 0x69, 0xec, 0xb5, 0xbc, 0xe3, 0xa8, 0x70, 0xe2, 0x11, 0x78, 0x04,
|
||||||
0x9e, 0xa1, 0x07, 0x0e, 0x1c, 0x39, 0x05, 0xea, 0xc7, 0xe0, 0x84, 0xd6, 0xeb, 0xa4, 0xe1, 0x5f,
|
0x9e, 0x82, 0x67, 0xe8, 0x81, 0x03, 0x47, 0x4e, 0x81, 0xfa, 0x19, 0x38, 0x71, 0x42, 0xeb, 0x75,
|
||||||
0x85, 0x7c, 0xdb, 0x19, 0x7f, 0x3b, 0xfe, 0xe6, 0xe7, 0xf1, 0x40, 0x77, 0xcc, 0xe8, 0x3c, 0x1d,
|
0xdc, 0xf2, 0x55, 0x90, 0x6f, 0x33, 0xe3, 0x99, 0xff, 0xce, 0xfc, 0x76, 0xb2, 0x21, 0xfd, 0x19,
|
||||||
0xb9, 0x21, 0x9f, 0x7a, 0x21, 0x8f, 0x29, 0x60, 0x31, 0x26, 0xd1, 0xfa, 0x31, 0x98, 0x31, 0x4f,
|
0xc5, 0xd3, 0x74, 0x62, 0xfb, 0x2c, 0x74, 0x7c, 0x16, 0xa1, 0x47, 0x23, 0x48, 0x82, 0xeb, 0xa6,
|
||||||
0x60, 0x32, 0x67, 0x21, 0x0a, 0x0f, 0xe7, 0x18, 0x93, 0xf0, 0xe6, 0xfb, 0x1e, 0x05, 0xe2, 0xc2,
|
0x17, 0x53, 0x87, 0x43, 0xb2, 0xa0, 0x3e, 0x70, 0x07, 0x16, 0x10, 0x21, 0x77, 0x16, 0xbb, 0x0e,
|
||||||
0x9d, 0x25, 0x9c, 0xb8, 0xf9, 0xe0, 0x46, 0xed, 0x2e, 0x95, 0xae, 0x52, 0xba, 0xf3, 0xfd, 0xe6,
|
0x7a, 0xfc, 0xcc, 0x8e, 0x13, 0x86, 0x4c, 0xbf, 0x77, 0x95, 0x6d, 0xaf, 0x32, 0x6d, 0x99, 0x69,
|
||||||
0xde, 0x98, 0x8f, 0x79, 0xae, 0xf4, 0xe4, 0x49, 0x5d, 0x6a, 0xda, 0x63, 0xce, 0xc7, 0x13, 0xf4,
|
0x2f, 0x76, 0xdb, 0x3b, 0x33, 0x36, 0x63, 0x79, 0xa6, 0x23, 0x2c, 0x59, 0xd4, 0x36, 0x67, 0x8c,
|
||||||
0xf2, 0x68, 0x94, 0x9e, 0x79, 0xc4, 0xa6, 0x28, 0x28, 0x98, 0xce, 0x0a, 0xc1, 0x93, 0xff, 0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64, 0x34, 0x14,
|
0x75, 0x94, 0xee, 0x96, 0x2b, 0x4c, 0xeb, 0x39, 0x69, 0x08, 0x9d, 0x63, 0xf4, 0x12, 0xac, 0x34,
|
||||||
0x14, 0x50, 0x2a, 0x71, 0xca, 0x27, 0x20, 0x53, 0x27, 0x79, 0xc6, 0xec, 0x40, 0x4d, 0x46, 0x18,
|
0x7a, 0x21, 0xa9, 0x5e, 0x49, 0x7e, 0x28, 0x78, 0x0e, 0x60, 0x0e, 0x15, 0x79, 0xfe, 0x26, 0xaa,
|
||||||
0x0d, 0x03, 0x2a, 0x00, 0x36, 0x5d, 0x35, 0x32, 0xee, 0x72, 0x64, 0xdc, 0xd3, 0xe5, 0xc8, 0x74,
|
0x9b, 0xa4, 0x09, 0xe7, 0x14, 0xc7, 0x1c, 0x3d, 0x4c, 0x05, 0x4e, 0xf1, 0x85, 0x88, 0xd0, 0x71,
|
||||||
0xab, 0x57, 0x0b, 0x7b, 0xe3, 0xe3, 0x37, 0x5b, 0xf3, 0xab, 0xea, 0x5a, 0x87, 0x9c, 0xb7, 0x60,
|
0x1e, 0xd1, 0x7b, 0xa4, 0x21, 0x3c, 0x08, 0xc6, 0x1e, 0x16, 0x00, 0xdb, 0xb6, 0x5c, 0x3a, 0x7b,
|
||||||
0x28, 0xa6, 0xe6, 0x1e, 0x6c, 0x09, 0x8a, 0x58, 0xac, 0xcc, 0xfa, 0x2a, 0x90, 0x5f, 0x59, 0x50,
|
0xb5, 0x01, 0xf6, 0xc9, 0x6a, 0xe9, 0xfa, 0xf5, 0x8b, 0xa5, 0xb9, 0xf6, 0xee, 0x8b, 0xa9, 0xb8,
|
||||||
0xc4, 0x53, 0x5a, 0x7e, 0x65, 0x15, 0x15, 0x79, 0x4c, 0x92, 0xdc, 0x96, 0xca, 0x63, 0x92, 0x98,
|
0x75, 0x59, 0xd6, 0x43, 0xeb, 0x15, 0xd1, 0x24, 0x53, 0x7d, 0x87, 0x6c, 0x70, 0x0c, 0x68, 0x24,
|
||||||
0x4d, 0xa8, 0x12, 0x26, 0x53, 0x16, 0x07, 0x93, 0xdc, 0x51, 0xd5, 0x5f, 0xc5, 0xce, 0x67, 0x0d,
|
0x9b, 0x75, 0xa5, 0x23, 0x6e, 0x99, 0x63, 0xc0, 0x52, 0x5c, 0xdd, 0xb2, 0xf4, 0x8a, 0x38, 0x24,
|
||||||
0xaa, 0xf2, 0x65, 0x2f, 0x2e, 0x19, 0x95, 0x1c, 0x39, 0xbd, 0x20, 0x54, 0x2b, 0x46, 0xa0, 0xe7,
|
0x49, 0xde, 0x96, 0x8c, 0x43, 0x92, 0xe8, 0x6d, 0x52, 0x47, 0x48, 0x42, 0x1a, 0x79, 0xf3, 0xbc,
|
||||||
0xeb, 0x6c, 0x85, 0xae, 0xf2, 0x4f, 0x74, 0x9b, 0xb7, 0xa3, 0xdb, 0x2a, 0x85, 0xee, 0x10, 0xb6,
|
0xa3, 0xba, 0x5b, 0xfa, 0xd6, 0x47, 0x85, 0xd4, 0xc5, 0x61, 0x4f, 0xcf, 0x29, 0x56, 0x5c, 0x39,
|
||||||
0x65, 0x37, 0x83, 0xc1, 0x71, 0x99, 0x66, 0x9c, 0xf7, 0xb0, 0xa3, 0x60, 0x60, 0xd8, 0x89, 0x22,
|
0xb5, 0x20, 0xd4, 0x28, 0x56, 0x60, 0xe0, 0xaa, 0xb4, 0x44, 0x57, 0xfb, 0x2b, 0xba, 0xf5, 0x9b,
|
||||||
0x8c, 0x4a, 0x11, 0x79, 0x08, 0xdb, 0x78, 0x89, 0xe1, 0x70, 0x85, 0x05, 0xb2, 0x85, 0x6d, 0xc8,
|
0xd1, 0x6d, 0x54, 0x42, 0xb7, 0x4f, 0x36, 0xc5, 0x34, 0xa3, 0xd1, 0x51, 0x95, 0x61, 0xac, 0x37,
|
||||||
0x9a, 0xfd, 0x9e, 0x6f, 0xc8, 0x47, 0xfd, 0xbf, 0xe0, 0x71, 0x9e, 0xab, 0x69, 0x7d, 0x19, 0xa4,
|
0x64, 0x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93, 0x8a, 0xff, 0x0e, 0x8f, 0xa5, 0x35, 0xd1, 0xf2, 0x6d, 0x79, 0xf8, 0x23, 0x00, 0x00,
|
||||||
|
0xff, 0xff, 0xfd, 0xdf, 0x0f, 0x7f, 0x66, 0x06, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,10 @@ package containerd.services.events.v1;
|
|||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
import "google/protobuf/timestamp.proto";
|
import "google/protobuf/timestamp.proto";
|
||||||
import "github.com/containerd/containerd/api/types/mount.proto";
|
import "github.com/containerd/containerd/api/types/mount.proto";
|
||||||
|
import "github.com/containerd/containerd/protobuf/plugin/fieldpath.proto";
|
||||||
|
|
||||||
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
||||||
|
option (containerd.plugin.fieldpath_all) = true;
|
||||||
|
|
||||||
message TaskCreate {
|
message TaskCreate {
|
||||||
string container_id = 1;
|
string container_id = 1;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "github.com/containerd/containerd/protobuf/plugin/fieldpath"
|
||||||
"github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
"github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||||
"github.com/gogo/protobuf/vanity"
|
"github.com/gogo/protobuf/vanity"
|
||||||
"github.com/gogo/protobuf/vanity/command"
|
"github.com/gogo/protobuf/vanity/command"
|
||||||
|
@ -219,25 +219,8 @@ func validateEnvelope(envelope *events.Envelope) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func adapt(ev interface{}) filters.Adaptor {
|
func adapt(ev interface{}) filters.Adaptor {
|
||||||
switch ev := ev.(type) {
|
if adaptor, ok := ev.(filters.Adaptor); ok {
|
||||||
case *events.Envelope:
|
return adaptor
|
||||||
return filters.AdapterFunc(func(fieldpath []string) (string, bool) {
|
|
||||||
if len(fieldpath) == 0 {
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
|
|
||||||
switch fieldpath[0] {
|
|
||||||
case "namespace":
|
|
||||||
return ev.Namespace, len(ev.Namespace) > 0
|
|
||||||
case "topic":
|
|
||||||
return ev.Topic, len(ev.Topic) > 0
|
|
||||||
default:
|
|
||||||
// TODO(stevvooe): Handle event fields.
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
case filters.Adaptor:
|
|
||||||
return ev
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return filters.AdapterFunc(func(fieldpath []string) (string, bool) {
|
return filters.AdapterFunc(func(fieldpath []string) (string, bool) {
|
||||||
|
1
protobuf/plugin/doc.go
Normal file
1
protobuf/plugin/doc.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package plugin
|
73
protobuf/plugin/fieldpath.pb.go
Normal file
73
protobuf/plugin/fieldpath.pb.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// Code generated by protoc-gen-gogo.
|
||||||
|
// source: github.com/containerd/containerd/protobuf/plugin/fieldpath.proto
|
||||||
|
// DO NOT EDIT!
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package plugin is a generated protocol buffer package.
|
||||||
|
|
||||||
|
It is generated from these files:
|
||||||
|
github.com/containerd/containerd/protobuf/plugin/fieldpath.proto
|
||||||
|
|
||||||
|
It has these top-level messages:
|
||||||
|
*/
|
||||||
|
package plugin
|
||||||
|
|
||||||
|
import proto "github.com/gogo/protobuf/proto"
|
||||||
|
import fmt "fmt"
|
||||||
|
import math "math"
|
||||||
|
import google_protobuf "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
|
var E_FieldpathAll = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*google_protobuf.FileOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 63300,
|
||||||
|
Name: "containerd.plugin.fieldpath_all",
|
||||||
|
Tag: "varint,63300,opt,name=fieldpath_all,json=fieldpathAll",
|
||||||
|
Filename: "github.com/containerd/containerd/protobuf/plugin/fieldpath.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
var E_Fieldpath = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*google_protobuf.MessageOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 64400,
|
||||||
|
Name: "containerd.plugin.fieldpath",
|
||||||
|
Tag: "varint,64400,opt,name=fieldpath",
|
||||||
|
Filename: "github.com/containerd/containerd/protobuf/plugin/fieldpath.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterExtension(E_FieldpathAll)
|
||||||
|
proto.RegisterExtension(E_Fieldpath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterFile("github.com/containerd/containerd/protobuf/plugin/fieldpath.proto", fileDescriptorFieldpath)
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileDescriptorFieldpath = []byte{
|
||||||
|
// 203 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x48, 0xcf, 0x2c, 0xc9,
|
||||||
|
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
|
||||||
|
0x4a, 0x41, 0x66, 0x16, 0x14, 0xe5, 0x97, 0xe4, 0x27, 0x95, 0xa6, 0xe9, 0x17, 0xe4, 0x94, 0xa6,
|
||||||
|
0x67, 0xe6, 0xe9, 0xa7, 0x65, 0xa6, 0xe6, 0xa4, 0x14, 0x24, 0x96, 0x64, 0xe8, 0x81, 0x65, 0x84,
|
||||||
|
0x04, 0x11, 0x6a, 0xf5, 0x20, 0x4a, 0xa4, 0x14, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0x11, 0x5a,
|
||||||
|
0x53, 0x52, 0x8b, 0x93, 0x8b, 0x32, 0x0b, 0x4a, 0xf2, 0x8b, 0x20, 0x9a, 0xac, 0x9c, 0xb9, 0x78,
|
||||||
|
0xe1, 0xe6, 0xc4, 0x27, 0xe6, 0xe4, 0x08, 0xc9, 0xe8, 0x41, 0xf4, 0xe8, 0xc1, 0xf4, 0xe8, 0xb9,
|
||||||
|
0x65, 0xe6, 0xa4, 0xfa, 0x17, 0x94, 0x64, 0xe6, 0xe7, 0x15, 0x4b, 0x1c, 0x79, 0xc7, 0xac, 0xc0,
|
||||||
|
0xa8, 0xc1, 0x11, 0xc4, 0x03, 0xd7, 0xe4, 0x98, 0x93, 0x63, 0x65, 0xcf, 0xc5, 0x09, 0xe7, 0x0b,
|
||||||
|
0xc9, 0x63, 0x18, 0xe0, 0x9b, 0x5a, 0x5c, 0x9c, 0x98, 0x0e, 0x37, 0x63, 0xc2, 0x77, 0x88, 0x19,
|
||||||
|
0x08, 0x3d, 0x4e, 0x12, 0x27, 0x1e, 0xca, 0x31, 0xdc, 0x78, 0x28, 0xc7, 0xd0, 0xf0, 0x48, 0x8e,
|
||||||
|
0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x04, 0x04, 0x00,
|
||||||
|
0x00, 0xff, 0xff, 0xd6, 0x21, 0x2a, 0xb6, 0x17, 0x01, 0x00, 0x00,
|
||||||
|
}
|
40
protobuf/plugin/fieldpath.proto
Normal file
40
protobuf/plugin/fieldpath.proto
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// Protocol Buffers for Go with Gadgets
|
||||||
|
//
|
||||||
|
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
|
||||||
|
// http://github.com/gogo/protobuf
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
syntax = "proto2";
|
||||||
|
package containerd.plugin;
|
||||||
|
|
||||||
|
import "google/protobuf/descriptor.proto";
|
||||||
|
|
||||||
|
extend google.protobuf.FileOptions {
|
||||||
|
optional bool fieldpath_all = 63300;
|
||||||
|
}
|
||||||
|
|
||||||
|
extend google.protobuf.MessageOptions {
|
||||||
|
optional bool fieldpath = 64400;
|
||||||
|
}
|
157
protobuf/plugin/fieldpath/fieldpath.go
Normal file
157
protobuf/plugin/fieldpath/fieldpath.go
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
package fieldpath
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd/protobuf/plugin"
|
||||||
|
"github.com/gogo/protobuf/gogoproto"
|
||||||
|
"github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||||
|
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||||
|
)
|
||||||
|
|
||||||
|
type fieldpathGenerator struct {
|
||||||
|
*generator.Generator
|
||||||
|
generator.PluginImports
|
||||||
|
typeurlPkg generator.Single
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
generator.RegisterPlugin(new(fieldpathGenerator))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *fieldpathGenerator) Name() string {
|
||||||
|
return "fieldpath"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *fieldpathGenerator) Init(g *generator.Generator) {
|
||||||
|
p.Generator = g
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *fieldpathGenerator) Generate(file *generator.FileDescriptor) {
|
||||||
|
p.PluginImports = generator.NewPluginImports(p.Generator)
|
||||||
|
p.typeurlPkg = p.NewImport("github.com/containerd/containerd/typeurl")
|
||||||
|
|
||||||
|
for _, m := range file.Messages() {
|
||||||
|
if m.DescriptorProto.GetOptions().GetMapEntry() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if plugin.FieldpathEnabled(file.FileDescriptorProto, m.DescriptorProto) {
|
||||||
|
p.generateMessage(m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *fieldpathGenerator) generateMessage(m *generator.Descriptor) {
|
||||||
|
ccTypeName := generator.CamelCaseSlice(m.TypeName())
|
||||||
|
|
||||||
|
p.P()
|
||||||
|
p.P(`// Field returns the value for the given fieldpath as a string, if defined.`)
|
||||||
|
p.P(`// If the value is not defined, the second value will be false.`)
|
||||||
|
p.P("func(m *", ccTypeName, ") Field(fieldpath []string) (string, bool) {")
|
||||||
|
p.In()
|
||||||
|
|
||||||
|
var (
|
||||||
|
fields []*descriptor.FieldDescriptorProto
|
||||||
|
unhandled []*descriptor.FieldDescriptorProto
|
||||||
|
)
|
||||||
|
|
||||||
|
for _, f := range m.Field {
|
||||||
|
if f.IsBool() || f.IsString() || isLabelsField(f) || isAnyField(f) || isMessageField(f) {
|
||||||
|
fields = append(fields, f)
|
||||||
|
} else {
|
||||||
|
unhandled = append(unhandled, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(fields) > 0 {
|
||||||
|
p.P(`if len(fieldpath) == 0 {`)
|
||||||
|
p.In()
|
||||||
|
p.P(`return "", false`)
|
||||||
|
p.Out()
|
||||||
|
p.P(`}`)
|
||||||
|
p.P()
|
||||||
|
p.P("switch fieldpath[0] {")
|
||||||
|
|
||||||
|
for _, f := range unhandled {
|
||||||
|
p.P("// unhandled: ", f.GetName())
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, f := range fields {
|
||||||
|
fName := generator.CamelCase(*f.Name)
|
||||||
|
if gogoproto.IsCustomName(f) {
|
||||||
|
fName = gogoproto.GetCustomName(f)
|
||||||
|
}
|
||||||
|
|
||||||
|
p.P(`case "`, f.GetName(), `":`)
|
||||||
|
p.In()
|
||||||
|
switch {
|
||||||
|
case isLabelsField(f):
|
||||||
|
p.P(`// Labels fields have been special-cased by name. If this breaks,`)
|
||||||
|
p.P(`// add better special casing to fieldpath plugin.`)
|
||||||
|
p.P(`if len(m.`, fName, `) == 0 {`)
|
||||||
|
p.In()
|
||||||
|
p.P(`return "", false`)
|
||||||
|
p.Out()
|
||||||
|
p.P("}")
|
||||||
|
p.P(`value, ok := m.`, fName, `[strings.Join(fieldpath[1:], ".")]`)
|
||||||
|
p.P(`return value, ok`)
|
||||||
|
case isAnyField(f):
|
||||||
|
p.P(`decoded, err := `, p.typeurlPkg.Use(), `.UnmarshalAny(m.`, fName, `)`)
|
||||||
|
p.P(`if err != nil {`)
|
||||||
|
p.In()
|
||||||
|
p.P(`return "", false`)
|
||||||
|
p.Out()
|
||||||
|
p.P(`}`)
|
||||||
|
p.P()
|
||||||
|
p.P(`adaptor, ok := decoded.(interface { Field([]string) (string, bool) })`)
|
||||||
|
p.P(`if !ok {`)
|
||||||
|
p.In()
|
||||||
|
p.P(`return "", false`)
|
||||||
|
p.Out()
|
||||||
|
p.P(`}`)
|
||||||
|
p.P(`return adaptor.Field(fieldpath[1:])`)
|
||||||
|
case isMessageField(f):
|
||||||
|
p.P(`// NOTE(stevvooe): This is probably not correct in many cases.`)
|
||||||
|
p.P(`// We assume that the target message also implements the Field`)
|
||||||
|
p.P(`// method, which isn't likely true in a lot of cases.`)
|
||||||
|
p.P(`//`)
|
||||||
|
p.P(`// If you have a broken build and have found this comment,`)
|
||||||
|
p.P(`// you may be closer to a solution.`)
|
||||||
|
p.P(`if m.`, fName, ` == nil {`)
|
||||||
|
p.In()
|
||||||
|
p.P(`return "", false`)
|
||||||
|
p.Out()
|
||||||
|
p.P(`}`)
|
||||||
|
p.P()
|
||||||
|
p.P(`return m.`, fName, `.Field(fieldpath[1:])`)
|
||||||
|
case f.IsString():
|
||||||
|
p.P(`return string(m.`, fName, `), len(m.`, fName, `) > 0`)
|
||||||
|
case f.IsBool():
|
||||||
|
p.P(`return fmt.Sprint(m.`, fName, `), true`)
|
||||||
|
}
|
||||||
|
p.Out()
|
||||||
|
}
|
||||||
|
|
||||||
|
p.P(`}`)
|
||||||
|
} else {
|
||||||
|
for _, f := range unhandled {
|
||||||
|
p.P("// unhandled: ", f.GetName())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p.P(`return "", false`)
|
||||||
|
p.Out()
|
||||||
|
p.P("}")
|
||||||
|
}
|
||||||
|
|
||||||
|
func isMessageField(f *descriptor.FieldDescriptorProto) bool {
|
||||||
|
return !f.IsRepeated() && f.IsMessage() && f.GetTypeName() != ".google.protobuf.Timestamp"
|
||||||
|
}
|
||||||
|
|
||||||
|
func isLabelsField(f *descriptor.FieldDescriptorProto) bool {
|
||||||
|
return f.IsMessage() && f.GetName() == "labels" && strings.HasSuffix(f.GetTypeName(), ".LabelsEntry")
|
||||||
|
}
|
||||||
|
|
||||||
|
func isAnyField(f *descriptor.FieldDescriptorProto) bool {
|
||||||
|
return !f.IsRepeated() && f.IsMessage() && f.GetTypeName() == ".google.protobuf.Any"
|
||||||
|
}
|
10
protobuf/plugin/helpers.go
Normal file
10
protobuf/plugin/helpers.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package plugin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogo/protobuf/proto"
|
||||||
|
"github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||||
|
)
|
||||||
|
|
||||||
|
func FieldpathEnabled(file *descriptor.FileDescriptorProto, message *descriptor.DescriptorProto) bool {
|
||||||
|
return proto.GetBoolExtension(message.Options, E_Fieldpath, proto.GetBoolExtension(file.Options, E_FieldpathAll, false))
|
||||||
|
}
|
62
typeurl/marshal_test.go
Normal file
62
typeurl/marshal_test.go
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
package typeurl_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
eventsapi "github.com/containerd/containerd/api/services/events/v1"
|
||||||
|
"github.com/containerd/containerd/typeurl"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMarshalEvent(t *testing.T) {
|
||||||
|
for _, testcase := range []struct {
|
||||||
|
event interface{}
|
||||||
|
url string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
event: &eventsapi.TaskStart{},
|
||||||
|
url: "types.containerd.io/containerd.services.events.v1.TaskStart",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
event: &eventsapi.NamespaceUpdate{},
|
||||||
|
url: "types.containerd.io/containerd.services.events.v1.NamespaceUpdate",
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
t.Run(fmt.Sprintf("%T", testcase.event), func(t *testing.T) {
|
||||||
|
a, err := typeurl.MarshalAny(testcase.event)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if a.TypeUrl != testcase.url {
|
||||||
|
t.Fatalf("unexpected url: %v != %v", a.TypeUrl, testcase.url)
|
||||||
|
}
|
||||||
|
|
||||||
|
v, err := typeurl.UnmarshalAny(a)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(v, testcase.event) {
|
||||||
|
t.Fatalf("round trip failed %v != %v", v, testcase.event)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkMarshalEvent(b *testing.B) {
|
||||||
|
ev := &eventsapi.TaskStart{}
|
||||||
|
expected, err := typeurl.MarshalAny(ev)
|
||||||
|
if err != nil {
|
||||||
|
b.Fatal(err)
|
||||||
|
}
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
a, err := typeurl.MarshalAny(ev)
|
||||||
|
if err != nil {
|
||||||
|
b.Fatal(err)
|
||||||
|
}
|
||||||
|
if a.TypeUrl != expected.TypeUrl {
|
||||||
|
b.Fatalf("incorrect type url: %v != %v", a, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,9 @@
|
|||||||
package typeurl
|
package typeurl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
eventsapi "github.com/containerd/containerd/api/services/events/v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type test struct {
|
type test struct {
|
||||||
@ -106,41 +103,6 @@ func TestIs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMarshalEvent(t *testing.T) {
|
|
||||||
for _, testcase := range []struct {
|
|
||||||
event interface{}
|
|
||||||
url string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
event: &eventsapi.TaskStart{},
|
|
||||||
url: "types.containerd.io/containerd.services.events.v1.TaskStart",
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
event: &eventsapi.NamespaceUpdate{},
|
|
||||||
url: "types.containerd.io/containerd.services.events.v1.NamespaceUpdate",
|
|
||||||
},
|
|
||||||
} {
|
|
||||||
t.Run(fmt.Sprintf("%T", testcase.event), func(t *testing.T) {
|
|
||||||
a, err := MarshalAny(testcase.event)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if a.TypeUrl != testcase.url {
|
|
||||||
t.Fatalf("unexpected url: %v != %v", a.TypeUrl, testcase.url)
|
|
||||||
}
|
|
||||||
|
|
||||||
v, err := UnmarshalAny(a)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(v, testcase.event) {
|
|
||||||
t.Fatalf("round trip failed %v != %v", v, testcase.event)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRegisterDiffUrls(t *testing.T) {
|
func TestRegisterDiffUrls(t *testing.T) {
|
||||||
clear()
|
clear()
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -151,20 +113,3 @@ func TestRegisterDiffUrls(t *testing.T) {
|
|||||||
Register(&test{}, "test")
|
Register(&test{}, "test")
|
||||||
Register(&test{}, "test", "two")
|
Register(&test{}, "test", "two")
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkMarshalEvent(b *testing.B) {
|
|
||||||
ev := &eventsapi.TaskStart{}
|
|
||||||
expected, err := MarshalAny(ev)
|
|
||||||
if err != nil {
|
|
||||||
b.Fatal(err)
|
|
||||||
}
|
|
||||||
for i := 0; i < b.N; i++ {
|
|
||||||
a, err := MarshalAny(ev)
|
|
||||||
if err != nil {
|
|
||||||
b.Fatal(err)
|
|
||||||
}
|
|
||||||
if a.TypeUrl != expected.TypeUrl {
|
|
||||||
b.Fatalf("incorrect type url: %v != %v", a, expected)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user