authz: use pointer to to structpb.Struct instead of value (#6307)

This commit is contained in:
Arvind Bright 2023-05-22 15:39:17 -07:00 committed by GitHub
parent 511a96359f
commit 2a266e78a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -62,9 +62,9 @@ type rule struct {
}
type auditLogger struct {
Name string `json:"name"`
Config structpb.Struct `json:"config"`
IsOptional bool `json:"is_optional"`
Name string `json:"name"`
Config *structpb.Struct `json:"config"`
IsOptional bool `json:"is_optional"`
}
type auditLoggingOptions struct {
@ -306,9 +306,12 @@ func (options *auditLoggingOptions) toProtos() (allow *v3rbacpb.RBAC_AuditLoggin
if config.Name == "" {
return nil, nil, fmt.Errorf("missing required field: name in audit_logging_options.audit_loggers[%v]", i)
}
if config.Config == nil {
config.Config = &structpb.Struct{}
}
typedStruct := &v1xdsudpatypepb.TypedStruct{
TypeUrl: typeURLPrefix + config.Name,
Value: &config.Config,
Value: config.Config,
}
customConfig, err := anypb.New(typedStruct)
if err != nil {