diff --git a/providers-sdk/v1/inventory/inventory.go b/providers-sdk/v1/inventory/inventory.go index 0ac96bb14b..3160646a72 100644 --- a/providers-sdk/v1/inventory/inventory.go +++ b/providers-sdk/v1/inventory/inventory.go @@ -378,7 +378,8 @@ func (p *Platform) PrettyTitle() string { } type cloneSettings struct { - noDiscovery bool + noDiscovery bool + parentConnectionId *uint32 } type CloneOption interface { @@ -394,6 +395,17 @@ type withoutDiscovery struct{} func (w withoutDiscovery) Apply(o *cloneSettings) { o.noDiscovery = true } +// WithoutDiscovery removes the discovery flags in the opts to ensure the same discovery does not run again +func WithParentConnectionId(parentId uint32) CloneOption { + return withParentConnectionId{parentId: parentId} +} + +type withParentConnectionId struct { + parentId uint32 +} + +func (w withParentConnectionId) Apply(o *cloneSettings) { o.parentConnectionId = &w.parentId } + func (cfg *Config) Clone(opts ...CloneOption) *Config { if cfg == nil { return nil @@ -409,6 +421,9 @@ func (cfg *Config) Clone(opts ...CloneOption) *Config { if cloneSettings.noDiscovery { clonedObject.Discover = &Discovery{} } + if cloneSettings.parentConnectionId != nil { + clonedObject.ParentConnectionId = *cloneSettings.parentConnectionId + } return clonedObject } diff --git a/providers-sdk/v1/inventory/inventory.pb.go b/providers-sdk/v1/inventory/inventory.pb.go index 989b6f7248..c932ff25cd 100644 --- a/providers-sdk/v1/inventory/inventory.pb.go +++ b/providers-sdk/v1/inventory/inventory.pb.go @@ -642,10 +642,11 @@ type Config struct { // Ports are not int by default, eg. docker://centos:latest parses a string // as port. Therefore it is up to the provider to convert the port to what // they need - Port int32 `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"` - Path string `protobuf:"bytes,4,opt,name=path,proto3" json:"path,omitempty"` - Id uint32 `protobuf:"varint,5,opt,name=id,proto3" json:"id,omitempty"` - Type string `protobuf:"bytes,12,opt,name=type,proto3" json:"type,omitempty"` + Port int32 `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"` + Path string `protobuf:"bytes,4,opt,name=path,proto3" json:"path,omitempty"` + Id uint32 `protobuf:"varint,5,opt,name=id,proto3" json:"id,omitempty"` + ParentConnectionId uint32 `protobuf:"varint,30,opt,name=parent_connection_id,json=parentConnectionId,proto3" json:"parent_connection_id,omitempty"` + Type string `protobuf:"bytes,12,opt,name=type,proto3" json:"type,omitempty"` // credentials available for this provider configuration Credentials []*vault.Credential `protobuf:"bytes,11,rep,name=credentials,proto3" json:"credentials,omitempty"` Insecure bool `protobuf:"varint,8,opt,name=insecure,proto3" json:"insecure,omitempty"` // disable ssl/tls checks @@ -736,6 +737,13 @@ func (x *Config) GetId() uint32 { return 0 } +func (x *Config) GetParentConnectionId() uint32 { + if x != nil { + return x.ParentConnectionId + } + return 0 +} + func (x *Config) GetType() string { if x != nil { return x.Type @@ -1650,7 +1658,7 @@ var file_inventory_proto_rawDesc = []byte{ 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x4a, - 0x04, 0x08, 0x1e, 0x10, 0x1f, 0x22, 0xc6, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x04, 0x08, 0x1e, 0x10, 0x1f, 0x22, 0xf8, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3c, 0x0a, 0x07, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x18, 0x1c, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x22, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, @@ -1663,240 +1671,244 @@ var file_inventory_proto_rawDesc = []byte{ 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, - 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x42, 0x0a, 0x0b, 0x63, - 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x20, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, - 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x61, 0x6c, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x12, - 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, 0x2e, 0x0a, 0x04, 0x73, - 0x75, 0x64, 0x6f, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6e, 0x71, 0x75, - 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, - 0x2e, 0x53, 0x75, 0x64, 0x6f, 0x52, 0x04, 0x73, 0x75, 0x64, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x72, - 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x16, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x72, 0x65, 0x63, - 0x6f, 0x72, 0x64, 0x12, 0x43, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x17, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3b, 0x0a, 0x08, 0x64, 0x69, 0x73, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x6e, 0x71, + 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x14, 0x70, 0x61, 0x72, 0x65, 0x6e, + 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, + 0x1e, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x12, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x42, 0x0a, + 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x0b, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x61, 0x6c, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, + 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, 0x2e, 0x0a, + 0x04, 0x73, 0x75, 0x64, 0x6f, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6e, + 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, + 0x76, 0x31, 0x2e, 0x53, 0x75, 0x64, 0x6f, 0x52, 0x04, 0x73, 0x75, 0x64, 0x6f, 0x12, 0x16, 0x0a, + 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x16, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x72, + 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x43, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0x17, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3b, 0x0a, 0x08, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, + 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, + 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x52, 0x08, 0x64, + 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x19, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, + 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x5f, 0x69, 0x64, + 0x18, 0x1a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, + 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, + 0x65, 0x73, 0x18, 0x1d, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, + 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x4a, 0x04, + 0x08, 0x09, 0x10, 0x0a, 0x4a, 0x04, 0x08, 0x0a, 0x10, 0x0b, 0x4a, 0x04, 0x08, 0x14, 0x10, 0x15, + 0x22, 0x68, 0x0a, 0x04, 0x53, 0x75, 0x64, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, + 0x76, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x75, 0x73, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, + 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x22, 0xa5, 0x01, 0x0a, 0x09, 0x44, + 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x74, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x73, 0x12, 0x43, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, + 0x65, 0x72, 0x79, 0x2e, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x74, 0x65, + 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x22, 0x94, 0x03, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x72, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x61, 0x72, 0x63, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x66, + 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x55, 0x0a, 0x12, 0x64, 0x65, 0x70, + 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x76, 0x38, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, + 0x14, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, + 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, + 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x56, 0x38, 0x5f, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x10, + 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x56, 0x38, 0x4b, 0x69, 0x6e, 0x64, + 0x12, 0x18, 0x0a, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x15, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x42, 0x0a, 0x06, 0x6c, 0x61, + 0x62, 0x65, 0x6c, 0x73, 0x18, 0x16, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6e, 0x71, + 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, + 0x31, 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x1a, 0x39, + 0x0a, 0x0b, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3e, 0x0a, 0x08, 0x54, 0x79, 0x70, + 0x65, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x70, 0x69, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, + 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xa4, 0x03, 0x0a, 0x0a, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x06, 0x6c, 0x61, + 0x62, 0x65, 0x6c, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, - 0x31, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x52, 0x08, 0x64, 0x69, 0x73, - 0x63, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, - 0x18, 0x19, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, - 0x1f, 0x0a, 0x0b, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x1a, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x49, 0x64, - 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, - 0x18, 0x1d, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, - 0x74, 0x69, 0x65, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, + 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x2e, 0x4c, 0x61, 0x62, + 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, + 0x12, 0x53, 0x0a, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, + 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x4e, 0x0a, 0x0f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x52, 0x65, + 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, + 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, + 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x4a, 0x04, 0x08, 0x09, - 0x10, 0x0a, 0x4a, 0x04, 0x08, 0x0a, 0x10, 0x0b, 0x4a, 0x04, 0x08, 0x14, 0x10, 0x15, 0x22, 0x68, - 0x0a, 0x04, 0x53, 0x75, 0x64, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x73, - 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, 0x65, 0x63, - 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, - 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x22, 0xa5, 0x01, 0x0a, 0x09, 0x44, 0x69, 0x73, - 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, - 0x12, 0x43, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x2b, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, - 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, - 0x79, 0x2e, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x66, - 0x69, 0x6c, 0x74, 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x45, + 0x1a, 0x3e, 0x0a, 0x10, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x22, 0x94, 0x03, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x72, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x61, 0x72, 0x63, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, - 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x66, 0x61, 0x6d, - 0x69, 0x6c, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x55, 0x0a, 0x12, 0x64, 0x65, 0x70, 0x72, 0x65, - 0x63, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x76, 0x38, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x14, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, 0x72, 0x65, - 0x63, 0x61, 0x74, 0x65, 0x64, 0x56, 0x38, 0x5f, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x10, 0x64, 0x65, - 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x56, 0x38, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x18, - 0x0a, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x42, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, - 0x6c, 0x73, 0x18, 0x16, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, - 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, - 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x1a, 0x39, 0x0a, 0x0b, - 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3e, 0x0a, 0x08, 0x54, 0x79, 0x70, 0x65, 0x4d, - 0x65, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x70, 0x69, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, 0x69, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xa4, 0x03, 0x0a, 0x0a, 0x4f, 0x62, 0x6a, 0x65, - 0x63, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, - 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, - 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, - 0x6c, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, - 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, - 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x53, - 0x0a, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0c, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x4d, 0x65, 0x74, 0x61, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x12, 0x4e, 0x0a, 0x0f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x66, 0x65, - 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, - 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, - 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, - 0x63, 0x65, 0x52, 0x0f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, - 0x63, 0x65, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3e, - 0x0a, 0x10, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x36, - 0x0a, 0x04, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, - 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x22, 0x6a, 0x0a, 0x0e, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x52, - 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x70, 0x69, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, - 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, - 0x69, 0x64, 0x22, 0xc1, 0x01, 0x0a, 0x09, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, - 0x12, 0x3c, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x4d, 0x65, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x37, - 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, - 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, - 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x70, 0x65, - 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x12, 0x3d, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, - 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, - 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0xd3, 0x03, 0x0a, 0x0d, 0x49, 0x6e, 0x76, 0x65, 0x6e, - 0x74, 0x6f, 0x72, 0x79, 0x53, 0x70, 0x65, 0x63, 0x12, 0x33, 0x0a, 0x06, 0x61, 0x73, 0x73, 0x65, - 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, - 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, - 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x06, 0x61, 0x73, 0x73, 0x65, 0x74, 0x73, 0x12, 0x56, 0x0a, - 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, - 0x6f, 0x72, 0x79, 0x53, 0x70, 0x65, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, - 0x74, 0x69, 0x61, 0x6c, 0x73, 0x12, 0x3e, 0x0a, 0x05, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x75, 0x6c, - 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x05, - 0x76, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, - 0x69, 0x61, 0x6c, 0x5f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0f, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x12, 0x68, 0x0a, 0x14, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5f, 0x63, 0x72, 0x65, - 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, - 0x2e, 0x6d, 0x6f, 0x6e, 0x64, 0x6f, 0x6f, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, - 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, - 0x74, 0x69, 0x61, 0x6c, 0x73, 0x52, 0x13, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, - 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x1a, 0x60, 0x0a, 0x10, 0x43, 0x72, - 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x36, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x20, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, - 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, - 0x6c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x11, 0x0a, 0x0f, - 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, - 0xec, 0x01, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, - 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, - 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x01, 0x12, 0x11, 0x0a, - 0x0d, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x02, - 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x52, 0x55, 0x4e, 0x4e, 0x49, 0x4e, - 0x47, 0x10, 0x03, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x4f, - 0x50, 0x50, 0x49, 0x4e, 0x47, 0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, 0x45, - 0x5f, 0x53, 0x54, 0x4f, 0x50, 0x50, 0x45, 0x44, 0x10, 0x05, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x54, - 0x41, 0x54, 0x45, 0x5f, 0x53, 0x48, 0x55, 0x54, 0x44, 0x4f, 0x57, 0x4e, 0x10, 0x06, 0x12, 0x14, - 0x0a, 0x10, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x54, 0x45, 0x52, 0x4d, 0x49, 0x4e, 0x41, 0x54, - 0x45, 0x44, 0x10, 0x07, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x52, 0x45, - 0x42, 0x4f, 0x4f, 0x54, 0x10, 0x08, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, - 0x4f, 0x4e, 0x4c, 0x49, 0x4e, 0x45, 0x10, 0x09, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, - 0x45, 0x5f, 0x4f, 0x46, 0x46, 0x4c, 0x49, 0x4e, 0x45, 0x10, 0x0a, 0x12, 0x11, 0x0a, 0x0d, 0x53, - 0x54, 0x41, 0x54, 0x45, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x0b, 0x2a, 0x3a, - 0x0a, 0x0d, 0x41, 0x73, 0x73, 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, - 0x16, 0x0a, 0x12, 0x43, 0x41, 0x54, 0x45, 0x47, 0x4f, 0x52, 0x59, 0x5f, 0x49, 0x4e, 0x56, 0x45, - 0x4e, 0x54, 0x4f, 0x52, 0x59, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x41, 0x54, 0x45, 0x47, - 0x4f, 0x52, 0x59, 0x5f, 0x43, 0x49, 0x43, 0x44, 0x10, 0x01, 0x2a, 0x85, 0x04, 0x0a, 0x0c, 0x50, - 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x4c, - 0x4f, 0x43, 0x41, 0x4c, 0x5f, 0x4f, 0x53, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x44, 0x4f, 0x43, - 0x4b, 0x45, 0x52, 0x5f, 0x45, 0x4e, 0x47, 0x49, 0x4e, 0x45, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, - 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x44, 0x4f, 0x43, 0x4b, 0x45, 0x52, 0x5f, 0x45, 0x4e, 0x47, - 0x49, 0x4e, 0x45, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x10, 0x02, 0x12, - 0x07, 0x0a, 0x03, 0x53, 0x53, 0x48, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x57, 0x49, 0x4e, 0x52, - 0x4d, 0x10, 0x04, 0x12, 0x17, 0x0a, 0x13, 0x41, 0x57, 0x53, 0x5f, 0x53, 0x53, 0x4d, 0x5f, 0x52, - 0x55, 0x4e, 0x5f, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x10, 0x05, 0x12, 0x16, 0x0a, 0x12, - 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, - 0x52, 0x59, 0x10, 0x06, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x41, 0x52, 0x10, 0x07, 0x12, 0x08, 0x0a, - 0x04, 0x4d, 0x4f, 0x43, 0x4b, 0x10, 0x08, 0x12, 0x0b, 0x0a, 0x07, 0x56, 0x53, 0x50, 0x48, 0x45, - 0x52, 0x45, 0x10, 0x09, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x52, 0x49, 0x53, 0x54, 0x41, 0x45, 0x4f, - 0x53, 0x10, 0x0a, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x57, 0x53, 0x10, 0x0c, 0x12, 0x07, 0x0a, 0x03, - 0x47, 0x43, 0x50, 0x10, 0x0d, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x5a, 0x55, 0x52, 0x45, 0x10, 0x0e, - 0x12, 0x09, 0x0a, 0x05, 0x4d, 0x53, 0x33, 0x36, 0x35, 0x10, 0x0f, 0x12, 0x08, 0x0a, 0x04, 0x49, - 0x50, 0x4d, 0x49, 0x10, 0x10, 0x12, 0x0e, 0x0a, 0x0a, 0x56, 0x53, 0x50, 0x48, 0x45, 0x52, 0x45, - 0x5f, 0x56, 0x4d, 0x10, 0x11, 0x12, 0x06, 0x0a, 0x02, 0x46, 0x53, 0x10, 0x12, 0x12, 0x07, 0x0a, - 0x03, 0x4b, 0x38, 0x53, 0x10, 0x13, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x51, 0x55, 0x49, 0x4e, 0x49, - 0x58, 0x5f, 0x4d, 0x45, 0x54, 0x41, 0x4c, 0x10, 0x14, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x4f, 0x43, - 0x4b, 0x45, 0x52, 0x10, 0x15, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x49, 0x54, 0x48, 0x55, 0x42, 0x10, - 0x16, 0x12, 0x0b, 0x0a, 0x07, 0x56, 0x41, 0x47, 0x52, 0x41, 0x4e, 0x54, 0x10, 0x17, 0x12, 0x0f, - 0x0a, 0x0b, 0x41, 0x57, 0x53, 0x5f, 0x45, 0x43, 0x32, 0x5f, 0x45, 0x42, 0x53, 0x10, 0x18, 0x12, - 0x0a, 0x0a, 0x06, 0x47, 0x49, 0x54, 0x4c, 0x41, 0x42, 0x10, 0x19, 0x12, 0x0d, 0x0a, 0x09, 0x54, - 0x45, 0x52, 0x52, 0x41, 0x46, 0x4f, 0x52, 0x4d, 0x10, 0x1a, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x4f, - 0x53, 0x54, 0x10, 0x1b, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, - 0x1c, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x4b, 0x54, 0x41, 0x10, 0x1d, 0x12, 0x14, 0x0a, 0x10, 0x47, - 0x4f, 0x4f, 0x47, 0x4c, 0x45, 0x5f, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x10, - 0x1e, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x4c, 0x41, 0x43, 0x4b, 0x10, 0x1f, 0x12, 0x07, 0x0a, 0x03, - 0x56, 0x43, 0x44, 0x10, 0x20, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x43, 0x49, 0x10, 0x21, 0x12, 0x09, - 0x0a, 0x05, 0x4f, 0x50, 0x43, 0x55, 0x41, 0x10, 0x22, 0x12, 0x21, 0x0a, 0x1d, 0x47, 0x43, 0x50, - 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x55, 0x54, 0x45, 0x5f, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4e, 0x43, - 0x45, 0x5f, 0x53, 0x4e, 0x41, 0x50, 0x53, 0x48, 0x4f, 0x54, 0x10, 0x23, 0x22, 0x04, 0x08, 0x0b, - 0x10, 0x0b, 0x2a, 0xcb, 0x02, 0x0a, 0x11, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, - 0x64, 0x56, 0x38, 0x5f, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x10, 0x0a, 0x0c, 0x4b, 0x49, 0x4e, 0x44, - 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x1e, 0x0a, 0x1a, 0x4b, 0x49, - 0x4e, 0x44, 0x5f, 0x56, 0x49, 0x52, 0x54, 0x55, 0x41, 0x4c, 0x5f, 0x4d, 0x41, 0x43, 0x48, 0x49, - 0x4e, 0x45, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x4b, 0x49, - 0x4e, 0x44, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x49, 0x4d, 0x41, - 0x47, 0x45, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x43, 0x4f, 0x44, - 0x45, 0x10, 0x03, 0x12, 0x10, 0x0a, 0x0c, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x50, 0x41, 0x43, 0x4b, - 0x41, 0x47, 0x45, 0x10, 0x04, 0x12, 0x18, 0x0a, 0x14, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x56, 0x49, - 0x52, 0x54, 0x55, 0x41, 0x4c, 0x5f, 0x4d, 0x41, 0x43, 0x48, 0x49, 0x4e, 0x45, 0x10, 0x05, 0x12, - 0x12, 0x0a, 0x0e, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, - 0x52, 0x10, 0x06, 0x12, 0x10, 0x0a, 0x0c, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x50, 0x52, 0x4f, 0x43, - 0x45, 0x53, 0x53, 0x10, 0x07, 0x12, 0x0c, 0x0a, 0x08, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x41, 0x50, - 0x49, 0x10, 0x08, 0x12, 0x13, 0x0a, 0x0f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x42, 0x41, 0x52, 0x45, - 0x5f, 0x4d, 0x45, 0x54, 0x41, 0x4c, 0x10, 0x09, 0x12, 0x10, 0x0a, 0x0c, 0x4b, 0x49, 0x4e, 0x44, - 0x5f, 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x10, 0x0a, 0x12, 0x13, 0x0a, 0x0f, 0x4b, 0x49, - 0x4e, 0x44, 0x5f, 0x4b, 0x38, 0x53, 0x5f, 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, 0x10, 0x0b, 0x12, - 0x13, 0x0a, 0x0f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x41, 0x57, 0x53, 0x5f, 0x4f, 0x42, 0x4a, 0x45, - 0x43, 0x54, 0x10, 0x0c, 0x12, 0x13, 0x0a, 0x0f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x47, 0x43, 0x50, - 0x5f, 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, 0x10, 0x0d, 0x12, 0x15, 0x0a, 0x11, 0x4b, 0x49, 0x4e, - 0x44, 0x5f, 0x41, 0x5a, 0x55, 0x52, 0x45, 0x5f, 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, 0x10, 0x0e, - 0x42, 0x36, 0x5a, 0x34, 0x67, 0x6f, 0x2e, 0x6d, 0x6f, 0x6e, 0x64, 0x6f, 0x6f, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x30, 0x2f, 0x70, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x69, - 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x36, 0x0a, 0x04, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x63, 0x6f, + 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, + 0x64, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x22, 0x6a, 0x0a, 0x0e, 0x4f, 0x77, 0x6e, 0x65, + 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x70, + 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x61, 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, + 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x75, 0x69, 0x64, 0x22, 0xc1, 0x01, 0x0a, 0x09, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, + 0x72, 0x79, 0x12, 0x3c, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x12, 0x37, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, + 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, + 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x53, + 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x12, 0x3d, 0x0a, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x63, 0x6e, 0x71, 0x75, + 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, + 0x2e, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0xd3, 0x03, 0x0a, 0x0d, 0x49, 0x6e, 0x76, + 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x70, 0x65, 0x63, 0x12, 0x33, 0x0a, 0x06, 0x61, 0x73, + 0x73, 0x65, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6e, 0x71, + 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, + 0x31, 0x2e, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x06, 0x61, 0x73, 0x73, 0x65, 0x74, 0x73, 0x12, + 0x56, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x76, 0x65, + 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x70, 0x65, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x12, 0x3e, 0x0a, 0x05, 0x76, 0x61, 0x75, 0x6c, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, + 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x05, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x63, 0x72, 0x65, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0f, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x12, 0x68, 0x0a, 0x14, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5f, 0x63, + 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x35, 0x2e, 0x6d, 0x6f, 0x6e, 0x64, 0x6f, 0x6f, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, + 0x79, 0x2e, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x43, 0x72, 0x65, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x52, 0x13, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x1a, 0x60, 0x0a, 0x10, + 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x36, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x61, 0x6c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x11, + 0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x2a, 0xec, 0x01, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x11, 0x0a, 0x0d, 0x53, + 0x54, 0x41, 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0f, + 0x0a, 0x0b, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x01, 0x12, + 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, + 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x52, 0x55, 0x4e, 0x4e, + 0x49, 0x4e, 0x47, 0x10, 0x03, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, + 0x54, 0x4f, 0x50, 0x50, 0x49, 0x4e, 0x47, 0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, + 0x54, 0x45, 0x5f, 0x53, 0x54, 0x4f, 0x50, 0x50, 0x45, 0x44, 0x10, 0x05, 0x12, 0x12, 0x0a, 0x0e, + 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, 0x48, 0x55, 0x54, 0x44, 0x4f, 0x57, 0x4e, 0x10, 0x06, + 0x12, 0x14, 0x0a, 0x10, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x54, 0x45, 0x52, 0x4d, 0x49, 0x4e, + 0x41, 0x54, 0x45, 0x44, 0x10, 0x07, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, + 0x52, 0x45, 0x42, 0x4f, 0x4f, 0x54, 0x10, 0x08, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x41, 0x54, + 0x45, 0x5f, 0x4f, 0x4e, 0x4c, 0x49, 0x4e, 0x45, 0x10, 0x09, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, + 0x41, 0x54, 0x45, 0x5f, 0x4f, 0x46, 0x46, 0x4c, 0x49, 0x4e, 0x45, 0x10, 0x0a, 0x12, 0x11, 0x0a, + 0x0d, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x0b, + 0x2a, 0x3a, 0x0a, 0x0d, 0x41, 0x73, 0x73, 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, + 0x79, 0x12, 0x16, 0x0a, 0x12, 0x43, 0x41, 0x54, 0x45, 0x47, 0x4f, 0x52, 0x59, 0x5f, 0x49, 0x4e, + 0x56, 0x45, 0x4e, 0x54, 0x4f, 0x52, 0x59, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x41, 0x54, + 0x45, 0x47, 0x4f, 0x52, 0x59, 0x5f, 0x43, 0x49, 0x43, 0x44, 0x10, 0x01, 0x2a, 0x85, 0x04, 0x0a, + 0x0c, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, + 0x08, 0x4c, 0x4f, 0x43, 0x41, 0x4c, 0x5f, 0x4f, 0x53, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x44, + 0x4f, 0x43, 0x4b, 0x45, 0x52, 0x5f, 0x45, 0x4e, 0x47, 0x49, 0x4e, 0x45, 0x5f, 0x49, 0x4d, 0x41, + 0x47, 0x45, 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x44, 0x4f, 0x43, 0x4b, 0x45, 0x52, 0x5f, 0x45, + 0x4e, 0x47, 0x49, 0x4e, 0x45, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x10, + 0x02, 0x12, 0x07, 0x0a, 0x03, 0x53, 0x53, 0x48, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x57, 0x49, + 0x4e, 0x52, 0x4d, 0x10, 0x04, 0x12, 0x17, 0x0a, 0x13, 0x41, 0x57, 0x53, 0x5f, 0x53, 0x53, 0x4d, + 0x5f, 0x52, 0x55, 0x4e, 0x5f, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x10, 0x05, 0x12, 0x16, + 0x0a, 0x12, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x52, 0x45, 0x47, 0x49, + 0x53, 0x54, 0x52, 0x59, 0x10, 0x06, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x41, 0x52, 0x10, 0x07, 0x12, + 0x08, 0x0a, 0x04, 0x4d, 0x4f, 0x43, 0x4b, 0x10, 0x08, 0x12, 0x0b, 0x0a, 0x07, 0x56, 0x53, 0x50, + 0x48, 0x45, 0x52, 0x45, 0x10, 0x09, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x52, 0x49, 0x53, 0x54, 0x41, + 0x45, 0x4f, 0x53, 0x10, 0x0a, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x57, 0x53, 0x10, 0x0c, 0x12, 0x07, + 0x0a, 0x03, 0x47, 0x43, 0x50, 0x10, 0x0d, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x5a, 0x55, 0x52, 0x45, + 0x10, 0x0e, 0x12, 0x09, 0x0a, 0x05, 0x4d, 0x53, 0x33, 0x36, 0x35, 0x10, 0x0f, 0x12, 0x08, 0x0a, + 0x04, 0x49, 0x50, 0x4d, 0x49, 0x10, 0x10, 0x12, 0x0e, 0x0a, 0x0a, 0x56, 0x53, 0x50, 0x48, 0x45, + 0x52, 0x45, 0x5f, 0x56, 0x4d, 0x10, 0x11, 0x12, 0x06, 0x0a, 0x02, 0x46, 0x53, 0x10, 0x12, 0x12, + 0x07, 0x0a, 0x03, 0x4b, 0x38, 0x53, 0x10, 0x13, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x51, 0x55, 0x49, + 0x4e, 0x49, 0x58, 0x5f, 0x4d, 0x45, 0x54, 0x41, 0x4c, 0x10, 0x14, 0x12, 0x0a, 0x0a, 0x06, 0x44, + 0x4f, 0x43, 0x4b, 0x45, 0x52, 0x10, 0x15, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x49, 0x54, 0x48, 0x55, + 0x42, 0x10, 0x16, 0x12, 0x0b, 0x0a, 0x07, 0x56, 0x41, 0x47, 0x52, 0x41, 0x4e, 0x54, 0x10, 0x17, + 0x12, 0x0f, 0x0a, 0x0b, 0x41, 0x57, 0x53, 0x5f, 0x45, 0x43, 0x32, 0x5f, 0x45, 0x42, 0x53, 0x10, + 0x18, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x49, 0x54, 0x4c, 0x41, 0x42, 0x10, 0x19, 0x12, 0x0d, 0x0a, + 0x09, 0x54, 0x45, 0x52, 0x52, 0x41, 0x46, 0x4f, 0x52, 0x4d, 0x10, 0x1a, 0x12, 0x08, 0x0a, 0x04, + 0x48, 0x4f, 0x53, 0x54, 0x10, 0x1b, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, + 0x4e, 0x10, 0x1c, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x4b, 0x54, 0x41, 0x10, 0x1d, 0x12, 0x14, 0x0a, + 0x10, 0x47, 0x4f, 0x4f, 0x47, 0x4c, 0x45, 0x5f, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, + 0x45, 0x10, 0x1e, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x4c, 0x41, 0x43, 0x4b, 0x10, 0x1f, 0x12, 0x07, + 0x0a, 0x03, 0x56, 0x43, 0x44, 0x10, 0x20, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x43, 0x49, 0x10, 0x21, + 0x12, 0x09, 0x0a, 0x05, 0x4f, 0x50, 0x43, 0x55, 0x41, 0x10, 0x22, 0x12, 0x21, 0x0a, 0x1d, 0x47, + 0x43, 0x50, 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x55, 0x54, 0x45, 0x5f, 0x49, 0x4e, 0x53, 0x54, 0x41, + 0x4e, 0x43, 0x45, 0x5f, 0x53, 0x4e, 0x41, 0x50, 0x53, 0x48, 0x4f, 0x54, 0x10, 0x23, 0x22, 0x04, + 0x08, 0x0b, 0x10, 0x0b, 0x2a, 0xcb, 0x02, 0x0a, 0x11, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, + 0x74, 0x65, 0x64, 0x56, 0x38, 0x5f, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x10, 0x0a, 0x0c, 0x4b, 0x49, + 0x4e, 0x44, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x1e, 0x0a, 0x1a, + 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x56, 0x49, 0x52, 0x54, 0x55, 0x41, 0x4c, 0x5f, 0x4d, 0x41, 0x43, + 0x48, 0x49, 0x4e, 0x45, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, + 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x49, + 0x4d, 0x41, 0x47, 0x45, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x43, + 0x4f, 0x44, 0x45, 0x10, 0x03, 0x12, 0x10, 0x0a, 0x0c, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x50, 0x41, + 0x43, 0x4b, 0x41, 0x47, 0x45, 0x10, 0x04, 0x12, 0x18, 0x0a, 0x14, 0x4b, 0x49, 0x4e, 0x44, 0x5f, + 0x56, 0x49, 0x52, 0x54, 0x55, 0x41, 0x4c, 0x5f, 0x4d, 0x41, 0x43, 0x48, 0x49, 0x4e, 0x45, 0x10, + 0x05, 0x12, 0x12, 0x0a, 0x0e, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, + 0x4e, 0x45, 0x52, 0x10, 0x06, 0x12, 0x10, 0x0a, 0x0c, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x50, 0x52, + 0x4f, 0x43, 0x45, 0x53, 0x53, 0x10, 0x07, 0x12, 0x0c, 0x0a, 0x08, 0x4b, 0x49, 0x4e, 0x44, 0x5f, + 0x41, 0x50, 0x49, 0x10, 0x08, 0x12, 0x13, 0x0a, 0x0f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x42, 0x41, + 0x52, 0x45, 0x5f, 0x4d, 0x45, 0x54, 0x41, 0x4c, 0x10, 0x09, 0x12, 0x10, 0x0a, 0x0c, 0x4b, 0x49, + 0x4e, 0x44, 0x5f, 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x10, 0x0a, 0x12, 0x13, 0x0a, 0x0f, + 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x4b, 0x38, 0x53, 0x5f, 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, 0x10, + 0x0b, 0x12, 0x13, 0x0a, 0x0f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x41, 0x57, 0x53, 0x5f, 0x4f, 0x42, + 0x4a, 0x45, 0x43, 0x54, 0x10, 0x0c, 0x12, 0x13, 0x0a, 0x0f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x47, + 0x43, 0x50, 0x5f, 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, 0x10, 0x0d, 0x12, 0x15, 0x0a, 0x11, 0x4b, + 0x49, 0x4e, 0x44, 0x5f, 0x41, 0x5a, 0x55, 0x52, 0x45, 0x5f, 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, + 0x10, 0x0e, 0x42, 0x36, 0x5a, 0x34, 0x67, 0x6f, 0x2e, 0x6d, 0x6f, 0x6e, 0x64, 0x6f, 0x6f, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x30, 0x2f, + 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x76, 0x31, + 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/providers-sdk/v1/inventory/inventory.proto b/providers-sdk/v1/inventory/inventory.proto index 815a9a59c9..05104c2c02 100644 --- a/providers-sdk/v1/inventory/inventory.proto +++ b/providers-sdk/v1/inventory/inventory.proto @@ -177,6 +177,7 @@ message Config { int32 port = 3; string path = 4; uint32 id = 5; + uint32 parent_connection_id = 30; string type = 12; // credentials available for this provider configuration diff --git a/providers-sdk/v1/plugin/connection.go b/providers-sdk/v1/plugin/connection.go new file mode 100644 index 0000000000..1d329590c2 --- /dev/null +++ b/providers-sdk/v1/plugin/connection.go @@ -0,0 +1,37 @@ +// Copyright (c) Mondoo, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package plugin + +import inventory "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + +type Connection interface { + ID() uint32 + + // ParentID returns the ID of the parent connection. If this returns >0, + // the connection with that ID will be used to store and get data. + ParentID() uint32 +} + +type connection struct { + id uint32 + parentId uint32 +} + +func NewConnection(id uint32, asset *inventory.Asset) Connection { + conn := &connection{ + id: id, + } + if len(asset.Connections) > 0 && asset.Connections[0].ParentConnectionId > 0 { + conn.parentId = asset.Connections[0].ParentConnectionId + } + return conn +} + +func (c *connection) ID() uint32 { + return c.id +} + +func (c *connection) ParentID() uint32 { + return c.parentId +} diff --git a/providers-sdk/v1/plugin/connection_test.go b/providers-sdk/v1/plugin/connection_test.go new file mode 100644 index 0000000000..8fb7827c44 --- /dev/null +++ b/providers-sdk/v1/plugin/connection_test.go @@ -0,0 +1,48 @@ +// Copyright (c) Mondoo, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package plugin + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + inventory "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" +) + +func TestConnection_ID(t *testing.T) { + c := NewConnection(1, &inventory.Asset{}) + require.NotNil(t, c) + assert.Equal(t, uint32(1), c.ID()) +} + +func TestConnection_ParentID_Nil(t *testing.T) { + c := NewConnection(1, &inventory.Asset{}) + require.NotNil(t, c) + assert.Equal(t, uint32(0), c.ParentID()) +} + +func TestConnection_ParentID(t *testing.T) { + c := NewConnection(1, &inventory.Asset{ + Connections: []*inventory.Config{ + { + ParentConnectionId: 2, + }, + }, + }) + require.NotNil(t, c) + assert.Equal(t, uint32(2), c.ParentID()) +} + +func TestConnection_ParentID_0(t *testing.T) { + c := NewConnection(1, &inventory.Asset{ + Connections: []*inventory.Config{ + { + ParentConnectionId: 0, + }, + }, + }) + require.NotNil(t, c) + assert.Equal(t, uint32(0), c.ParentID()) +} diff --git a/providers-sdk/v1/plugin/runtime.go b/providers-sdk/v1/plugin/runtime.go index e4b926a497..5369e61064 100644 --- a/providers-sdk/v1/plugin/runtime.go +++ b/providers-sdk/v1/plugin/runtime.go @@ -14,7 +14,7 @@ import ( type Runtime struct { Connection Connection - Resources syncx.Map[Resource] + Resources *syncx.Map[Resource] Callback ProviderCallback HasRecording bool CreateResource CreateNamedResource @@ -24,8 +24,27 @@ type Runtime struct { Upstream *upstream.UpstreamClient } -type Connection interface { - ID() uint32 +func NewRuntime( + conn Connection, + callback ProviderCallback, + hasRecording bool, + createResource CreateNamedResource, + newResource NewResource, + getData GetData, + setData SetData, + upstream *upstream.UpstreamClient, +) *Runtime { + return &Runtime{ + Connection: conn, + Resources: &syncx.Map[Resource]{}, + Callback: callback, + HasRecording: hasRecording, + CreateResource: createResource, + NewResource: newResource, + GetData: getData, + SetData: setData, + Upstream: upstream, + } } type ( diff --git a/providers-sdk/v1/plugin/service.go b/providers-sdk/v1/plugin/service.go index 96f02f176a..e983b3f135 100644 --- a/providers-sdk/v1/plugin/service.go +++ b/providers-sdk/v1/plugin/service.go @@ -42,6 +42,17 @@ func (s *Service) AddRuntime(createRuntime func(connId uint32) (*Runtime, error) s.lastConnectionID-- return nil, err } + + if runtime.Connection != nil { + if parentId := runtime.Connection.ParentID(); parentId > 0 { + parentRuntime, err := s.doGetRuntime(parentId) + if err != nil { + return nil, errors.New("parent connection " + strconv.FormatUint(uint64(parentId), 10) + " not found") + } + runtime.Resources = parentRuntime.Resources + + } + } s.runtimes[s.lastConnectionID] = runtime return runtime, nil } @@ -49,6 +60,12 @@ func (s *Service) AddRuntime(createRuntime func(connId uint32) (*Runtime, error) func (s *Service) GetRuntime(id uint32) (*Runtime, error) { s.runtimesLock.Lock() defer s.runtimesLock.Unlock() + return s.doGetRuntime(id) +} + +// doGetRuntime is a helper function to get a runtime by its ID. It MUST be called +// with a lock on s.runtimesLock. +func (s *Service) doGetRuntime(id uint32) (*Runtime, error) { if runtime, ok := s.runtimes[id]; ok { return runtime, nil } diff --git a/providers-sdk/v1/plugin/service_test.go b/providers-sdk/v1/plugin/service_test.go index 2129218aa2..12a06a4cae 100644 --- a/providers-sdk/v1/plugin/service_test.go +++ b/providers-sdk/v1/plugin/service_test.go @@ -9,10 +9,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/utils/syncx" ) type TestConnection struct { - id uint32 + id uint32 + parentId uint32 } func newTestConnection(id uint32) *TestConnection { @@ -23,6 +25,10 @@ func (c *TestConnection) ID() uint32 { return c.id } +func (c *TestConnection) ParentID() uint32 { + return c.parentId +} + type TestConnectionWithClose struct { *TestConnection closed bool @@ -36,6 +42,16 @@ func (c *TestConnectionWithClose) Close() { c.closed = true } +type TestResource struct{} + +func (r *TestResource) MqlID() string { + return "test.resource" +} + +func (r *TestResource) MqlName() string { + return "Test Resource" +} + func TestAddRuntime(t *testing.T) { s := NewService() wg := sync.WaitGroup{} @@ -63,6 +79,52 @@ func TestAddRuntime(t *testing.T) { assert.Equal(t, s.lastConnectionID, uint32(200)) } +func TestAddRuntime_ParentNotExist(t *testing.T) { + s := NewService() + parentId := uint32(10) + _, err := s.AddRuntime(func(connId uint32) (*Runtime, error) { + c := newTestConnection(connId) + c.parentId = parentId + return &Runtime{ + Connection: c, + }, nil + }) + require.Error(t, err) + assert.Equal(t, "parent connection 10 not found", err.Error()) +} + +func TestAddRuntime_Parent(t *testing.T) { + s := NewService() + + parent, err := s.AddRuntime(func(connId uint32) (*Runtime, error) { + resMap := &syncx.Map[Resource]{} + resMap.Set("test.resource", &TestResource{}) + + return &Runtime{ + Resources: resMap, + Connection: newTestConnection(connId), + }, nil + }) + require.NoError(t, err) + + parentId := parent.Connection.ID() + child, err := s.AddRuntime(func(connId uint32) (*Runtime, error) { + c := newTestConnection(connId) + c.parentId = parentId + return &Runtime{ + Connection: c, + }, nil + }) + require.NoError(t, err) + + // Check that the resources for the parent and the child are the same + assert.Equal(t, parent.Resources, child.Resources) + + // Add another resource and check that it appears in the child runtime + parent.Resources.Set("test.resource2", &TestResource{}) + assert.Equal(t, parent.Resources, child.Resources) +} + func TestGetRuntime(t *testing.T) { s := NewService() diff --git a/providers-sdk/v1/testutils/mockprovider/mockprovider.go b/providers-sdk/v1/testutils/mockprovider/mockprovider.go index e05af8030e..7a3724f444 100644 --- a/providers-sdk/v1/testutils/mockprovider/mockprovider.go +++ b/providers-sdk/v1/testutils/mockprovider/mockprovider.go @@ -11,6 +11,7 @@ import ( "go.mondoo.com/cnquery/v10/llx" "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/testutils/mockprovider/resources" + "go.mondoo.com/cnquery/v10/utils/syncx" ) var Config = plugin.Provider{ @@ -44,6 +45,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba s.lastConnectionID++ connID := s.lastConnectionID runtime := &plugin.Runtime{ + Resources: &syncx.Map[plugin.Resource]{}, Callback: callback, HasRecording: req.HasRecording, } diff --git a/providers/arista/connection/connection.go b/providers/arista/connection/connection.go index f3b38b6b8c..ee4ae2c23e 100644 --- a/providers/arista/connection/connection.go +++ b/providers/arista/connection/connection.go @@ -8,11 +8,12 @@ import ( "github.com/aristanetworks/goeapi" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" ) type AristaConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset // custom connection fields @@ -21,9 +22,9 @@ type AristaConnection struct { func NewAristaConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*AristaConnection, error) { conn := &AristaConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // initialize connection @@ -59,10 +60,6 @@ func (c *AristaConnection) Name() string { return "arista" } -func (c *AristaConnection) ID() uint32 { - return c.id -} - func (c *AristaConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/arista/provider/provider.go b/providers/arista/provider/provider.go index 4f6b109078..db1ba9aa4e 100644 --- a/providers/arista/provider/provider.go +++ b/providers/arista/provider/provider.go @@ -139,16 +139,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = connId - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/atlassian/connection/admin/connection.go b/providers/atlassian/connection/admin/connection.go index 018360858d..a3fa9be31f 100644 --- a/providers/atlassian/connection/admin/connection.go +++ b/providers/atlassian/connection/admin/connection.go @@ -10,6 +10,7 @@ import ( "github.com/ctreminiom/go-atlassian/admin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/atlassian/connection/shared" ) @@ -18,7 +19,7 @@ const ( ) type AdminConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset client *admin.Client @@ -45,29 +46,23 @@ func NewConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (* _, response, _ := client.Organization.Gets(context.Background(), "") if response != nil { if response.StatusCode == 401 { - return nil, errors.New("Failed to authenticate") + return nil, errors.New("failed to authenticate") } } - conn := &AdminConnection{ - Conf: conf, - id: id, - asset: asset, - client: client, - name: "admin.atlassian.com", - } - - return conn, nil + return &AdminConnection{ + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, + client: client, + name: "admin.atlassian.com", + }, nil } func (c *AdminConnection) Name() string { return c.name } -func (c *AdminConnection) ID() uint32 { - return c.id -} - func (c *AdminConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/atlassian/connection/confluence/connection.go b/providers/atlassian/connection/confluence/connection.go index 25eab96ac8..39af128850 100644 --- a/providers/atlassian/connection/confluence/connection.go +++ b/providers/atlassian/connection/confluence/connection.go @@ -10,6 +10,7 @@ import ( "github.com/ctreminiom/go-atlassian/confluence" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/atlassian/connection/shared" ) @@ -18,7 +19,7 @@ const ( ) type ConfluenceConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset client *confluence.Client @@ -59,31 +60,28 @@ func NewConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (* client.Auth.SetUserAgent("curl/7.54.0") _, response, err := client.Label.Get(context.Background(), "test", "page", 0, 50) + if err != nil { + return nil, err + } if response != nil { if response.StatusCode == 401 { - return nil, errors.New("Failed to authenticate") + return nil, errors.New("failed to authenticate") } } - conn := &ConfluenceConnection{ - Conf: conf, - id: id, - asset: asset, - client: client, - name: host, - } - - return conn, nil + return &ConfluenceConnection{ + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, + client: client, + name: host, + }, nil } func (c *ConfluenceConnection) Name() string { return c.name } -func (c *ConfluenceConnection) ID() uint32 { - return c.id -} - func (c *ConfluenceConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/atlassian/connection/jira/connection.go b/providers/atlassian/connection/jira/connection.go index 0dc40e0758..e0313cf8bc 100644 --- a/providers/atlassian/connection/jira/connection.go +++ b/providers/atlassian/connection/jira/connection.go @@ -10,6 +10,7 @@ import ( v2 "github.com/ctreminiom/go-atlassian/jira/v2" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/atlassian/connection/shared" ) @@ -18,7 +19,7 @@ const ( ) type JiraConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset client *v2.Client @@ -62,29 +63,23 @@ func NewConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (* _, response, _ := client.MySelf.Details(context.Background(), expand) if response != nil { if response.StatusCode == 401 { - return nil, errors.New("Failed to authenticate") + return nil, errors.New("failed to authenticate") } } - conn := &JiraConnection{ - Conf: conf, - id: id, - asset: asset, - client: client, - name: host, - } - - return conn, nil + return &JiraConnection{ + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, + client: client, + name: host, + }, nil } func (c *JiraConnection) Name() string { return c.name } -func (c *JiraConnection) ID() uint32 { - return c.id -} - func (c *JiraConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/atlassian/connection/scim/connection.go b/providers/atlassian/connection/scim/connection.go index bb6d1bfb4f..19121bdc1e 100644 --- a/providers/atlassian/connection/scim/connection.go +++ b/providers/atlassian/connection/scim/connection.go @@ -11,6 +11,7 @@ import ( "github.com/ctreminiom/go-atlassian/admin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/atlassian/connection/shared" ) @@ -19,7 +20,7 @@ const ( ) type ScimConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset client *admin.Client @@ -50,30 +51,25 @@ func NewConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (* _, response, _ := client.SCIM.Schema.User(context.Background(), conf.Options["directory-id"]) if response != nil { if response.StatusCode == 401 { - return nil, errors.New("Failed to authenticate") + return nil, errors.New("failed to authenticate") } } name := fmt.Sprintf("Directory %s", conf.Options["directory-id"]) - conn := &ScimConnection{ - Conf: conf, - id: id, - asset: asset, - client: client, - name: name, - } - return conn, nil + return &ScimConnection{ + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, + client: client, + name: name, + }, nil } func (c *ScimConnection) Name() string { return c.name } -func (c *ScimConnection) ID() uint32 { - return c.id -} - func (c *ScimConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/atlassian/connection/shared/shared.go b/providers/atlassian/connection/shared/shared.go index 874bfbe8d9..a4ec39b760 100644 --- a/providers/atlassian/connection/shared/shared.go +++ b/providers/atlassian/connection/shared/shared.go @@ -5,12 +5,13 @@ package shared import ( "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" ) type ConnectionType string type Connection interface { - ID() uint32 + plugin.Connection Name() string Type() ConnectionType Asset() *inventory.Asset diff --git a/providers/atlassian/provider/provider.go b/providers/atlassian/provider/provider.go index cd486c729e..a3be6d4e66 100644 --- a/providers/atlassian/provider/provider.go +++ b/providers/atlassian/provider/provider.go @@ -152,16 +152,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/aws/connection/awsec2ebsconn/provider.go b/providers/aws/connection/awsec2ebsconn/provider.go index 2090c4854c..f13534ded1 100644 --- a/providers/aws/connection/awsec2ebsconn/provider.go +++ b/providers/aws/connection/awsec2ebsconn/provider.go @@ -17,6 +17,7 @@ import ( "github.com/rs/zerolog/log" "github.com/spf13/afero" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/util/convert" awsec2ebstypes "go.mondoo.com/cnquery/v10/providers/aws/connection/awsec2ebsconn/types" "go.mondoo.com/cnquery/v10/providers/os/connection/fs" @@ -32,7 +33,7 @@ const ( ) type AwsEbsConnection struct { - id uint32 + plugin.Connection asset *inventory.Asset FsProvider *fs.FileSystemConnection scannerRegionEc2svc *ec2.Client @@ -80,8 +81,9 @@ func NewAwsEbsConnection(id uint32, conf *inventory.Config, asset *inventory.Ass // 2. create provider instance c := &AwsEbsConnection{ - config: cfg, - opts: conf.Options, + Connection: plugin.NewConnection(id, asset), + config: cfg, + opts: conf.Options, target: awsec2ebstypes.TargetInfo{ PlatformId: conf.PlatformId, Region: targetRegion, @@ -369,10 +371,6 @@ func (c *AwsEbsConnection) Name() string { return "aws ebs" } -func (c *AwsEbsConnection) ID() uint32 { - return c.id -} - func (c *AwsEbsConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/aws/connection/connection.go b/providers/aws/connection/connection.go index 9fbfae1277..4053ad8970 100644 --- a/providers/aws/connection/connection.go +++ b/providers/aws/connection/connection.go @@ -16,11 +16,12 @@ import ( "github.com/rs/zerolog/log" "github.com/spf13/afero" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/os/connection/shared" ) type AwsConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset cfg aws.Config @@ -63,8 +64,8 @@ type EcsDiscoveryFilters struct { func NewMockConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) *AwsConnection { return &AwsConnection{ - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + asset: asset, } } @@ -100,8 +101,8 @@ func NewAwsConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) } } + c.Connection = plugin.NewConnection(id, asset) c.Conf = conf - c.id = id c.asset = asset c.cfg = cfg c.accountId = *identity.Account @@ -231,10 +232,6 @@ func (h *AwsConnection) Name() string { return "aws" } -func (h *AwsConnection) ID() uint32 { - return h.id -} - func (p *AwsConnection) Asset() *inventory.Asset { return p.asset } diff --git a/providers/aws/provider/provider.go b/providers/aws/provider/provider.go index 94af458a8a..0679ab98c1 100644 --- a/providers/aws/provider/provider.go +++ b/providers/aws/provider/provider.go @@ -221,16 +221,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = connId - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/aws/resources/discovery_conversion.go b/providers/aws/resources/discovery_conversion.go index 6d3768850c..4de1fd99a1 100644 --- a/providers/aws/resources/discovery_conversion.go +++ b/providers/aws/resources/discovery_conversion.go @@ -66,18 +66,11 @@ func MqlObjectToAsset(account string, mqlObject mqlObject, conn *connection.AwsC Name: mqlObject.name, Platform: connection.GetPlatformForObject(platformName), Labels: mqlObject.labels, - Connections: []*inventory.Config{cloneInventoryConf(conn.Conf)}, + Connections: []*inventory.Config{t.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(t.Id))}, Options: conn.ConnectionOptions(), } } -func cloneInventoryConf(invConf *inventory.Config) *inventory.Config { - invConfClone := invConf.Clone() - // We do not want to run discovery again for the already discovered assets - invConfClone.Discover = &inventory.Discovery{} - return invConfClone -} - func validate(m mqlObject) error { if m.name == "" { return errors.New("name required for mql aws object to asset translation") diff --git a/providers/azure/connection/connection.go b/providers/azure/connection/connection.go index ded0ebbba5..4490362e06 100644 --- a/providers/azure/connection/connection.go +++ b/providers/azure/connection/connection.go @@ -8,6 +8,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/pkg/errors" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" "go.mondoo.com/cnquery/v10/providers/azure/connection/auth" "go.mondoo.com/cnquery/v10/providers/azure/connection/shared" @@ -22,7 +23,7 @@ const ( ) type AzureConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset token azcore.TokenCredential @@ -46,8 +47,8 @@ func NewAzureConnection(id uint32, asset *inventory.Asset, conf *inventory.Confi return nil, errors.Wrap(err, "cannot fetch credentials for microsoft provider") } return &AzureConnection{ + Connection: plugin.NewConnection(id, asset), Conf: conf, - id: id, asset: asset, token: token, subscriptionId: subId, @@ -58,10 +59,6 @@ func (h *AzureConnection) Name() string { return "azure" } -func (h *AzureConnection) ID() uint32 { - return h.id -} - func (p *AzureConnection) Asset() *inventory.Asset { return p.asset } diff --git a/providers/azure/connection/shared/shared.go b/providers/azure/connection/shared/shared.go index 0af57bd2e4..96526118b0 100644 --- a/providers/azure/connection/shared/shared.go +++ b/providers/azure/connection/shared/shared.go @@ -5,12 +5,13 @@ package shared import ( "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" ) type ConnectionType string type AzureConnection interface { - ID() uint32 + plugin.Connection Name() string Type() ConnectionType Config() *inventory.Config diff --git a/providers/azure/provider/provider.go b/providers/azure/provider/provider.go index 267852182f..c53becb3dd 100644 --- a/providers/azure/provider/provider.go +++ b/providers/azure/provider/provider.go @@ -203,16 +203,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/azure/resources/azure.lr.manifest.yaml b/providers/azure/resources/azure.lr.manifest.yaml index 2fd464fe09..48fe921c0f 100644 --- a/providers/azure/resources/azure.lr.manifest.yaml +++ b/providers/azure/resources/azure.lr.manifest.yaml @@ -10,8 +10,8 @@ resources: - azure azure.subscription: docs: - desc: "Use the `azure.subscription` resource to assess the configuration of - Azure subscriptions." + desc: Use the `azure.subscription` resource to assess the configuration of Azure + subscriptions. fields: advisor: {} aks: {} @@ -48,8 +48,8 @@ resources: title: Return the subscription ID and a list of tenants that manage the subscription azure.subscription.advisor: docs: - desc: "Use the `azure.subscription.advisor` resource to retrieve scoring - and recommendations from Microsoft Azure Advisor." + desc: Use the `azure.subscription.advisor` resource to retrieve scoring and + recommendations from Microsoft Azure Advisor. fields: recommendations: {} subscriptionId: {} @@ -62,7 +62,8 @@ resources: url: https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview snippets: - query: "azure.subscription.advisor {\n averageScore \n recommendations \n}\n" - title: Return the average score and all recommendations from Microsoft Azure Advisor + title: Return the average score and all recommendations from Microsoft Azure + Advisor - query: | azure.subscription.advisorService { averageScore > 90 @@ -79,8 +80,8 @@ resources: - azure azure.subscription.advisorService: docs: - desc: "Use the `azure.subscription.advisorService` resource to retrieve scoring - and recommendations from Microsoft Azure Advisor." + desc: Use the `azure.subscription.advisorService` resource to retrieve scoring + and recommendations from Microsoft Azure Advisor. fields: averageScore: {} recommendations: {} @@ -91,7 +92,6 @@ resources: platform: name: - azure - snippets: azure.subscription.advisorService.recommendation: fields: category: {} @@ -160,7 +160,8 @@ resources: - azure azure.subscription.aks.cluster: docs: - desc: "Use the `azure.subscription.aks.cluster` resource to retrieve and check properties for an Azure Kubernetes Service cluster." + desc: Use the `azure.subscription.aks.cluster` resource to retrieve and check + properties for an Azure Kubernetes Service cluster. fields: addonProfiles: {} agentPoolProfiles: {} diff --git a/providers/core/provider/provider.go b/providers/core/provider/provider.go index 22dd18ec96..42d78dde16 100644 --- a/providers/core/provider/provider.go +++ b/providers/core/provider/provider.go @@ -46,15 +46,15 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } } - return &plugin.Runtime{ - Callback: callback, - Upstream: upstream, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - }, nil + return plugin.NewRuntime( + nil, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/equinix/connection/connection.go b/providers/equinix/connection/connection.go index c8e0db8bc1..cbe1d08dd9 100644 --- a/providers/equinix/connection/connection.go +++ b/providers/equinix/connection/connection.go @@ -23,7 +23,7 @@ const ( ) type EquinixConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset // custom connection fields @@ -36,9 +36,9 @@ type EquinixConnection struct { func NewEquinixConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*EquinixConnection, error) { conn := &EquinixConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // if a secret was provided, it always overrides the env variable since it has precedence @@ -114,10 +114,6 @@ func (c *EquinixConnection) Name() string { return "equinix" } -func (c *EquinixConnection) ID() uint32 { - return c.id -} - func (c *EquinixConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/equinix/provider/provider.go b/providers/equinix/provider/provider.go index 513ce0f0c4..aedc608e13 100644 --- a/providers/equinix/provider/provider.go +++ b/providers/equinix/provider/provider.go @@ -123,16 +123,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/gcp/connection/connection.go b/providers/gcp/connection/connection.go index 4b9126e657..277fccf282 100644 --- a/providers/gcp/connection/connection.go +++ b/providers/gcp/connection/connection.go @@ -30,7 +30,7 @@ const ( ) type GcpConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset // custom connection fields @@ -44,9 +44,9 @@ type GcpConnection struct { func NewGcpConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*GcpConnection, error) { conn := &GcpConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // initialize connection @@ -118,10 +118,6 @@ func (c *GcpConnection) Name() string { return "gcp" } -func (c *GcpConnection) ID() uint32 { - return c.id -} - func (c *GcpConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/gcp/connection/shared/shared.go b/providers/gcp/connection/shared/shared.go index 528b5dc9c6..47e99796bc 100644 --- a/providers/gcp/connection/shared/shared.go +++ b/providers/gcp/connection/shared/shared.go @@ -5,12 +5,13 @@ package shared import ( "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" ) type ConnectionType string type GcpConnection interface { - ID() uint32 + plugin.Connection Name() string Type() ConnectionType Config() *inventory.Config diff --git a/providers/gcp/provider/provider.go b/providers/gcp/provider/provider.go index 2e5f784d74..10a63f71ab 100644 --- a/providers/gcp/provider/provider.go +++ b/providers/gcp/provider/provider.go @@ -236,16 +236,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/gcp/resources/discovery.go b/providers/gcp/resources/discovery.go index bfcc34d7f6..48852a2edc 100644 --- a/providers/gcp/resources/discovery.go +++ b/providers/gcp/resources/discovery.go @@ -78,7 +78,7 @@ func Discover(runtime *plugin.Runtime) (*inventory.Inventory, error) { Family: []string{"google"}, }, Labels: map[string]string{}, - Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery())}, + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.Conf.Id))}, }) } @@ -126,7 +126,7 @@ func discoverOrganization(conn *connection.GcpConnection, gcpOrg *mqlGcpOrganiza for i := range projectList.Data { project := projectList.Data[i].(*mqlGcpProject) - projectConf := conn.Conf.Clone() + projectConf := conn.Conf.Clone(inventory.WithParentConnectionId(conn.Conf.Id)) if projectConf.Options == nil { projectConf.Options = map[string]string{} } @@ -198,7 +198,7 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject) }, Labels: labels, // TODO: the current connection handling does not work well for instances - Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.Conf.Id))}, // pass-in the parent connection config }) } } @@ -231,7 +231,7 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject) Family: []string{"google"}, }, Labels: labels, - Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.Conf.Id))}, // pass-in the parent connection config }) } } @@ -259,7 +259,7 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject) Family: []string{"google"}, }, Labels: map[string]string{}, - Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.Conf.Id))}, // pass-in the parent connection config }) } } @@ -291,7 +291,7 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject) Family: []string{"google"}, }, Labels: map[string]string{}, - Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.Conf.Id))}, // pass-in the parent connection config }) } } @@ -319,7 +319,7 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject) Family: []string{"google"}, }, Labels: map[string]string{}, - Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.Conf.Id))}, // pass-in the parent connection config }) } } @@ -347,7 +347,7 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject) Family: []string{"google"}, }, Labels: map[string]string{}, - Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.Conf.Id))}, // pass-in the parent connection config }) } } @@ -375,7 +375,7 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject) Family: []string{"google"}, }, Labels: map[string]string{}, - Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.Conf.Id))}, // pass-in the parent connection config }) } } @@ -403,7 +403,7 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject) Family: []string{"google"}, }, Labels: map[string]string{}, - Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.Conf.Id))}, // pass-in the parent connection config }) } } diff --git a/providers/github/connection/connection.go b/providers/github/connection/connection.go index 262f5726c8..91606c5c6a 100644 --- a/providers/github/connection/connection.go +++ b/providers/github/connection/connection.go @@ -12,12 +12,13 @@ import ( "github.com/google/go-github/v57/github" "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" "golang.org/x/oauth2" ) type GithubConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset client *github.Client @@ -65,24 +66,18 @@ func NewGithubConnection(id uint32, asset *inventory.Asset, conf *inventory.Conf } return nil, err } - conn := &GithubConnection{ - Conf: conf, - id: id, - asset: asset, - client: client, - } - - return conn, nil + return &GithubConnection{ + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, + client: client, + }, nil } func (c *GithubConnection) Name() string { return "github" } -func (c *GithubConnection) ID() uint32 { - return c.id -} - func (c *GithubConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/github/provider/provider.go b/providers/github/provider/provider.go index 6dfa3078c6..0d71304965 100644 --- a/providers/github/provider/provider.go +++ b/providers/github/provider/provider.go @@ -144,16 +144,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/gitlab/connection/connection.go b/providers/gitlab/connection/connection.go index 3e3edadf71..c3432c0bfd 100644 --- a/providers/gitlab/connection/connection.go +++ b/providers/gitlab/connection/connection.go @@ -13,11 +13,12 @@ import ( "github.com/rs/zerolog/log" "github.com/xanzy/go-gitlab" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" ) type GitLabConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset group *gitlab.Group @@ -66,9 +67,9 @@ func NewGitLabConnection(id uint32, asset *inventory.Asset, conf *inventory.Conf return nil, err } - conn := &GitLabConnection{ + return &GitLabConnection{ + Connection: plugin.NewConnection(id, asset), Conf: conf, - id: id, asset: asset, groupName: conf.Options["group"], groupID: conf.Options["group-id"], @@ -76,19 +77,13 @@ func NewGitLabConnection(id uint32, asset *inventory.Asset, conf *inventory.Conf projectID: conf.Options["project-id"], url: conf.Options["url"], client: client, - } - - return conn, nil + }, nil } func (c *GitLabConnection) Name() string { return "gitlab" } -func (c *GitLabConnection) ID() uint32 { - return c.id -} - func (c *GitLabConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/gitlab/provider/provider.go b/providers/gitlab/provider/provider.go index 75930f81a5..5a0af7a25b 100644 --- a/providers/gitlab/provider/provider.go +++ b/providers/gitlab/provider/provider.go @@ -156,16 +156,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = connId - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/google-workspace/connection/connection.go b/providers/google-workspace/connection/connection.go index 9fef896341..9f67ea124b 100644 --- a/providers/google-workspace/connection/connection.go +++ b/providers/google-workspace/connection/connection.go @@ -8,11 +8,12 @@ import ( "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" ) type GoogleWorkspaceConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset // Add custom connection fields here @@ -23,9 +24,9 @@ type GoogleWorkspaceConnection struct { func NewGoogleWorkspaceConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*GoogleWorkspaceConnection, error) { conn := &GoogleWorkspaceConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } if len(conf.Credentials) != 0 { @@ -53,10 +54,6 @@ func (c *GoogleWorkspaceConnection) Name() string { return "google-workspace" } -func (c *GoogleWorkspaceConnection) ID() uint32 { - return c.id -} - func (c *GoogleWorkspaceConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/google-workspace/provider/provider.go b/providers/google-workspace/provider/provider.go index 3ddc3a8ea0..b481949b92 100644 --- a/providers/google-workspace/provider/provider.go +++ b/providers/google-workspace/provider/provider.go @@ -174,16 +174,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = connId - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/ipmi/connection/connection.go b/providers/ipmi/connection/connection.go index 8d699ab57b..a7a42ba242 100644 --- a/providers/ipmi/connection/connection.go +++ b/providers/ipmi/connection/connection.go @@ -8,12 +8,13 @@ import ( "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" impi_client "go.mondoo.com/cnquery/v10/providers/ipmi/connection/client" ) type IpmiConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset // custom connection fields @@ -23,9 +24,9 @@ type IpmiConnection struct { func NewIpmiConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*IpmiConnection, error) { conn := &IpmiConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // initialize connection @@ -68,10 +69,6 @@ func (c *IpmiConnection) Name() string { return "ipmi" } -func (c *IpmiConnection) ID() uint32 { - return c.id -} - func (c *IpmiConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/ipmi/provider/provider.go b/providers/ipmi/provider/provider.go index 0bf0bd7b6a..fd7e759f7a 100644 --- a/providers/ipmi/provider/provider.go +++ b/providers/ipmi/provider/provider.go @@ -133,16 +133,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/k8s/connection/admission/connection.go b/providers/k8s/connection/admission/connection.go index 1a16f03907..cc53603d95 100644 --- a/providers/k8s/connection/admission/connection.go +++ b/providers/k8s/connection/admission/connection.go @@ -10,6 +10,7 @@ import ( "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/k8s/connection/shared" "go.mondoo.com/cnquery/v10/providers/k8s/connection/shared/resources" admission "k8s.io/api/admission/v1" @@ -18,17 +19,16 @@ import ( type Connection struct { shared.ManifestParser - id uint32 + plugin.Connection asset *inventory.Asset namespace string } -// func newManifestProvider(selectedResourceID string, objectKind string, opts ...Option) (KubernetesProvider, error) { func NewConnection(id uint32, asset *inventory.Asset, data string) (shared.Connection, error) { c := &Connection{ - id: id, - asset: asset, - namespace: asset.Connections[0].Options[shared.OPTION_NAMESPACE], + Connection: plugin.NewConnection(id, asset), + asset: asset, + namespace: asset.Connections[0].Options[shared.OPTION_NAMESPACE], } admission, err := base64.StdEncoding.DecodeString(data) @@ -67,10 +67,6 @@ func (c *Connection) SupportedResourceTypes() (*resources.ApiResourceIndex, erro return c.ManifestParser.SupportedResourceTypes() } -func (c *Connection) ID() uint32 { - return c.id -} - func (c *Connection) Runtime() string { return "k8s-admission" } diff --git a/providers/k8s/connection/api/connection.go b/providers/k8s/connection/api/connection.go index 8936e9297b..f389a415ce 100644 --- a/providers/k8s/connection/api/connection.go +++ b/providers/k8s/connection/api/connection.go @@ -12,6 +12,7 @@ import ( "github.com/pkg/errors" "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/k8s/connection/shared" "go.mondoo.com/cnquery/v10/providers/k8s/connection/shared/resources" admissionv1 "k8s.io/api/admission/v1" @@ -27,7 +28,7 @@ import ( ) type Connection struct { - id uint32 + plugin.Connection asset *inventory.Asset d *resources.Discovery config *rest.Config @@ -99,7 +100,7 @@ func NewConnection(id uint32, asset *inventory.Asset, discoveryCache *resources. } res := Connection{ - id: id, + Connection: plugin.NewConnection(id, asset), asset: asset, d: d, config: config, @@ -125,14 +126,6 @@ func buildConfigFromFlags(masterUrl, kubeconfigPath string, context string) (*re &clientcmd.ConfigOverrides{ClusterInfo: clientcmdapi.Cluster{Server: masterUrl}, CurrentContext: context}).ClientConfig() } -func (c *Connection) SetID(id uint32) { - c.id = id -} - -func (c *Connection) ID() uint32 { - return c.id -} - func (c *Connection) Runtime() string { return "k8s-cluster" } diff --git a/providers/k8s/connection/manifest/connection.go b/providers/k8s/connection/manifest/connection.go index e9dce2dc7b..c905060f00 100644 --- a/providers/k8s/connection/manifest/connection.go +++ b/providers/k8s/connection/manifest/connection.go @@ -11,6 +11,7 @@ import ( "github.com/pkg/errors" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/k8s/connection/shared" "go.mondoo.com/cnquery/v10/providers/k8s/connection/shared/resources" admissionv1 "k8s.io/api/admission/v1" @@ -40,7 +41,7 @@ func WithManifestContent(data []byte) Option { type Connection struct { shared.ManifestParser - id uint32 + plugin.Connection asset *inventory.Asset namespace string @@ -48,12 +49,11 @@ type Connection struct { manifestContent []byte } -// func newManifestProvider(selectedResourceID string, objectKind string, opts ...Option) (KubernetesProvider, error) { func NewConnection(id uint32, asset *inventory.Asset, opts ...Option) (shared.Connection, error) { c := &Connection{ - id: id, - asset: asset, - namespace: asset.Connections[0].Options[shared.OPTION_NAMESPACE], + Connection: plugin.NewConnection(id, asset), + asset: asset, + namespace: asset.Connections[0].Options[shared.OPTION_NAMESPACE], } for _, option := range opts { @@ -98,10 +98,6 @@ func (c *Connection) SupportedResourceTypes() (*resources.ApiResourceIndex, erro return c.ManifestParser.SupportedResourceTypes() } -func (c *Connection) ID() uint32 { - return c.id -} - func (c *Connection) Name() string { return c.asset.Name } diff --git a/providers/k8s/connection/shared/connection.go b/providers/k8s/connection/shared/connection.go index 6f0e705ebc..fb074d5607 100644 --- a/providers/k8s/connection/shared/connection.go +++ b/providers/k8s/connection/shared/connection.go @@ -31,7 +31,6 @@ type ConnectionType string type Connection interface { plugin.Connection - ID() uint32 Name() string Runtime() string diff --git a/providers/k8s/connection/shared/resources/discovery.go b/providers/k8s/connection/shared/resources/discovery.go index 7751ef7f27..49e5b9efab 100644 --- a/providers/k8s/connection/shared/resources/discovery.go +++ b/providers/k8s/connection/shared/resources/discovery.go @@ -5,13 +5,11 @@ package resources import ( "context" - "fmt" "io" "os" "sync" "time" - "github.com/kofalt/go-memoize" "github.com/pkg/errors" "github.com/rs/zerolog/log" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -62,7 +60,6 @@ func NewDiscovery(restConfig *rest.Config) (*Discovery, error) { discoveryClient: cachedClient, dynClient: dynClient, ServerVersion: serverVersion, - memoizer: memoize.NewMemoizer(30*time.Minute, time.Hour), }, nil } @@ -70,7 +67,6 @@ type Discovery struct { dynClient dynamic.Interface discoveryClient discovery.CachedDiscoveryInterface ServerVersion *version.Info - memoizer *memoize.Memoizer } func (d *Discovery) SupportedResourceTypes() (*ApiResourceIndex, error) { @@ -118,43 +114,36 @@ func (d *Discovery) GetAllResources(ctx context.Context, resTypes *ApiResourceIn } func (d *Discovery) GetKindResources(ctx context.Context, apiRes ApiResource, ns string, allNs bool) ([]runtime.Object, error) { - res, err, _ := d.memoizer.Memoize(fmt.Sprintf("GetKindResources/%s/%s/%v", apiRes.FullApiName(), ns, allNs), func() (interface{}, error) { - var out []runtime.Object - - var next string - for { - var intf dynamic.ResourceInterface - nintf := d.dynClient.Resource(apiRes.GroupVersionResource()) - log.Debug().Msgf("query resources for %s (namespaced: %t)", apiRes.Resource.Name, apiRes.Resource.Namespaced) - if apiRes.Resource.Namespaced && !allNs { - intf = nintf.Namespace(ns) - } else { - intf = nintf - } - resp, err := intf.List(ctx, metav1.ListOptions{ - Limit: 250, - Continue: next, - }) - // this error will happen when users have no permission - if err != nil { - log.Debug().Err(err).Msgf("could not fetch resources for: %v", apiRes.GroupVersionResource()) - break - } + var out []runtime.Object + + var next string + for { + var intf dynamic.ResourceInterface + nintf := d.dynClient.Resource(apiRes.GroupVersionResource()) + log.Debug().Msgf("query resources for %s (namespaced: %t)", apiRes.Resource.Name, apiRes.Resource.Namespaced) + if apiRes.Resource.Namespaced && !allNs { + intf = nintf.Namespace(ns) + } else { + intf = nintf + } + resp, err := intf.List(ctx, metav1.ListOptions{ + Limit: 250, + Continue: next, + }) + // this error will happen when users have no permission + if err != nil { + log.Debug().Err(err).Msgf("could not fetch resources for: %v", apiRes.GroupVersionResource()) + break + } - out = append(out, UnstructuredListToObjectList(resp.Items)...) + out = append(out, UnstructuredListToObjectList(resp.Items)...) - next = resp.GetContinue() - if next == "" { - break - } + next = resp.GetContinue() + if next == "" { + break } - return out, nil - }) - if err != nil { - return nil, err } - - return res.([]runtime.Object), nil + return out, nil } func contains(v []string, s string) bool { diff --git a/providers/k8s/go.mod b/providers/k8s/go.mod index 345c0ead06..a05b25c205 100644 --- a/providers/k8s/go.mod +++ b/providers/k8s/go.mod @@ -10,7 +10,6 @@ require ( github.com/cockroachdb/errors v1.11.1 github.com/gobwas/glob v0.2.3 github.com/google/go-containerregistry v0.19.0 - github.com/kofalt/go-memoize v0.0.0-20220914132407-0b5d6a304579 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.32.0 github.com/stretchr/testify v1.8.4 @@ -273,7 +272,6 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc5 // indirect github.com/package-url/packageurl-go v0.1.2 // indirect - github.com/patrickmn/go-cache v2.1.0+incompatible // indirect github.com/pelletier/go-toml/v2 v2.1.1 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pkg/sftp v1.13.6 // indirect diff --git a/providers/k8s/go.sum b/providers/k8s/go.sum index facff75c1f..bc6081eec0 100644 --- a/providers/k8s/go.sum +++ b/providers/k8s/go.sum @@ -706,8 +706,6 @@ github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/knqyf263/go-rpmdb v0.0.0-20231206071317-a8af76a6220f h1:G7KFUNfKsJDCvOP2ZSiqDdHzBX3tPJ05pO7eKVYL1jo= github.com/knqyf263/go-rpmdb v0.0.0-20231206071317-a8af76a6220f/go.mod h1:9LQcoMCMQ9vrF7HcDtXfvqGO4+ddxFQ8+YF/0CVGDww= -github.com/kofalt/go-memoize v0.0.0-20220914132407-0b5d6a304579 h1:RbY+urZu3ri7Medi8pY3ovt1+XQxxv7zSkgmEZ5E0CU= -github.com/kofalt/go-memoize v0.0.0-20220914132407-0b5d6a304579/go.mod h1:PifxINf6wYU0USPBk0z1Z8Pka1AqeyCJAp9ecCcNL5Q= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= @@ -857,8 +855,6 @@ github.com/package-url/packageurl-go v0.1.2 h1:0H2DQt6DHd/NeRlVwW4EZ4oEI6Bn40XlN github.com/package-url/packageurl-go v0.1.2/go.mod h1:uQd4a7Rh3ZsVg5j0lNyAfyxIeGde9yrlhjF78GzeW0c= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= -github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI= github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= @@ -981,12 +977,8 @@ github.com/sivchari/tenv v1.7.1 h1:PSpuD4bu6fSmtWMxSGWcvqUUgIn7k3yOJhOIzVWn8Ak= github.com/sivchari/tenv v1.7.1/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg= github.com/smarty/assertions v1.15.1 h1:812oFiXI+G55vxsFf+8bIZ1ux30qtkdqzKbEFwyX3Tk= github.com/smarty/assertions v1.15.1/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec= -github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs= -github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY= github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60= -github.com/smartystreets/gunit v1.4.2 h1:tyWYZffdPhQPfK5VsMQXfauwnJkqg7Tv5DLuQVYxq3Q= -github.com/smartystreets/gunit v1.4.2/go.mod h1:ZjM1ozSIMJlAz/ay4SG8PeKF00ckUp+zMHZXV9/bvak= github.com/sonatard/noctx v0.0.2 h1:L7Dz4De2zDQhW8S0t+KUjY0MAQJd6SgVwhzNIc4ok00= github.com/sonatard/noctx v0.0.2/go.mod h1:kzFz+CzWSjQ2OzIm46uJZoXuBpa2+0y3T36U18dWqIo= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= diff --git a/providers/k8s/provider/provider.go b/providers/k8s/provider/provider.go index 5560b62a72..9acb22b4ec 100644 --- a/providers/k8s/provider/provider.go +++ b/providers/k8s/provider/provider.go @@ -171,16 +171,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = connId - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/k8s/resources/discovery.go b/providers/k8s/resources/discovery.go index a9dc16e50d..b8b0648944 100644 --- a/providers/k8s/resources/discovery.go +++ b/providers/k8s/resources/discovery.go @@ -311,7 +311,7 @@ func discoverPods( Name: pod.Namespace.Data + "/" + pod.Name.Data, Platform: platform, Labels: labels, - Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(invConfig.Id))}, // pass-in the parent connection config Category: conn.Asset().Category, }) od.Add(pod.obj) @@ -366,7 +366,7 @@ func discoverJobs( Name: job.Namespace.Data + "/" + job.Name.Data, Platform: platform, Labels: labels, - Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(invConfig.Id))}, // pass-in the parent connection config Category: conn.Asset().Category, }) od.Add(job.obj) @@ -421,7 +421,7 @@ func discoverCronJobs( Name: cjob.Namespace.Data + "/" + cjob.Name.Data, Platform: platform, Labels: labels, - Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(invConfig.Id))}, // pass-in the parent connection config Category: conn.Asset().Category, }) od.Add(cjob.obj) @@ -476,7 +476,7 @@ func discoverStatefulSets( Name: statefulset.Namespace.Data + "/" + statefulset.Name.Data, Platform: platform, Labels: labels, - Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(invConfig.Id))}, // pass-in the parent connection config Category: conn.Asset().Category, }) od.Add(statefulset.obj) @@ -531,7 +531,7 @@ func discoverDeployments( Name: deployment.Namespace.Data + "/" + deployment.Name.Data, Platform: platform, Labels: labels, - Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(invConfig.Id))}, // pass-in the parent connection config Category: conn.Asset().Category, }) od.Add(deployment.obj) @@ -586,7 +586,7 @@ func discoverReplicaSets( Name: replicaset.Namespace.Data + "/" + replicaset.Name.Data, Platform: platform, Labels: labels, - Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(invConfig.Id))}, // pass-in the parent connection config Category: conn.Asset().Category, }) od.Add(replicaset.obj) @@ -641,7 +641,7 @@ func discoverDaemonSets( Name: daemonset.Namespace.Data + "/" + daemonset.Name.Data, Platform: platform, Labels: labels, - Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(invConfig.Id))}, // pass-in the parent connection config Category: conn.Asset().Category, }) od.Add(daemonset.obj) @@ -726,7 +726,7 @@ func discoverIngresses( Name: ingress.Namespace.Data + "/" + ingress.Name.Data, Platform: platform, Labels: labels, - Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(invConfig.Id))}, // pass-in the parent connection config Category: conn.Asset().Category, }) od.Add(ingress.obj) @@ -779,7 +779,7 @@ func discoverNamespaces( Name: ns.Name, Platform: platform, Labels: labels, - Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery())}, // pass-in the parent connection config + Connections: []*inventory.Config{invConfig.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(invConfig.Id))}, // pass-in the parent connection config Category: conn.Asset().Category, }) if od != nil { diff --git a/providers/k8s/resources/resources_test.go b/providers/k8s/resources/resources_test.go index bbf1a52a0b..15badcc0f0 100644 --- a/providers/k8s/resources/resources_test.go +++ b/providers/k8s/resources/resources_test.go @@ -17,6 +17,7 @@ import ( "go.mondoo.com/cnquery/v10/providers/k8s/connection/manifest" "go.mondoo.com/cnquery/v10/providers/k8s/connection/shared" sharedres "go.mondoo.com/cnquery/v10/providers/k8s/connection/shared/resources" + "go.mondoo.com/cnquery/v10/utils/syncx" ) type K8sObjectKindTest struct { @@ -50,7 +51,7 @@ func TestManifestFiles(t *testing.T) { require.NoError(t, err) require.NotNil(t, conn) - runtime := &plugin.Runtime{} + runtime := &plugin.Runtime{Resources: &syncx.Map[plugin.Resource]{}} runtime.Connection = conn obj, err := NewResource( @@ -145,7 +146,7 @@ func TestManifestFile_CustomResource(t *testing.T) { name := "demo-pipeline" namespace := "default" kind := "pipeline.tekton.dev" - runtime := &plugin.Runtime{} + runtime := &plugin.Runtime{Resources: &syncx.Map[plugin.Resource]{}} runtime.Connection = conn parser := conn.(*manifest.Connection).ManifestParser @@ -159,6 +160,7 @@ func TestManifestFile_CustomResource(t *testing.T) { assert.Equal(t, 1, len(res.Resources)) rr, err := conn.Resources(kind, name, namespace) + require.NoError(t, err) assert.Equal(t, name, rr.Name) assert.Equal(t, namespace, rr.Namespace) diff --git a/providers/ms365/connection/connection.go b/providers/ms365/connection/connection.go index 66f9c4c2f9..f7bd35938a 100644 --- a/providers/ms365/connection/connection.go +++ b/providers/ms365/connection/connection.go @@ -12,6 +12,7 @@ import ( errors "github.com/cockroachdb/errors" msgrapgh_org "github.com/microsoftgraph/msgraph-sdk-go/organization" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" "go.mondoo.com/cnquery/v10/providers/os/connection/local" "go.mondoo.com/cnquery/v10/providers/os/connection/shared" @@ -26,7 +27,7 @@ const ( ) type Ms365Connection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset token azcore.TokenCredential @@ -63,10 +64,9 @@ func NewMs365Connection(id uint32, asset *inventory.Asset, conf *inventory.Confi if err != nil { return nil, errors.Wrap(err, "authentication failed") } - return &Ms365Connection{ + Connection: plugin.NewConnection(id, asset), Conf: conf, - id: id, asset: asset, token: token, tenantId: tenantId, @@ -80,10 +80,6 @@ func (h *Ms365Connection) Name() string { return "ms365" } -func (h *Ms365Connection) ID() uint32 { - return h.id -} - func (p *Ms365Connection) Asset() *inventory.Asset { return p.asset } diff --git a/providers/ms365/provider/provider.go b/providers/ms365/provider/provider.go index 164a22c987..68c2e46b88 100644 --- a/providers/ms365/provider/provider.go +++ b/providers/ms365/provider/provider.go @@ -130,16 +130,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/network/connection/connection.go b/providers/network/connection/connection.go index fec21d3994..891fba5a92 100644 --- a/providers/network/connection/connection.go +++ b/providers/network/connection/connection.go @@ -5,19 +5,20 @@ package connection import ( "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" ) type HostConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset } func NewHostConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) *HostConnection { return &HostConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } } @@ -25,10 +26,6 @@ func (h *HostConnection) Name() string { return "host" } -func (h *HostConnection) ID() uint32 { - return h.id -} - func (p *HostConnection) Asset() *inventory.Asset { return p.asset } diff --git a/providers/network/provider/provider.go b/providers/network/provider/provider.go index 4109d81b49..f93ac0ad69 100644 --- a/providers/network/provider/provider.go +++ b/providers/network/provider/provider.go @@ -174,16 +174,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = connId - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/network/resources/dns_test.go b/providers/network/resources/dns_test.go index 94cc31c654..35a4bb4264 100644 --- a/providers/network/resources/dns_test.go +++ b/providers/network/resources/dns_test.go @@ -13,6 +13,7 @@ import ( "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/network/connection" "go.mondoo.com/cnquery/v10/providers/network/resources" + "go.mondoo.com/cnquery/v10/utils/syncx" ) func TestResource_DNS(t *testing.T) { @@ -50,13 +51,13 @@ func TestResource_DnsFqdn(t *testing.T) { }, } - runtime := &plugin.Runtime{} + runtime := &plugin.Runtime{Resources: &syncx.Map[plugin.Resource]{}} for _, tc := range testCases { conf := &inventory.Config{ Host: tc.hostName, } - runtime.Connection = connection.NewHostConnection(1, nil, conf) + runtime.Connection = connection.NewHostConnection(1, &inventory.Asset{}, conf) dns, err := resources.NewResource( runtime, diff --git a/providers/network/resources/tls_test.go b/providers/network/resources/tls_test.go index 6fe6380e3b..f6b6b922c3 100644 --- a/providers/network/resources/tls_test.go +++ b/providers/network/resources/tls_test.go @@ -13,6 +13,7 @@ import ( "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/network/connection" "go.mondoo.com/cnquery/v10/providers/network/resources" + "go.mondoo.com/cnquery/v10/utils/syncx" ) func TestResource_TLS(t *testing.T) { @@ -32,13 +33,13 @@ func TestResource_TlsFqdn(t *testing.T) { }, } - runtime := &plugin.Runtime{} + runtime := &plugin.Runtime{Resources: &syncx.Map[plugin.Resource]{}} for _, tc := range testCases { conf := &inventory.Config{ Host: tc.hostName, } - runtime.Connection = connection.NewHostConnection(1, nil, conf) + runtime.Connection = connection.NewHostConnection(1, &inventory.Asset{}, conf) dns, err := resources.NewResource( runtime, diff --git a/providers/oci/connection/connection.go b/providers/oci/connection/connection.go index 9089063db8..9a12071905 100644 --- a/providers/oci/connection/connection.go +++ b/providers/oci/connection/connection.go @@ -8,11 +8,12 @@ import ( "github.com/oracle/oci-go-sdk/v65/common" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" ) type OciConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset config common.ConfigurationProvider @@ -21,9 +22,9 @@ type OciConnection struct { func NewOciConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*OciConnection, error) { conn := &OciConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // initialize your connection here @@ -70,10 +71,6 @@ func (s *OciConnection) Name() string { return "oci" } -func (s *OciConnection) ID() uint32 { - return s.id -} - func (s *OciConnection) Asset() *inventory.Asset { return s.asset } diff --git a/providers/oci/provider/provider.go b/providers/oci/provider/provider.go index d2ebe411a0..d2eb4bfcef 100644 --- a/providers/oci/provider/provider.go +++ b/providers/oci/provider/provider.go @@ -152,16 +152,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = connId - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/okta/connection/connection.go b/providers/okta/connection/connection.go index 18c618b114..fe8e8949b9 100644 --- a/providers/okta/connection/connection.go +++ b/providers/okta/connection/connection.go @@ -10,11 +10,12 @@ import ( "github.com/okta/okta-sdk-golang/v2/okta" "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" ) type OktaConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset // custom connection fields @@ -25,9 +26,9 @@ type OktaConnection struct { func NewOktaConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*OktaConnection, error) { conn := &OktaConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // initialize connection @@ -77,10 +78,6 @@ func (c *OktaConnection) Name() string { return "okta" } -func (c *OktaConnection) ID() uint32 { - return c.id -} - func (c *OktaConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/okta/provider/provider.go b/providers/okta/provider/provider.go index 36c1832c77..e4d2e01d3d 100644 --- a/providers/okta/provider/provider.go +++ b/providers/okta/provider/provider.go @@ -132,16 +132,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = connId - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/opcua/connection/connection.go b/providers/opcua/connection/connection.go index f918f4ee91..0c62b31d49 100644 --- a/providers/opcua/connection/connection.go +++ b/providers/opcua/connection/connection.go @@ -14,7 +14,7 @@ import ( ) type OpcuaConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset client *opcua.Client @@ -23,9 +23,9 @@ type OpcuaConnection struct { func NewOpcuaConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*OpcuaConnection, error) { conn := &OpcuaConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // initialize connection @@ -82,10 +82,6 @@ func (c *OpcuaConnection) Name() string { return "opcua" } -func (c *OpcuaConnection) ID() uint32 { - return c.id -} - func (c *OpcuaConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/opcua/provider/provider.go b/providers/opcua/provider/provider.go index ab2450caca..33f92e2cf2 100644 --- a/providers/opcua/provider/provider.go +++ b/providers/opcua/provider/provider.go @@ -106,16 +106,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/os/connection/docker_container.go b/providers/os/connection/docker_container.go index e9e91a574d..93269a7d5e 100644 --- a/providers/os/connection/docker_container.go +++ b/providers/os/connection/docker_container.go @@ -15,6 +15,7 @@ import ( "github.com/rs/zerolog/log" "github.com/spf13/afero" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/os/connection/container/auth" "go.mondoo.com/cnquery/v10/providers/os/connection/container/docker_engine" "go.mondoo.com/cnquery/v10/providers/os/connection/container/image" @@ -31,7 +32,7 @@ const ( var _ shared.Connection = &DockerContainerConnection{} type DockerContainerConnection struct { - id uint32 + plugin.Connection asset *inventory.Asset Client *client.Client @@ -68,12 +69,12 @@ func NewDockerContainerConnection(id uint32, conf *inventory.Config, asset *inve } conn := &DockerContainerConnection{ - id: id, - asset: asset, - Client: dockerClient, - container: conf.Host, - kind: "container", - runtime: "docker", + Connection: plugin.NewConnection(id, asset), + asset: asset, + Client: dockerClient, + container: conf.Host, + kind: "container", + runtime: "docker", } // this can later be used for containers build from scratch @@ -103,10 +104,6 @@ func GetDockerClient() (*client.Client, error) { return cli, nil } -func (c *DockerContainerConnection) ID() uint32 { - return c.id -} - func (c *DockerContainerConnection) Name() string { return string(DockerContainer) } diff --git a/providers/os/connection/docker_snapshot.go b/providers/os/connection/docker_snapshot.go index 84aa270784..1ffe469799 100644 --- a/providers/os/connection/docker_snapshot.go +++ b/providers/os/connection/docker_snapshot.go @@ -73,10 +73,6 @@ func ExportSnapshot(containerid string, f *os.File) error { return cache.StreamToTmpFile(rc, f) } -func (p *DockerSnapshotConnection) ID() uint32 { - return p.id -} - func (p *DockerSnapshotConnection) Name() string { return string(shared.Type_DockerSnapshot) } diff --git a/providers/os/connection/fs/filesystem.go b/providers/os/connection/fs/filesystem.go index 5a3cbf5b8f..318b2cf1a4 100644 --- a/providers/os/connection/fs/filesystem.go +++ b/providers/os/connection/fs/filesystem.go @@ -30,7 +30,7 @@ func NewFileSystemConnectionWithClose(id uint32, conf *inventory.Config, asset * log.Debug().Str("path", path).Msg("load filesystem") return &FileSystemConnection{ - id: id, + Connection: plugin.NewConnection(id, asset), Conf: conf, asset: asset, MountedDir: path, @@ -45,7 +45,7 @@ func NewConnection(id uint32, conf *inventory.Config, asset *inventory.Asset) (* } type FileSystemConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset @@ -102,10 +102,6 @@ func (c *FileSystemConnection) Identifier() (string, error) { return c.tcPlatformId, nil } -func (c *FileSystemConnection) ID() uint32 { - return c.id -} - func (c *FileSystemConnection) Name() string { return string(shared.Type_FileSystem) } diff --git a/providers/os/connection/fs/filesystem_test.go b/providers/os/connection/fs/filesystem_test.go index 1f1f7c7a23..5d6940ccdc 100644 --- a/providers/os/connection/fs/filesystem_test.go +++ b/providers/os/connection/fs/filesystem_test.go @@ -18,7 +18,7 @@ import ( func TestOsDetection(t *testing.T) { conn, err := fs.NewConnection(0, &inventory.Config{ Path: "./testdata/centos8", - }, nil) + }, &inventory.Asset{}) require.NoError(t, err) pf, detected := detector.DetectOS(conn) @@ -31,7 +31,7 @@ func TestOsDetection(t *testing.T) { func TestMountedDirectoryFile(t *testing.T) { conn, err := fs.NewConnection(0, &inventory.Config{ Path: "./testdata/centos8", - }, nil) + }, &inventory.Asset{}) require.NoError(t, err) f, err := conn.FileSystem().Open("/etc/os-release") @@ -69,7 +69,7 @@ func TestMountedDirectoryFile(t *testing.T) { func TestRunCommandReturnsErr(t *testing.T) { conn, err := fs.NewConnection(0, &inventory.Config{ Path: "./testdata/centos8", - }, nil) + }, &inventory.Asset{}) require.NoError(t, err) _, err = conn.RunCommand("aa-status") diff --git a/providers/os/connection/fs/fsutil/hash_test.go b/providers/os/connection/fs/fsutil/hash_test.go index 609cf0c108..56d29886dc 100644 --- a/providers/os/connection/fs/fsutil/hash_test.go +++ b/providers/os/connection/fs/fsutil/hash_test.go @@ -8,6 +8,7 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/fs/fsutil" "go.mondoo.com/cnquery/v10/providers/os/connection/local" ) @@ -15,7 +16,7 @@ import ( func TestFileResource(t *testing.T) { path := "/tmp/test_hash" - conn := local.NewConnection(0, nil, nil) + conn := local.NewConnection(0, nil, &inventory.Asset{}) assert.NotNil(t, conn) fs := conn.FileSystem() diff --git a/providers/os/connection/local/local.go b/providers/os/connection/local/local.go index 0b25400939..12bc80661e 100644 --- a/providers/os/connection/local/local.go +++ b/providers/os/connection/local/local.go @@ -14,24 +14,24 @@ import ( "github.com/rs/zerolog/log" "github.com/spf13/afero" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/os/connection/shared" "go.mondoo.com/cnquery/v10/providers/os/connection/ssh/cat" ) type LocalConnection struct { - shell []string - fs afero.Fs - Sudo *inventory.Sudo - runtime string - id uint32 - asset *inventory.Asset + plugin.Connection + shell []string + fs afero.Fs + Sudo *inventory.Sudo + asset *inventory.Asset } func NewConnection(id uint32, conf *inventory.Config, asset *inventory.Asset) *LocalConnection { // expect unix shell by default res := LocalConnection{ - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + asset: asset, } if conf != nil { res.Sudo = conf.Sudo @@ -48,10 +48,6 @@ func NewConnection(id uint32, conf *inventory.Config, asset *inventory.Asset) *L return &res } -func (p *LocalConnection) ID() uint32 { - return p.id -} - func (p *LocalConnection) Name() string { return "local" } diff --git a/providers/os/connection/local/statutil/stat_test.go b/providers/os/connection/local/statutil/stat_test.go index c06a4522ba..48e88893f1 100644 --- a/providers/os/connection/local/statutil/stat_test.go +++ b/providers/os/connection/local/statutil/stat_test.go @@ -12,13 +12,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/connection/shared" ) func TestLinuxStatCmd(t *testing.T) { filepath, _ := filepath.Abs("./testdata/linux.toml") - p, err := mock.New(0, filepath, nil) + p, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) statHelper := New(p) @@ -45,7 +46,7 @@ func TestLinuxStatCmd(t *testing.T) { func TestOpenbsdStatCmd(t *testing.T) { filepath, _ := filepath.Abs("./testdata/openbsd.toml") - p, err := mock.New(0, filepath, nil) + p, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) statHelper := New(p) @@ -65,7 +66,7 @@ func TestOpenbsdStatCmd(t *testing.T) { func TestAixStatCmd(t *testing.T) { filepath, _ := filepath.Abs("./testdata/aix.toml") - p, err := mock.New(0, filepath, nil) + p, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) statHelper := New(p) diff --git a/providers/os/connection/mock/mock.go b/providers/os/connection/mock/mock.go index d746e83e05..3677abac19 100644 --- a/providers/os/connection/mock/mock.go +++ b/providers/os/connection/mock/mock.go @@ -20,6 +20,7 @@ import ( "github.com/rs/zerolog/log" "github.com/spf13/afero" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/os/connection/shared" ) @@ -63,18 +64,18 @@ type MockFileData struct { } type Connection struct { + plugin.Connection data *TomlData asset *inventory.Asset mutex sync.Mutex - uid uint32 missing map[string]map[string]bool } func New(id uint32, path string, asset *inventory.Asset) (*Connection, error) { res := &Connection{ - uid: id, - data: &TomlData{}, - asset: asset, + Connection: plugin.NewConnection(id, asset), + data: &TomlData{}, + asset: asset, missing: map[string]map[string]bool{ "file": {}, "command": {}, @@ -114,10 +115,6 @@ func New(id uint32, path string, asset *inventory.Asset) (*Connection, error) { return res, nil } -func (c *Connection) ID() uint32 { - return c.uid -} - func (c *Connection) Type() shared.ConnectionType { return "mock" } diff --git a/providers/os/connection/shared/shared.go b/providers/os/connection/shared/shared.go index 2fbba6dc1e..b541d0a97c 100644 --- a/providers/os/connection/shared/shared.go +++ b/providers/os/connection/shared/shared.go @@ -14,6 +14,7 @@ import ( "github.com/spf13/afero" "go.mondoo.com/cnquery/v10/llx" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" ) type ConnectionType string @@ -43,10 +44,10 @@ const ( ) type Connection interface { + plugin.Connection RunCommand(command string) (*Command, error) FileInfo(path string) (FileInfoDetails, error) FileSystem() afero.Fs - ID() uint32 Name() string Type() ConnectionType Asset() *inventory.Asset @@ -54,7 +55,7 @@ type Connection interface { } type SimpleConnection interface { - ID() uint32 + plugin.Connection Name() string Type() ConnectionType Asset() *inventory.Asset diff --git a/providers/os/connection/ssh.go b/providers/os/connection/ssh.go index e39cafbbf2..38244b8744 100644 --- a/providers/os/connection/ssh.go +++ b/providers/os/connection/ssh.go @@ -22,6 +22,7 @@ import ( "github.com/rs/zerolog/log" "github.com/spf13/afero" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" "go.mondoo.com/cnquery/v10/providers/os/connection/shared" "go.mondoo.com/cnquery/v10/providers/os/connection/ssh/awsinstanceconnect" @@ -39,7 +40,7 @@ import ( var _ shared.Connection = (*SshConnection)(nil) type SshConnection struct { - id uint32 + plugin.Connection conf *inventory.Config asset *inventory.Asset @@ -54,9 +55,9 @@ type SshConnection struct { func NewSshConnection(id uint32, conf *inventory.Config, asset *inventory.Asset) (*SshConnection, error) { res := SshConnection{ - id: id, - conf: conf, - asset: asset, + Connection: plugin.NewConnection(id, asset), + conf: conf, + asset: asset, } host := conf.GetHost() @@ -115,10 +116,6 @@ func NewSshConnection(id uint32, conf *inventory.Config, asset *inventory.Asset) return &res, nil } -func (c *SshConnection) ID() uint32 { - return c.id -} - func (c *SshConnection) Name() string { return "ssh" } diff --git a/providers/os/connection/ssh/cat/cat_test.go b/providers/os/connection/ssh/cat/cat_test.go index 92c0348dcc..7ae650922d 100644 --- a/providers/os/connection/ssh/cat/cat_test.go +++ b/providers/os/connection/ssh/cat/cat_test.go @@ -22,7 +22,7 @@ import ( func TestCatFs(t *testing.T) { filepath, _ := filepath.Abs("./testdata/cat.toml") - p, err := mock.New(0, filepath, nil) + p, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) flags := map[string]*llx.Primitive{ diff --git a/providers/os/connection/ssh_test.go b/providers/os/connection/ssh_test.go index cafbfcba68..364c42ad1b 100644 --- a/providers/os/connection/ssh_test.go +++ b/providers/os/connection/ssh_test.go @@ -25,12 +25,12 @@ func TestSSHDefaultSettings(t *testing.T) { } func TestSSHProviderError(t *testing.T) { - _, err := NewSshConnection(0, &inventory.Config{Type: shared.Type_Local.String(), Host: "example.local"}, nil) + _, err := NewSshConnection(0, &inventory.Config{Type: shared.Type_Local.String(), Host: "example.local"}, &inventory.Asset{}) assert.Equal(t, "provider type does not match", err.Error()) } func TestSSHAuthError(t *testing.T) { - _, err := NewSshConnection(0, &inventory.Config{Type: shared.Type_SSH.String(), Host: "example.local"}, nil) + _, err := NewSshConnection(0, &inventory.Config{Type: shared.Type_SSH.String(), Host: "example.local"}, &inventory.Asset{}) assert.True(t, // local testing if ssh agent is available err.Error() == "dial tcp: lookup example.local: no such host" || diff --git a/providers/os/connection/tar.go b/providers/os/connection/tar.go index 4b51fec1f1..01f316118a 100644 --- a/providers/os/connection/tar.go +++ b/providers/os/connection/tar.go @@ -17,6 +17,7 @@ import ( "github.com/rs/zerolog/log" "github.com/spf13/afero" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/os/connection/container/cache" "go.mondoo.com/cnquery/v10/providers/os/connection/shared" provider_tar "go.mondoo.com/cnquery/v10/providers/os/connection/tar" @@ -32,7 +33,7 @@ const ( var _ shared.Connection = (*TarConnection)(nil) type TarConnection struct { - id uint32 + plugin.Connection asset *inventory.Asset conf *inventory.Config fetchFn func() (string, error) @@ -52,10 +53,6 @@ type TarConnection struct { } } -func (p *TarConnection) ID() uint32 { - return p.id -} - func (p *TarConnection) Name() string { return string(shared.Type_Tar) } @@ -181,9 +178,9 @@ func NewTarConnectionForContainer(id uint32, conf *inventory.Config, asset *inve } return &TarConnection{ - id: id, - asset: asset, - Fs: provider_tar.NewFs(f.Name()), + Connection: plugin.NewConnection(id, asset), + asset: asset, + Fs: provider_tar.NewFs(f.Name()), fetchFn: func() (string, error) { err = cache.StreamToTmpFile(mutate.Extract(img), f) if err != nil { @@ -277,7 +274,7 @@ func NewWithClose(id uint32, conf *inventory.Config, asset *inventory.Asset, clo identifier = "//platformid.api.mondoo.app/runtime/tar/hash/" + hash c := &TarConnection{ - id: id, + Connection: plugin.NewConnection(id, asset), asset: asset, Fs: provider_tar.NewFs(filename), CloseFN: closeFn, @@ -320,9 +317,9 @@ func newWithFlattenedImage(id uint32, conf *inventory.Config, asset *inventory.A } c := &TarConnection{ - id: id, - asset: asset, - Fs: provider_tar.NewFs(imageFilename), + Connection: plugin.NewConnection(id, asset), + asset: asset, + Fs: provider_tar.NewFs(imageFilename), CloseFN: func() { if closeFn != nil { closeFn() diff --git a/providers/os/connection/tar_test.go b/providers/os/connection/tar_test.go index fb86d82ebc..24d7ee5e8f 100644 --- a/providers/os/connection/tar_test.go +++ b/providers/os/connection/tar_test.go @@ -38,7 +38,7 @@ func TestTarCommand(t *testing.T) { Options: map[string]string{ connection.OPTION_FILE: alpineContainerPath, }, - }, nil) + }, &inventory.Asset{}) assert.Equal(t, nil, err, "should create tar without error") cmd, err := c.RunCommand("ls /") @@ -62,7 +62,7 @@ func TestPlatformIdentifier(t *testing.T) { Options: map[string]string{ connection.OPTION_FILE: alpineContainerPath, }, - }, nil) + }, &inventory.Asset{}) require.NoError(t, err) platformId, err := conn.Identifier() require.NoError(t, err) @@ -78,7 +78,7 @@ func TestTarSymlinkFile(t *testing.T) { Options: map[string]string{ connection.OPTION_FILE: alpineContainerPath, }, - }, nil) + }, &inventory.Asset{}) assert.Equal(t, nil, err, "should create tar without error") f, err := c.FileSystem().Open("/bin/cat") @@ -110,7 +110,7 @@ func TestTarRelativeSymlinkFileCentos(t *testing.T) { Options: map[string]string{ connection.OPTION_FILE: centosContainerPath, }, - }, nil) + }, &inventory.Asset{}) assert.Equal(t, nil, err, "should create tar without error") f, err := c.FileSystem().Open("/etc/redhat-release") @@ -141,7 +141,7 @@ func TestTarFile(t *testing.T) { Options: map[string]string{ connection.OPTION_FILE: alpineContainerPath, }, - }, nil) + }, &inventory.Asset{}) assert.Equal(t, nil, err, "should create tar without error") f, err := c.FileSystem().Open("/etc/alpine-release") @@ -171,7 +171,7 @@ func TestFilePermissions(t *testing.T) { Options: map[string]string{ connection.OPTION_FILE: alpineContainerPath, }, - }, nil) + }, &inventory.Asset{}) require.NoError(t, err) path := "/etc/alpine-release" @@ -228,7 +228,7 @@ func TestTarFileFind(t *testing.T) { Options: map[string]string{ connection.OPTION_FILE: alpineContainerPath, }, - }, nil) + }, &inventory.Asset{}) assert.Equal(t, nil, err, "should create tar without error") fs := c.FileSystem() diff --git a/providers/os/connection/vagrant.go b/providers/os/connection/vagrant.go index d334e8f331..a23f91e426 100644 --- a/providers/os/connection/vagrant.go +++ b/providers/os/connection/vagrant.go @@ -38,10 +38,6 @@ func NewVagrantConnection(id uint32, conf *inventory.Config, asset *inventory.As return &res, nil } -func (p *VagrantConnection) ID() uint32 { - return p.id -} - func (p *VagrantConnection) Name() string { return string(Vagrant) } diff --git a/providers/os/connection/vagrant/cli_test.go b/providers/os/connection/vagrant/cli_test.go index fe953bf81c..5657d4e546 100644 --- a/providers/os/connection/vagrant/cli_test.go +++ b/providers/os/connection/vagrant/cli_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/connection/vagrant" ) func TestVagrantSshConfigParsing(t *testing.T) { - mock, err := mock.New(0, "./testdata/vagrant.toml", nil) + mock, err := mock.New(0, "./testdata/vagrant.toml", &inventory.Asset{}) require.NoError(t, err) cmd, err := mock.RunCommand("vagrant ssh-config debian10") @@ -30,7 +31,7 @@ func TestVagrantSshConfigParsing(t *testing.T) { } func TestVagrantStatusParsing(t *testing.T) { - mock, err := mock.New(0, "./testdata/vagrant.toml", nil) + mock, err := mock.New(0, "./testdata/vagrant.toml", &inventory.Asset{}) require.NoError(t, err) cmd, err := mock.RunCommand("vagrant status") diff --git a/providers/os/connection/winrm.go b/providers/os/connection/winrm.go index e0cc241d2e..a27ffdbe4e 100644 --- a/providers/os/connection/winrm.go +++ b/providers/os/connection/winrm.go @@ -13,6 +13,7 @@ import ( "github.com/rs/zerolog/log" "github.com/spf13/afero" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" "go.mondoo.com/cnquery/v10/providers/os/connection/shared" winrmConn "go.mondoo.com/cnquery/v10/providers/os/connection/winrm" @@ -78,16 +79,16 @@ func NewWinrmConnection(id uint32, conf *inventory.Config, asset *inventory.Asse log.Debug().Msg("winrm> connection established") return &WinrmConnection{ - id: id, - conf: conf, - asset: asset, - Endpoint: winrmEndpoint, - Client: client, + Connection: plugin.NewConnection(id, asset), + conf: conf, + asset: asset, + Endpoint: winrmEndpoint, + Client: client, }, nil } type WinrmConnection struct { - id uint32 + plugin.Connection conf *inventory.Config asset *inventory.Asset @@ -97,10 +98,6 @@ type WinrmConnection struct { Client *winrm.Client } -func (c *WinrmConnection) ID() uint32 { - return c.id -} - func (c *WinrmConnection) Name() string { return "ssh" } diff --git a/providers/os/connection/winrm/cat/cat_test.go b/providers/os/connection/winrm/cat/cat_test.go index 9f37e95459..4cd50a44bf 100644 --- a/providers/os/connection/winrm/cat/cat_test.go +++ b/providers/os/connection/winrm/cat/cat_test.go @@ -10,13 +10,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/connection/winrm/cat" ) func TestCatFs(t *testing.T) { filepath, _ := filepath.Abs("./testdata/winrm.toml") - p, err := mock.New(0, filepath, nil) + p, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) catfs := cat.New(p) diff --git a/providers/os/detector/detector_platform_test.go b/providers/os/detector/detector_platform_test.go index 54847e1e7c..8867b7cc21 100644 --- a/providers/os/detector/detector_platform_test.go +++ b/providers/os/detector/detector_platform_test.go @@ -14,7 +14,7 @@ import ( ) func detectPlatformFromMock(filepath string) (*inventory.Platform, error) { - mockConn, err := mock.New(0, filepath, nil) + mockConn, err := mock.New(0, filepath, &inventory.Asset{}) if err != nil { return nil, err } diff --git a/providers/os/id/aws/aws_test.go b/providers/os/id/aws/aws_test.go index 8e46ef3a59..1a88024c81 100644 --- a/providers/os/id/aws/aws_test.go +++ b/providers/os/id/aws/aws_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" ) func TestDetectInstance(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance.toml", nil) + conn, err := mock.New(0, "./testdata/instance.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -27,7 +28,7 @@ func TestDetectInstance(t *testing.T) { } func TestDetectInstanceArm(t *testing.T) { - conn, err := mock.New(0, "./testdata/instancearm.toml", nil) + conn, err := mock.New(0, "./testdata/instancearm.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -41,7 +42,7 @@ func TestDetectInstanceArm(t *testing.T) { } func TestDetectNotInstance(t *testing.T) { - conn, err := mock.New(0, "./testdata/notinstance.toml", nil) + conn, err := mock.New(0, "./testdata/notinstance.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -55,7 +56,7 @@ func TestDetectNotInstance(t *testing.T) { } func TestDetectConainer(t *testing.T) { - conn, err := mock.New(0, "./testdata/container.toml", nil) + conn, err := mock.New(0, "./testdata/container.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/awsec2/metadata_cmd_test.go b/providers/os/id/awsec2/metadata_cmd_test.go index fe8d87478f..dcff519fde 100644 --- a/providers/os/id/awsec2/metadata_cmd_test.go +++ b/providers/os/id/awsec2/metadata_cmd_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" ) func TestEC2RoleProviderInstanceIdentityUnix(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance-identity_document_linux.toml", nil) + conn, err := mock.New(0, "./testdata/instance-identity_document_linux.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -28,7 +29,7 @@ func TestEC2RoleProviderInstanceIdentityUnix(t *testing.T) { } func TestEC2RoleProviderInstanceIdentityUnixNoName(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance-identity_document_linux_no_tags.toml", nil) + conn, err := mock.New(0, "./testdata/instance-identity_document_linux_no_tags.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -43,7 +44,7 @@ func TestEC2RoleProviderInstanceIdentityUnixNoName(t *testing.T) { } func TestEC2RoleProviderInstanceIdentityWindows(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance-identity_document_windows.toml", nil) + conn, err := mock.New(0, "./testdata/instance-identity_document_windows.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -58,7 +59,7 @@ func TestEC2RoleProviderInstanceIdentityWindows(t *testing.T) { } func TestEC2RoleProviderInstanceIdentityWindowsNoName(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance-identity_document_windows_no_tags.toml", nil) + conn, err := mock.New(0, "./testdata/instance-identity_document_windows_no_tags.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/awsecs/awsecs_test.go b/providers/os/id/awsecs/awsecs_test.go index 099c3e8a16..8cc74239db 100644 --- a/providers/os/id/awsecs/awsecs_test.go +++ b/providers/os/id/awsecs/awsecs_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" ) @@ -22,7 +23,7 @@ func TestParseECSContainerId(t *testing.T) { } func TestEC2RoleProviderInstanceIdentityUnix(t *testing.T) { - conn, err := mock.New(0, "./testdata/container-identity.toml", nil) + conn, err := mock.New(0, "./testdata/container-identity.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/azcompute/azcompute_test.go b/providers/os/id/azcompute/azcompute_test.go index 0c6c91ca37..c81235a66e 100644 --- a/providers/os/id/azcompute/azcompute_test.go +++ b/providers/os/id/azcompute/azcompute_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" ) func TestCommandProviderLinux(t *testing.T) { - conn, err := mock.New(0, "./testdata/metadata_linux.toml", nil) + conn, err := mock.New(0, "./testdata/metadata_linux.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -27,7 +28,7 @@ func TestCommandProviderLinux(t *testing.T) { } func TestCommandProviderWindows(t *testing.T) { - conn, err := mock.New(0, "./testdata/metadata_windows.toml", nil) + conn, err := mock.New(0, "./testdata/metadata_windows.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/gce/gce_test.go b/providers/os/id/gce/gce_test.go index ebec7a9d52..9cb5ecd115 100644 --- a/providers/os/id/gce/gce_test.go +++ b/providers/os/id/gce/gce_test.go @@ -8,13 +8,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" "go.mondoo.com/cnquery/v10/providers/os/id/gce" ) func TestCommandProviderLinux(t *testing.T) { - conn, err := mock.New(0, "./testdata/metadata_linux.toml", nil) + conn, err := mock.New(0, "./testdata/metadata_linux.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -29,7 +30,7 @@ func TestCommandProviderLinux(t *testing.T) { } func TestCommandProviderWindows(t *testing.T) { - conn, err := mock.New(0, "./testdata/metadata_windows.toml", nil) + conn, err := mock.New(0, "./testdata/metadata_windows.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/gcp/gcp_test.go b/providers/os/id/gcp/gcp_test.go index 475c52f287..065ee4547a 100644 --- a/providers/os/id/gcp/gcp_test.go +++ b/providers/os/id/gcp/gcp_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" ) func TestDetectLinuxInstance(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance_linux.toml", nil) + conn, err := mock.New(0, "./testdata/instance_linux.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -27,7 +28,7 @@ func TestDetectLinuxInstance(t *testing.T) { } func TestDetectWindowsInstance(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance_windows.toml", nil) + conn, err := mock.New(0, "./testdata/instance_windows.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -41,7 +42,7 @@ func TestDetectWindowsInstance(t *testing.T) { } func TestNoMatch(t *testing.T) { - conn, err := mock.New(0, "./testdata/aws_instance.toml", nil) + conn, err := mock.New(0, "./testdata/aws_instance.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/hostname/hostname_test.go b/providers/os/id/hostname/hostname_test.go index 9fc77c48d8..9ccfbfcba1 100644 --- a/providers/os/id/hostname/hostname_test.go +++ b/providers/os/id/hostname/hostname_test.go @@ -8,13 +8,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" "go.mondoo.com/cnquery/v10/providers/os/id/hostname" ) func TestHostnameLinuxEtcHostname(t *testing.T) { - conn, err := mock.New(0, "./testdata/hostname_arch.toml", nil) + conn, err := mock.New(0, "./testdata/hostname_arch.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -26,7 +27,7 @@ func TestHostnameLinuxEtcHostname(t *testing.T) { } func TestHostnameLinux(t *testing.T) { - conn, err := mock.New(0, "./testdata/hostname_linux.toml", nil) + conn, err := mock.New(0, "./testdata/hostname_linux.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -38,7 +39,7 @@ func TestHostnameLinux(t *testing.T) { } func TestHostnameLinuxFqdn(t *testing.T) { - conn, err := mock.New(0, "./testdata/hostname_fqdn.toml", nil) + conn, err := mock.New(0, "./testdata/hostname_fqdn.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -50,7 +51,7 @@ func TestHostnameLinuxFqdn(t *testing.T) { } func TestHostnameWindows(t *testing.T) { - conn, err := mock.New(0, "./testdata/hostname_windows.toml", nil) + conn, err := mock.New(0, "./testdata/hostname_windows.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -62,7 +63,7 @@ func TestHostnameWindows(t *testing.T) { } func TestHostnameMacos(t *testing.T) { - conn, err := mock.New(0, "./testdata/hostname_macos.toml", nil) + conn, err := mock.New(0, "./testdata/hostname_macos.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/platformid/linux_test.go b/providers/os/id/platformid/linux_test.go index a7cb3dbde1..ad52bd6345 100644 --- a/providers/os/id/platformid/linux_test.go +++ b/providers/os/id/platformid/linux_test.go @@ -9,12 +9,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestLinuxMachineId(t *testing.T) { filepath, _ := filepath.Abs("./testdata/linux_test.toml") - provider, err := mock.New(0, filepath, nil) + provider, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) lid := LinuxIdProvider{connection: provider} diff --git a/providers/os/id/platformid/osx_test.go b/providers/os/id/platformid/osx_test.go index 433db78486..bc69093c76 100644 --- a/providers/os/id/platformid/osx_test.go +++ b/providers/os/id/platformid/osx_test.go @@ -9,12 +9,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestMacOSMachineId(t *testing.T) { filepath, _ := filepath.Abs("./testdata/osx_test.toml") - provider, err := mock.New(0, filepath, nil) + provider, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) lid := MacOSIdProvider{connection: provider} diff --git a/providers/os/id/platformid/win_test.go b/providers/os/id/platformid/win_test.go index 309a367f21..4360759045 100644 --- a/providers/os/id/platformid/win_test.go +++ b/providers/os/id/platformid/win_test.go @@ -8,11 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestGuidWindows(t *testing.T) { - provider, err := mock.New(0, "./testdata/guid_windows.toml", nil) + provider, err := mock.New(0, "./testdata/guid_windows.toml", &inventory.Asset{}) require.NoError(t, err) lid := WinIdProvider{connection: provider} diff --git a/providers/os/provider/provider.go b/providers/os/provider/provider.go index 6130d94bde..b7abc001a5 100644 --- a/providers/os/provider/provider.go +++ b/providers/os/provider/provider.go @@ -422,16 +422,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba conf.Id = connId conf.Capabilities = conn.Capabilities().String() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/os/resources/file_test.go b/providers/os/resources/file_test.go index d3c42b4071..8ed406874a 100644 --- a/providers/os/resources/file_test.go +++ b/providers/os/resources/file_test.go @@ -12,6 +12,7 @@ import ( "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/testutils" "go.mondoo.com/cnquery/v10/providers/os/resources" + "go.mondoo.com/cnquery/v10/utils/syncx" ) const passwdContent = `root:x:0:0::/root:/bin/bash @@ -201,7 +202,7 @@ func TestResource_File_Permissions(t *testing.T) { }, } - runtime := &plugin.Runtime{} + runtime := &plugin.Runtime{Resources: &syncx.Map[plugin.Resource]{}} for _, tc := range testCases { if !tc.focus { diff --git a/providers/os/resources/groups/dscache_test.go b/providers/os/resources/groups/dscache_test.go index 94530056ae..093cccbf1a 100644 --- a/providers/os/resources/groups/dscache_test.go +++ b/providers/os/resources/groups/dscache_test.go @@ -7,12 +7,13 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/groups" ) func TestParseDscacheutilResult(t *testing.T) { - mock, err := mock.New(0, "./testdata/osx.toml", nil) + mock, err := mock.New(0, "./testdata/osx.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/groups/etcgroups_test.go b/providers/os/resources/groups/etcgroups_test.go index beb5288fe7..9063ef1ce7 100644 --- a/providers/os/resources/groups/etcgroups_test.go +++ b/providers/os/resources/groups/etcgroups_test.go @@ -7,12 +7,13 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/groups" ) func TestParseLinuxEtcGroups(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } @@ -41,7 +42,7 @@ func TestParseLinuxEtcGroups(t *testing.T) { } func TestParseFreebsd12EtcGroups(t *testing.T) { - mock, err := mock.New(0, "./testdata/freebsd12.toml", nil) + mock, err := mock.New(0, "./testdata/freebsd12.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/groups/ps1getlocalgroup_test.go b/providers/os/resources/groups/ps1getlocalgroup_test.go index 42b6a755b4..dfaa6c4af3 100644 --- a/providers/os/resources/groups/ps1getlocalgroup_test.go +++ b/providers/os/resources/groups/ps1getlocalgroup_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/groups" ) func TestWindowsGroupsParserFromMock(t *testing.T) { - mock, err := mock.New(0, "./testdata/windows.toml", nil) + mock, err := mock.New(0, "./testdata/windows.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.RunCommand("powershell -c \"Get-LocalGroup | ConvertTo-Json\"") diff --git a/providers/os/resources/kernel/modules_test.go b/providers/os/resources/kernel/modules_test.go index 34a1ae5653..e4f11f6c7f 100644 --- a/providers/os/resources/kernel/modules_test.go +++ b/providers/os/resources/kernel/modules_test.go @@ -8,11 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestLsmodParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.RunCommand("/sbin/lsmod") @@ -31,7 +32,7 @@ func TestLsmodParser(t *testing.T) { } func TestLinuxProcModulesParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.FileSystem().Open("/proc/modules") @@ -51,7 +52,7 @@ func TestLinuxProcModulesParser(t *testing.T) { } func TestKldstatParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/freebsd12.toml", nil) + mock, err := mock.New(0, "./testdata/freebsd12.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.RunCommand("kldstat") @@ -70,7 +71,7 @@ func TestKldstatParser(t *testing.T) { } func TestKextstatParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/osx.toml", nil) + mock, err := mock.New(0, "./testdata/osx.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.RunCommand("kextstat") diff --git a/providers/os/resources/kernel/sysctl_test.go b/providers/os/resources/kernel/sysctl_test.go index bc3a430797..e1af85a02e 100644 --- a/providers/os/resources/kernel/sysctl_test.go +++ b/providers/os/resources/kernel/sysctl_test.go @@ -8,11 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestSysctlDebian(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) require.NoError(t, err) c, err := mock.RunCommand("/sbin/sysctl -a") @@ -26,7 +27,7 @@ func TestSysctlDebian(t *testing.T) { } func TestSysctlMacos(t *testing.T) { - mock, err := mock.New(0, "./testdata/osx.toml", nil) + mock, err := mock.New(0, "./testdata/osx.toml", &inventory.Asset{}) require.NoError(t, err) c, err := mock.RunCommand("sysctl -a") @@ -40,7 +41,7 @@ func TestSysctlMacos(t *testing.T) { } func TestSysctlFreebsd(t *testing.T) { - mock, err := mock.New(0, "./testdata/freebsd12.toml", nil) + mock, err := mock.New(0, "./testdata/freebsd12.toml", &inventory.Asset{}) require.NoError(t, err) c, err := mock.RunCommand("sysctl -a") diff --git a/providers/os/resources/logindefs/logindefs_test.go b/providers/os/resources/logindefs/logindefs_test.go index 6d86db02b3..855f3886a5 100644 --- a/providers/os/resources/logindefs/logindefs_test.go +++ b/providers/os/resources/logindefs/logindefs_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/logindefs" ) func TestLoginDefsParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.FileSystem().Open("/etc/login.defs") diff --git a/providers/os/resources/packages/apk_packages_test.go b/providers/os/resources/packages/apk_packages_test.go index 37600d9d2b..ed084fabff 100644 --- a/providers/os/resources/packages/apk_packages_test.go +++ b/providers/os/resources/packages/apk_packages_test.go @@ -24,7 +24,7 @@ func TestAlpineApkdbParser(t *testing.T) { }, } - mock, err := mock.New(0, "./testdata/packages_apk.toml", nil) + mock, err := mock.New(0, "./testdata/packages_apk.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } @@ -118,7 +118,7 @@ func TestAlpineApkdbParser(t *testing.T) { } func TestApkUpdateParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/updates_apk.toml", nil) + mock, err := mock.New(0, "./testdata/updates_apk.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/packages/dpkg_packages_test.go b/providers/os/resources/packages/dpkg_packages_test.go index 0294a532fa..0a2306155a 100644 --- a/providers/os/resources/packages/dpkg_packages_test.go +++ b/providers/os/resources/packages/dpkg_packages_test.go @@ -25,7 +25,7 @@ func TestDpkgParser(t *testing.T) { }, } - mock, err := mock.New(0, "./testdata/packages_dpkg.toml", nil) + mock, err := mock.New(0, "./testdata/packages_dpkg.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.FileSystem().Open("/var/lib/dpkg/status") require.NoError(t, err) @@ -87,7 +87,7 @@ func TestDpkgParserStatusD(t *testing.T) { }, } - mock, err := mock.New(0, "./testdata/packages_dpkg_statusd.toml", nil) + mock, err := mock.New(0, "./testdata/packages_dpkg_statusd.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.FileSystem().Open("/var/lib/dpkg/status.d/base") require.NoError(t, err) @@ -115,7 +115,7 @@ and the text of several common licenses in use on Debian systems.`, } func TestDpkgUpdateParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/updates_dpkg.toml", nil) + mock, err := mock.New(0, "./testdata/updates_dpkg.toml", &inventory.Asset{}) require.NoError(t, err) c, err := mock.RunCommand("DEBIAN_FRONTEND=noninteractive apt-get upgrade --dry-run") require.NoError(t, err) diff --git a/providers/os/resources/packages/macos_packages_test.go b/providers/os/resources/packages/macos_packages_test.go index e7475a80b5..b2a2019c7a 100644 --- a/providers/os/resources/packages/macos_packages_test.go +++ b/providers/os/resources/packages/macos_packages_test.go @@ -7,12 +7,13 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/packages" ) func TestMacOsXPackageParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/packages_macos.toml", nil) + mock, err := mock.New(0, "./testdata/packages_macos.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/packages/opkg_packages_test.go b/providers/os/resources/packages/opkg_packages_test.go index 6b37aac819..2d65638105 100644 --- a/providers/os/resources/packages/opkg_packages_test.go +++ b/providers/os/resources/packages/opkg_packages_test.go @@ -49,7 +49,7 @@ firewall - 2016-11-29-1` } func TestOpkgStatusParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/packages_opkg_statusfile.toml", nil) + mock, err := mock.New(0, "./testdata/packages_opkg_statusfile.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.FileSystem().Open("/usr/lib/opkg/status") require.NoError(t, err) diff --git a/providers/os/resources/packages/rpm_packages_test.go b/providers/os/resources/packages/rpm_packages_test.go index a38f7bf986..c8355bbcc6 100644 --- a/providers/os/resources/packages/rpm_packages_test.go +++ b/providers/os/resources/packages/rpm_packages_test.go @@ -21,7 +21,7 @@ import ( ) func TestRedhat7Parser(t *testing.T) { - mock, err := mock.New(0, "./testdata/packages_redhat7.toml", nil) + mock, err := mock.New(0, "./testdata/packages_redhat7.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } @@ -104,7 +104,7 @@ func TestRedhat7Parser(t *testing.T) { } func TestRedhat6Parser(t *testing.T) { - mock, err := mock.New(0, "./testdata/packages_redhat6.toml", nil) + mock, err := mock.New(0, "./testdata/packages_redhat6.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } @@ -178,7 +178,7 @@ func TestRedhat6Parser(t *testing.T) { func TestPhoton4ImageParser(t *testing.T) { // to create this test file, run the following command: // mondoo scan docker image photon:4.0 --record - mock, err := mock.New(0, "./testdata/packages_photon_image.toml", nil) + mock, err := mock.New(0, "./testdata/packages_photon_image.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/packages/rpm_updates_test.go b/providers/os/resources/packages/rpm_updates_test.go index a66460f58a..74b4e4820a 100644 --- a/providers/os/resources/packages/rpm_updates_test.go +++ b/providers/os/resources/packages/rpm_updates_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestRpmUpdateParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/updates_rpm.toml", nil) + mock, err := mock.New(0, "./testdata/updates_rpm.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } @@ -37,7 +38,7 @@ func TestRpmUpdateParser(t *testing.T) { } func TestZypperUpdateParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/updates_zypper.toml", nil) + mock, err := mock.New(0, "./testdata/updates_zypper.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/procfs/cpu_info_test.go b/providers/os/resources/procfs/cpu_info_test.go index d8231498dd..3ccd5142f3 100644 --- a/providers/os/resources/procfs/cpu_info_test.go +++ b/providers/os/resources/procfs/cpu_info_test.go @@ -8,11 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestParseProcCpuX64(t *testing.T) { - trans, err := mock.New(0, "./testdata/cpu-info-x64.toml", nil) + trans, err := mock.New(0, "./testdata/cpu-info-x64.toml", &inventory.Asset{}) require.NoError(t, err) f, err := trans.FileSystem().Open("/proc/cpuinfo") @@ -70,7 +71,7 @@ func TestParseProcCpuX64(t *testing.T) { } func TestParseProcCpuArm(t *testing.T) { - trans, err := mock.New(0, "./testdata/cpu-info-aarch64.toml", nil) + trans, err := mock.New(0, "./testdata/cpu-info-aarch64.toml", &inventory.Asset{}) require.NoError(t, err) f, err := trans.FileSystem().Open("/proc/cpuinfo") diff --git a/providers/os/resources/procfs/processes_test.go b/providers/os/resources/procfs/processes_test.go index 2763943722..d7acec9388 100644 --- a/providers/os/resources/procfs/processes_test.go +++ b/providers/os/resources/procfs/processes_test.go @@ -8,11 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestParseProcessStatus(t *testing.T) { - trans, err := mock.New(0, "./testdata/process-pid1.toml", nil) + trans, err := mock.New(0, "./testdata/process-pid1.toml", &inventory.Asset{}) require.NoError(t, err) f, err := trans.FileSystem().Open("/proc/1/status") @@ -27,7 +28,7 @@ func TestParseProcessStatus(t *testing.T) { } func TestParseProcessCmdline(t *testing.T) { - trans, err := mock.New(0, "./testdata/process-pid1.toml", nil) + trans, err := mock.New(0, "./testdata/process-pid1.toml", &inventory.Asset{}) require.NoError(t, err) f, err := trans.FileSystem().Open("/proc/1/cmdline") diff --git a/providers/os/resources/shadow/shadow_test.go b/providers/os/resources/shadow/shadow_test.go index 982efcb51f..e044158d92 100644 --- a/providers/os/resources/shadow/shadow_test.go +++ b/providers/os/resources/shadow/shadow_test.go @@ -9,12 +9,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/shadow" ) func TestParseShadow(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.FileSystem().Open("/etc/shadow") diff --git a/providers/os/resources/smbios/smbios_test.go b/providers/os/resources/smbios/smbios_test.go index 9311ca1d85..287023d719 100644 --- a/providers/os/resources/smbios/smbios_test.go +++ b/providers/os/resources/smbios/smbios_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" ) func TestManagerCentos(t *testing.T) { - conn, err := mock.New(0, "./testdata/centos.toml", nil) + conn, err := mock.New(0, "./testdata/centos.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -56,7 +57,7 @@ func TestManagerCentos(t *testing.T) { } func TestManagerMacos(t *testing.T) { - conn, err := mock.New(0, "./testdata/macos.toml", nil) + conn, err := mock.New(0, "./testdata/macos.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -99,7 +100,7 @@ func TestManagerMacos(t *testing.T) { } func TestManagerWindows(t *testing.T) { - conn, err := mock.New(0, "./testdata/windows.toml", nil) + conn, err := mock.New(0, "./testdata/windows.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/resources/users/dscl_test.go b/providers/os/resources/users/dscl_test.go index 02c85ce555..b53c5d6b06 100644 --- a/providers/os/resources/users/dscl_test.go +++ b/providers/os/resources/users/dscl_test.go @@ -7,12 +7,13 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/users" ) func TestParseDsclListResult(t *testing.T) { - mock, err := mock.New(0, "./testdata/osx.toml", nil) + mock, err := mock.New(0, "./testdata/osx.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/users/etcpasswd_test.go b/providers/os/resources/users/etcpasswd_test.go index 21f227c06c..77d0ce81a2 100644 --- a/providers/os/resources/users/etcpasswd_test.go +++ b/providers/os/resources/users/etcpasswd_test.go @@ -7,12 +7,13 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/users" ) func TestParseLinuxEtcPasswd(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } @@ -36,7 +37,7 @@ func TestParseLinuxEtcPasswd(t *testing.T) { } func TestParseFreebsdLinuxEtcPasswd(t *testing.T) { - mock, err := mock.New(0, "./testdata/freebsd12.toml", nil) + mock, err := mock.New(0, "./testdata/freebsd12.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/windows/auditpol_test.go b/providers/os/resources/windows/auditpol_test.go index c70b371449..911da979bf 100644 --- a/providers/os/resources/windows/auditpol_test.go +++ b/providers/os/resources/windows/auditpol_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/windows" ) func TestParseAuditpol(t *testing.T) { - mock, err := mock.New(0, "./testdata/auditpol.toml", nil) + mock, err := mock.New(0, "./testdata/auditpol.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.RunCommand("auditpol /get /category:* /r") diff --git a/providers/os/resources/windows/secpol_test.go b/providers/os/resources/windows/secpol_test.go index 2f8274ef90..dc3f600ad9 100644 --- a/providers/os/resources/windows/secpol_test.go +++ b/providers/os/resources/windows/secpol_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/powershell" ) func TestParseSecpol(t *testing.T) { - mock, err := mock.New(0, "./testdata/secpol.toml", nil) + mock, err := mock.New(0, "./testdata/secpol.toml", &inventory.Asset{}) require.NoError(t, err) encoded := powershell.Encode(SecpolScript) diff --git a/providers/os/resources/yum/yum_test.go b/providers/os/resources/yum/yum_test.go index 34f0bce00c..547bb9f537 100644 --- a/providers/os/resources/yum/yum_test.go +++ b/providers/os/resources/yum/yum_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) @@ -62,7 +63,7 @@ Repo-filename: /etc/yum.repos.d/CentOS-Media.repo } func TestYumRepoRhel7(t *testing.T) { - mock, err := mock.New(0, "./testdata/yum_rhel7.toml", nil) + mock, err := mock.New(0, "./testdata/yum_rhel7.toml", &inventory.Asset{}) require.NoError(t, err) cmd, err := mock.RunCommand(RhelYumRepoListCommand) @@ -79,7 +80,7 @@ func TestYumRepoRhel7(t *testing.T) { } func TestYumRepoRhel8(t *testing.T) { - mock, err := mock.New(0, "./testdata/yum_rhel8.toml", nil) + mock, err := mock.New(0, "./testdata/yum_rhel8.toml", &inventory.Asset{}) require.NoError(t, err) cmd, err := mock.RunCommand(RhelYumRepoListCommand) diff --git a/providers/slack/connection/connection.go b/providers/slack/connection/connection.go index b9284f2e6c..7a5d4e9e6e 100644 --- a/providers/slack/connection/connection.go +++ b/providers/slack/connection/connection.go @@ -12,11 +12,12 @@ import ( "github.com/rs/zerolog/log" "github.com/slack-go/slack" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" ) type SlackConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset client *slack.Client @@ -25,17 +26,17 @@ type SlackConnection struct { func NewMockConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) *SlackConnection { return &SlackConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } } func NewSlackConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*SlackConnection, error) { sc := &SlackConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // if a secret was provided, it always overrides the env variable since it has precedence @@ -75,10 +76,6 @@ func (s *SlackConnection) Name() string { return "slack" } -func (s *SlackConnection) ID() uint32 { - return s.id -} - func (s *SlackConnection) Asset() *inventory.Asset { return s.asset } @@ -111,12 +108,15 @@ func (l *zeroLogAdapter) Msg(msg string, keysAndValues ...interface{}) { func (l *zeroLogAdapter) Error(msg string, keysAndValues ...interface{}) { l.Msg(msg, keysAndValues...) } + func (l *zeroLogAdapter) Info(msg string, keysAndValues ...interface{}) { l.Msg(msg, keysAndValues...) } + func (l *zeroLogAdapter) Debug(msg string, keysAndValues ...interface{}) { l.Msg(msg, keysAndValues...) } + func (l *zeroLogAdapter) Warn(msg string, keysAndValues ...interface{}) { l.Msg(msg, keysAndValues...) } diff --git a/providers/slack/provider/provider.go b/providers/slack/provider/provider.go index 7a673c72d1..215eb4fb38 100644 --- a/providers/slack/provider/provider.go +++ b/providers/slack/provider/provider.go @@ -143,16 +143,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/terraform/connection/connection.go b/providers/terraform/connection/connection.go index 5447dcaa57..c8607646f7 100644 --- a/providers/terraform/connection/connection.go +++ b/providers/terraform/connection/connection.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hclparse" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" ) type ConnectionType string @@ -15,7 +16,7 @@ type ConnectionType string // - https://www.terraform.io/docs/language/syntax/configuration.html // - https://github.com/hashicorp/hcl/blob/main/hclsyntax/spec.md type Connection struct { - id uint32 + plugin.Connection name string asset *inventory.Asset platformID string @@ -46,10 +47,6 @@ func (c *Connection) Asset() *inventory.Asset { return c.asset } -func (c *Connection) ID() uint32 { - return c.id -} - func (c *Connection) Name() string { return c.name } diff --git a/providers/terraform/connection/hcl_manifest.go b/providers/terraform/connection/hcl_manifest.go index 36c59fd818..8978fb5a1e 100644 --- a/providers/terraform/connection/hcl_manifest.go +++ b/providers/terraform/connection/hcl_manifest.go @@ -18,6 +18,7 @@ import ( "github.com/pkg/errors" "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" ) @@ -133,9 +134,9 @@ func newHclConnection(id uint32, path string, asset *inventory.Asset) (*Connecti } return &Connection{ - id: id, - asset: asset, - assetType: assetType, + Connection: plugin.NewConnection(id, asset), + asset: asset, + assetType: assetType, parsed: loader.GetParser(), tfVars: tfVars, diff --git a/providers/terraform/connection/tfplan.go b/providers/terraform/connection/tfplan.go index 0be7ade6bb..e95b0a5efb 100644 --- a/providers/terraform/connection/tfplan.go +++ b/providers/terraform/connection/tfplan.go @@ -9,6 +9,7 @@ import ( "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" ) type Plan struct { @@ -214,9 +215,9 @@ func NewPlanConnection(id uint32, asset *inventory.Asset) (*Connection, error) { } return &Connection{ - id: id, - asset: asset, - assetType: assetType, + Connection: plugin.NewConnection(id, asset), + asset: asset, + assetType: assetType, plan: &tfPlan, }, nil diff --git a/providers/terraform/connection/tfstate.go b/providers/terraform/connection/tfstate.go index 4c3b4fcf81..48ab70f8cb 100644 --- a/providers/terraform/connection/tfstate.go +++ b/providers/terraform/connection/tfstate.go @@ -9,6 +9,7 @@ import ( "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" ) // This is designed around https://www.terraform.io/internals/json-format @@ -101,9 +102,9 @@ func NewStateConnection(id uint32, asset *inventory.Asset) (*Connection, error) } return &Connection{ - id: id, - asset: asset, - assetType: assetType, + Connection: plugin.NewConnection(id, asset), + asset: asset, + assetType: assetType, state: &tfState, }, nil diff --git a/providers/terraform/provider/provider.go b/providers/terraform/provider/provider.go index e8c50c1f7f..fe85c9bcbe 100644 --- a/providers/terraform/provider/provider.go +++ b/providers/terraform/provider/provider.go @@ -177,16 +177,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/vcd/connection/connection.go b/providers/vcd/connection/connection.go index 267e740382..258e32ff08 100644 --- a/providers/vcd/connection/connection.go +++ b/providers/vcd/connection/connection.go @@ -11,11 +11,12 @@ import ( "github.com/rs/zerolog/log" "github.com/vmware/go-vcloud-director/v2/govcd" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" ) type VcdConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset // custom fields @@ -25,9 +26,9 @@ type VcdConnection struct { func NewVcdConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*VcdConnection, error) { conn := &VcdConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // initialize connection @@ -75,10 +76,6 @@ func (c *VcdConnection) Name() string { return "vcd" } -func (c *VcdConnection) ID() uint32 { - return c.id -} - func (c *VcdConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/vcd/provider/provider.go b/providers/vcd/provider/provider.go index fdaa94920d..625c2dc7e1 100644 --- a/providers/vcd/provider/provider.go +++ b/providers/vcd/provider/provider.go @@ -124,16 +124,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err diff --git a/providers/vsphere/connection/connection.go b/providers/vsphere/connection/connection.go index 3f411a9736..b6ae96fb7e 100644 --- a/providers/vsphere/connection/connection.go +++ b/providers/vsphere/connection/connection.go @@ -9,6 +9,7 @@ import ( "net/url" "strconv" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" "github.com/vmware/govmomi" @@ -16,7 +17,7 @@ import ( ) type VsphereConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset client *govmomi.Client @@ -39,9 +40,9 @@ func vSphereConnectionURL(hostname string, port int32, user string, password str func NewVsphereConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*VsphereConnection, error) { conn := &VsphereConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // initialize vSphere connection @@ -76,10 +77,6 @@ func (c *VsphereConnection) Name() string { return "vsphere" } -func (c *VsphereConnection) ID() uint32 { - return c.id -} - func (c *VsphereConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/vsphere/provider/provider.go b/providers/vsphere/provider/provider.go index 72f135990c..e56830a91f 100644 --- a/providers/vsphere/provider/provider.go +++ b/providers/vsphere/provider/provider.go @@ -154,16 +154,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = connId - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err