Add Validate RPC to Config service SDK. (#55)

Signed-off-by: Edwin Buck <edwbuck@gmail.com>
This commit is contained in:
Edwin Buck 2024-07-01 13:08:28 -05:00 committed by Marcos Yacob
parent 3f1b22c78d
commit 8f411ead94
3 changed files with 272 additions and 32 deletions

View File

@ -115,6 +115,124 @@ func (*ConfigureResponse) Descriptor() ([]byte, []int) {
return file_spire_service_common_config_v1_config_proto_rawDescGZIP(), []int{1}
}
type ValidateRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Required. Core SPIRE configuration.
CoreConfiguration *CoreConfiguration `protobuf:"bytes,1,opt,name=core_configuration,json=coreConfiguration,proto3" json:"core_configuration,omitempty"`
// Required. HCL encoded plugin configuration.
HclConfiguration string `protobuf:"bytes,2,opt,name=hcl_configuration,json=hclConfiguration,proto3" json:"hcl_configuration,omitempty"`
}
func (x *ValidateRequest) Reset() {
*x = ValidateRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_spire_service_common_config_v1_config_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ValidateRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ValidateRequest) ProtoMessage() {}
func (x *ValidateRequest) ProtoReflect() protoreflect.Message {
mi := &file_spire_service_common_config_v1_config_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ValidateRequest.ProtoReflect.Descriptor instead.
func (*ValidateRequest) Descriptor() ([]byte, []int) {
return file_spire_service_common_config_v1_config_proto_rawDescGZIP(), []int{2}
}
func (x *ValidateRequest) GetCoreConfiguration() *CoreConfiguration {
if x != nil {
return x.CoreConfiguration
}
return nil
}
func (x *ValidateRequest) GetHclConfiguration() string {
if x != nil {
return x.HclConfiguration
}
return ""
}
type ValidateResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Required. True when the plugin deems the configuration usable.
Valid bool `protobuf:"varint,1,opt,name=valid,proto3" json:"valid,omitempty"`
// Examples of invalid configuration notes include:
// - value for "plugin.port" is not a number.
// - missing field "plugin.user"
// - specified SPIFFE ID in "plugin.spiffe_id" is not within system trust domain.
// - etc.
Notes []string `protobuf:"bytes,2,rep,name=notes,proto3" json:"notes,omitempty"`
}
func (x *ValidateResponse) Reset() {
*x = ValidateResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_spire_service_common_config_v1_config_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ValidateResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ValidateResponse) ProtoMessage() {}
func (x *ValidateResponse) ProtoReflect() protoreflect.Message {
mi := &file_spire_service_common_config_v1_config_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ValidateResponse.ProtoReflect.Descriptor instead.
func (*ValidateResponse) Descriptor() ([]byte, []int) {
return file_spire_service_common_config_v1_config_proto_rawDescGZIP(), []int{3}
}
func (x *ValidateResponse) GetValid() bool {
if x != nil {
return x.Valid
}
return false
}
func (x *ValidateResponse) GetNotes() []string {
if x != nil {
return x.Notes
}
return nil
}
type CoreConfiguration struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -128,7 +246,7 @@ type CoreConfiguration struct {
func (x *CoreConfiguration) Reset() {
*x = CoreConfiguration{}
if protoimpl.UnsafeEnabled {
mi := &file_spire_service_common_config_v1_config_proto_msgTypes[2]
mi := &file_spire_service_common_config_v1_config_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -141,7 +259,7 @@ func (x *CoreConfiguration) String() string {
func (*CoreConfiguration) ProtoMessage() {}
func (x *CoreConfiguration) ProtoReflect() protoreflect.Message {
mi := &file_spire_service_common_config_v1_config_proto_msgTypes[2]
mi := &file_spire_service_common_config_v1_config_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -154,7 +272,7 @@ func (x *CoreConfiguration) ProtoReflect() protoreflect.Message {
// Deprecated: Use CoreConfiguration.ProtoReflect.Descriptor instead.
func (*CoreConfiguration) Descriptor() ([]byte, []int) {
return file_spire_service_common_config_v1_config_proto_rawDescGZIP(), []int{2}
return file_spire_service_common_config_v1_config_proto_rawDescGZIP(), []int{4}
}
func (x *CoreConfiguration) GetTrustDomain() string {
@ -183,24 +301,45 @@ var file_spire_service_common_config_v1_config_proto_rawDesc = []byte{
0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x10, 0x68, 0x63, 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x22, 0x13, 0x0a, 0x11, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x36, 0x0a, 0x11, 0x43, 0x6f, 0x72, 0x65, 0x43, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x74,
0x72, 0x75, 0x73, 0x74, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0b, 0x74, 0x72, 0x75, 0x73, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x32, 0x7a,
0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x70, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x75, 0x72, 0x65, 0x12, 0x30, 0x2e, 0x73, 0x70, 0x69, 0x72, 0x65, 0x2e, 0x73, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x63, 0x6f, 0x6e,
0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x73, 0x70, 0x69, 0x72, 0x65, 0x2e,
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x63,
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75,
0x72, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x52, 0x5a, 0x50, 0x67, 0x69,
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x70, 0x69, 0x66, 0x66, 0x65, 0x2f,
0x73, 0x70, 0x69, 0x72, 0x65, 0x2d, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2d, 0x73, 0x64, 0x6b,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x70, 0x69, 0x72, 0x65, 0x2f, 0x73, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x76, 0x31, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xa0, 0x01, 0x0a, 0x0f, 0x56, 0x61, 0x6c, 0x69, 0x64,
0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x60, 0x0a, 0x12, 0x63, 0x6f,
0x72, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x73, 0x70, 0x69, 0x72, 0x65, 0x2e, 0x73,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x63, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x43, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x11, 0x63, 0x6f, 0x72, 0x65, 0x43,
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x11,
0x68, 0x63, 0x6c, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x68, 0x63, 0x6c, 0x43, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3e, 0x0a, 0x10, 0x56, 0x61, 0x6c,
0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a,
0x05, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61,
0x6c, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03,
0x28, 0x09, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x22, 0x36, 0x0a, 0x11, 0x43, 0x6f, 0x72,
0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x21,
0x0a, 0x0c, 0x74, 0x72, 0x75, 0x73, 0x74, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x74, 0x72, 0x75, 0x73, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69,
0x6e, 0x32, 0xe9, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x70, 0x0a, 0x09,
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x12, 0x30, 0x2e, 0x73, 0x70, 0x69, 0x72,
0x65, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x75, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x73, 0x70,
0x69, 0x72, 0x65, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e,
0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6d,
0x0a, 0x08, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x12, 0x2f, 0x2e, 0x73, 0x70, 0x69,
0x72, 0x65, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f,
0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69,
0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x73, 0x70,
0x69, 0x72, 0x65, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c,
0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x52, 0x5a,
0x50, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x70, 0x69, 0x66,
0x66, 0x65, 0x2f, 0x73, 0x70, 0x69, 0x72, 0x65, 0x2d, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2d,
0x73, 0x64, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x70, 0x69, 0x72, 0x65, 0x2f,
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x63,
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x76,
0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -215,21 +354,26 @@ func file_spire_service_common_config_v1_config_proto_rawDescGZIP() []byte {
return file_spire_service_common_config_v1_config_proto_rawDescData
}
var file_spire_service_common_config_v1_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_spire_service_common_config_v1_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_spire_service_common_config_v1_config_proto_goTypes = []interface{}{
(*ConfigureRequest)(nil), // 0: spire.service.common.config.v1.ConfigureRequest
(*ConfigureResponse)(nil), // 1: spire.service.common.config.v1.ConfigureResponse
(*CoreConfiguration)(nil), // 2: spire.service.common.config.v1.CoreConfiguration
(*ValidateRequest)(nil), // 2: spire.service.common.config.v1.ValidateRequest
(*ValidateResponse)(nil), // 3: spire.service.common.config.v1.ValidateResponse
(*CoreConfiguration)(nil), // 4: spire.service.common.config.v1.CoreConfiguration
}
var file_spire_service_common_config_v1_config_proto_depIdxs = []int32{
2, // 0: spire.service.common.config.v1.ConfigureRequest.core_configuration:type_name -> spire.service.common.config.v1.CoreConfiguration
0, // 1: spire.service.common.config.v1.Config.Configure:input_type -> spire.service.common.config.v1.ConfigureRequest
1, // 2: spire.service.common.config.v1.Config.Configure:output_type -> spire.service.common.config.v1.ConfigureResponse
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
4, // 0: spire.service.common.config.v1.ConfigureRequest.core_configuration:type_name -> spire.service.common.config.v1.CoreConfiguration
4, // 1: spire.service.common.config.v1.ValidateRequest.core_configuration:type_name -> spire.service.common.config.v1.CoreConfiguration
0, // 2: spire.service.common.config.v1.Config.Configure:input_type -> spire.service.common.config.v1.ConfigureRequest
2, // 3: spire.service.common.config.v1.Config.Validate:input_type -> spire.service.common.config.v1.ValidateRequest
1, // 4: spire.service.common.config.v1.Config.Configure:output_type -> spire.service.common.config.v1.ConfigureResponse
3, // 5: spire.service.common.config.v1.Config.Validate:output_type -> spire.service.common.config.v1.ValidateResponse
4, // [4:6] is the sub-list for method output_type
2, // [2:4] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_spire_service_common_config_v1_config_proto_init() }
@ -263,6 +407,30 @@ func file_spire_service_common_config_v1_config_proto_init() {
}
}
file_spire_service_common_config_v1_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ValidateRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_spire_service_common_config_v1_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ValidateResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_spire_service_common_config_v1_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CoreConfiguration); i {
case 0:
return &v.state
@ -281,7 +449,7 @@ func file_spire_service_common_config_v1_config_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_spire_service_common_config_v1_config_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumMessages: 5,
NumExtensions: 0,
NumServices: 1,
},

View File

@ -12,6 +12,10 @@ service Config {
// calls to Configure can happen concurrently with other RPCs against the
// plugin.
rpc Configure(ConfigureRequest) returns (ConfigureResponse);
// Validate is called by SPIRE with a potential specific configuration for
// the plugin to determine if it is usable.
rpc Validate(ValidateRequest) returns (ValidateResponse);
}
message ConfigureRequest {
@ -25,6 +29,34 @@ message ConfigureRequest {
message ConfigureResponse {
}
message ValidateRequest {
// Required. Core SPIRE configuration.
CoreConfiguration core_configuration = 1;
// Required. HCL encoded plugin configuration.
string hcl_configuration = 2;
}
message ValidateResponse {
// Required. True when the plugin deems the configuration usable.
bool valid = 1;
// Optional. Zero or more notes providing feedback to an end user.
// Examples of valid configuration notes include:
// - "configuration valid"
// - "please ensure port 23423 is open"
// - "check access to (whatever) from the deployment environment"
// etc.
// Examples of invalid configuration notes include:
// - value for "plugin.port" is not a number.
// - missing field "plugin.user"
// - specified SPIFFE ID in "plugin.spiffe_id" is not within system trust domain.
// - etc.
repeated string notes = 2;
}
message CoreConfiguration {
// Required. The trust domain name SPIRE is configured with (e.g.
// "example.org").

View File

@ -26,6 +26,9 @@ type ConfigClient interface {
// calls to Configure can happen concurrently with other RPCs against the
// plugin.
Configure(ctx context.Context, in *ConfigureRequest, opts ...grpc.CallOption) (*ConfigureResponse, error)
// Validate is called by SPIRE with a potential specific configuration for
// the plugin to determine if it is usable.
Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error)
}
type configClient struct {
@ -45,6 +48,15 @@ func (c *configClient) Configure(ctx context.Context, in *ConfigureRequest, opts
return out, nil
}
func (c *configClient) Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error) {
out := new(ValidateResponse)
err := c.cc.Invoke(ctx, "/spire.service.common.config.v1.Config/Validate", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ConfigServer is the server API for Config service.
// All implementations must embed UnimplementedConfigServer
// for forward compatibility
@ -57,6 +69,9 @@ type ConfigServer interface {
// calls to Configure can happen concurrently with other RPCs against the
// plugin.
Configure(context.Context, *ConfigureRequest) (*ConfigureResponse, error)
// Validate is called by SPIRE with a potential specific configuration for
// the plugin to determine if it is usable.
Validate(context.Context, *ValidateRequest) (*ValidateResponse, error)
mustEmbedUnimplementedConfigServer()
}
@ -67,6 +82,9 @@ type UnimplementedConfigServer struct {
func (UnimplementedConfigServer) Configure(context.Context, *ConfigureRequest) (*ConfigureResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Configure not implemented")
}
func (UnimplementedConfigServer) Validate(context.Context, *ValidateRequest) (*ValidateResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Validate not implemented")
}
func (UnimplementedConfigServer) mustEmbedUnimplementedConfigServer() {}
// UnsafeConfigServer may be embedded to opt out of forward compatibility for this service.
@ -98,6 +116,24 @@ func _Config_Configure_Handler(srv interface{}, ctx context.Context, dec func(in
return interceptor(ctx, in, info, handler)
}
func _Config_Validate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ValidateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ConfigServer).Validate(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/spire.service.common.config.v1.Config/Validate",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ConfigServer).Validate(ctx, req.(*ValidateRequest))
}
return interceptor(ctx, in, info, handler)
}
// Config_ServiceDesc is the grpc.ServiceDesc for Config service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -109,6 +145,10 @@ var Config_ServiceDesc = grpc.ServiceDesc{
MethodName: "Configure",
Handler: _Config_Configure_Handler,
},
{
MethodName: "Validate",
Handler: _Config_Validate_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "spire/service/common/config/v1/config.proto",