From fc2b576deeaca10887a2402e73a030cb8b3608d3 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 31 Jul 2024 13:08:37 -0400 Subject: [PATCH] Add ability to get warnings from the WASM dev interface --- pkg/development/wasm/operations.go | 13 + pkg/development/wasm/operations_test.go | 53 +++ pkg/proto/developer/v1/developer.pb.go | 311 +++++++++---- .../developer/v1/developer.pb.validate.go | 296 ++++++++++++ .../developer/v1/developer_vtproto.pb.go | 436 ++++++++++++++++++ proto/internal/developer/v1/developer.proto | 13 + 6 files changed, 1042 insertions(+), 80 deletions(-) diff --git a/pkg/development/wasm/operations.go b/pkg/development/wasm/operations.go index 27c05ca31c..630f16d345 100644 --- a/pkg/development/wasm/operations.go +++ b/pkg/development/wasm/operations.go @@ -4,6 +4,7 @@ package main import ( + "context" "fmt" "strings" @@ -134,6 +135,18 @@ func runOperation(devContext *development.DevContext, operation *devinterface.Op }, }, nil + case operation.SchemaWarningsParameters != nil: + warnings, err := development.GetWarnings(context.Background(), devContext) + if err != nil { + return nil, err + } + + return &devinterface.OperationResult{ + SchemaWarningsResult: &devinterface.SchemaWarningsResult{ + Warnings: warnings, + }, + }, nil + default: return nil, fmt.Errorf("unknown operation") } diff --git a/pkg/development/wasm/operations_test.go b/pkg/development/wasm/operations_test.go index 4226a387b1..c691be3a60 100644 --- a/pkg/development/wasm/operations_test.go +++ b/pkg/development/wasm/operations_test.go @@ -22,6 +22,59 @@ type editCheckResult struct { IsConditional bool } +func TestSchemaWarningsOperation(t *testing.T) { + type testCase struct { + name string + schema string + expectedWarning *devinterface.DeveloperWarning + } + + tests := []testCase{ + { + "no warnings", + `definition foo { + relation bar: foo + }`, + nil, + }, + { + "permission misnamed", + `definition resource { + permission view_resource = nil + }`, + &devinterface.DeveloperWarning{ + Message: "Permission \"view_resource\" references parent type \"resource\" in its name; it is recommended to drop the suffix (relation-name-references-parent)", + Line: 2, + Column: 5, + SourceCode: "view_resource", + }, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + response := run(t, &devinterface.DeveloperRequest{ + Context: &devinterface.RequestContext{ + Schema: tc.schema, + }, + Operations: []*devinterface.Operation{ + { + SchemaWarningsParameters: &devinterface.SchemaWarningsParameters{}, + }, + }, + }) + + require.Empty(t, response.GetDeveloperErrors()) + + if tc.expectedWarning == nil { + require.Empty(t, response.GetOperationsResults().Results[0].SchemaWarningsResult.Warnings) + } else { + testutil.RequireProtoEqual(t, tc.expectedWarning, response.OperationsResults.Results[0].SchemaWarningsResult.Warnings[0], "mismatching warning") + } + }) + } +} + func TestCheckOperation(t *testing.T) { type testCase struct { name string diff --git a/pkg/proto/developer/v1/developer.pb.go b/pkg/proto/developer/v1/developer.pb.go index d90e09875e..f553c602d7 100644 --- a/pkg/proto/developer/v1/developer.pb.go +++ b/pkg/proto/developer/v1/developer.pb.go @@ -399,10 +399,11 @@ type Operation struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - CheckParameters *CheckOperationParameters `protobuf:"bytes,1,opt,name=check_parameters,json=checkParameters,proto3" json:"check_parameters,omitempty"` - AssertionsParameters *RunAssertionsParameters `protobuf:"bytes,2,opt,name=assertions_parameters,json=assertionsParameters,proto3" json:"assertions_parameters,omitempty"` - ValidationParameters *RunValidationParameters `protobuf:"bytes,3,opt,name=validation_parameters,json=validationParameters,proto3" json:"validation_parameters,omitempty"` - FormatSchemaParameters *FormatSchemaParameters `protobuf:"bytes,4,opt,name=format_schema_parameters,json=formatSchemaParameters,proto3" json:"format_schema_parameters,omitempty"` + CheckParameters *CheckOperationParameters `protobuf:"bytes,1,opt,name=check_parameters,json=checkParameters,proto3" json:"check_parameters,omitempty"` + AssertionsParameters *RunAssertionsParameters `protobuf:"bytes,2,opt,name=assertions_parameters,json=assertionsParameters,proto3" json:"assertions_parameters,omitempty"` + ValidationParameters *RunValidationParameters `protobuf:"bytes,3,opt,name=validation_parameters,json=validationParameters,proto3" json:"validation_parameters,omitempty"` + FormatSchemaParameters *FormatSchemaParameters `protobuf:"bytes,4,opt,name=format_schema_parameters,json=formatSchemaParameters,proto3" json:"format_schema_parameters,omitempty"` + SchemaWarningsParameters *SchemaWarningsParameters `protobuf:"bytes,5,opt,name=schema_warnings_parameters,json=schemaWarningsParameters,proto3" json:"schema_warnings_parameters,omitempty"` } func (x *Operation) Reset() { @@ -465,6 +466,13 @@ func (x *Operation) GetFormatSchemaParameters() *FormatSchemaParameters { return nil } +func (x *Operation) GetSchemaWarningsParameters() *SchemaWarningsParameters { + if x != nil { + return x.SchemaWarningsParameters + } + return nil +} + // OperationsResults holds the results for the operations, indexed by the operation. type OperationsResults struct { state protoimpl.MessageState @@ -519,10 +527,11 @@ type OperationResult struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - CheckResult *CheckOperationsResult `protobuf:"bytes,1,opt,name=check_result,json=checkResult,proto3" json:"check_result,omitempty"` - AssertionsResult *RunAssertionsResult `protobuf:"bytes,2,opt,name=assertions_result,json=assertionsResult,proto3" json:"assertions_result,omitempty"` - ValidationResult *RunValidationResult `protobuf:"bytes,3,opt,name=validation_result,json=validationResult,proto3" json:"validation_result,omitempty"` - FormatSchemaResult *FormatSchemaResult `protobuf:"bytes,4,opt,name=format_schema_result,json=formatSchemaResult,proto3" json:"format_schema_result,omitempty"` + CheckResult *CheckOperationsResult `protobuf:"bytes,1,opt,name=check_result,json=checkResult,proto3" json:"check_result,omitempty"` + AssertionsResult *RunAssertionsResult `protobuf:"bytes,2,opt,name=assertions_result,json=assertionsResult,proto3" json:"assertions_result,omitempty"` + ValidationResult *RunValidationResult `protobuf:"bytes,3,opt,name=validation_result,json=validationResult,proto3" json:"validation_result,omitempty"` + FormatSchemaResult *FormatSchemaResult `protobuf:"bytes,4,opt,name=format_schema_result,json=formatSchemaResult,proto3" json:"format_schema_result,omitempty"` + SchemaWarningsResult *SchemaWarningsResult `protobuf:"bytes,5,opt,name=schema_warnings_result,json=schemaWarningsResult,proto3" json:"schema_warnings_result,omitempty"` } func (x *OperationResult) Reset() { @@ -585,6 +594,13 @@ func (x *OperationResult) GetFormatSchemaResult() *FormatSchemaResult { return nil } +func (x *OperationResult) GetSchemaWarningsResult() *SchemaWarningsResult { + if x != nil { + return x.SchemaWarningsResult + } + return nil +} + // DeveloperWarning represents a single warning raised by the development package. type DeveloperWarning struct { state protoimpl.MessageState @@ -1343,6 +1359,93 @@ func (x *FormatSchemaResult) GetFormattedSchema() string { return "" } +// SchemaWarningsParameters are the parameters for a `schemaWarnings` operation. +type SchemaWarningsParameters struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *SchemaWarningsParameters) Reset() { + *x = SchemaWarningsParameters{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SchemaWarningsParameters) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SchemaWarningsParameters) ProtoMessage() {} + +func (x *SchemaWarningsParameters) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[18] + 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 SchemaWarningsParameters.ProtoReflect.Descriptor instead. +func (*SchemaWarningsParameters) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{18} +} + +// SchemaWarningsResult is the result of the `schemaWarnings` operation. +type SchemaWarningsResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Warnings []*DeveloperWarning `protobuf:"bytes,1,rep,name=warnings,proto3" json:"warnings,omitempty"` +} + +func (x *SchemaWarningsResult) Reset() { + *x = SchemaWarningsResult{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SchemaWarningsResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SchemaWarningsResult) ProtoMessage() {} + +func (x *SchemaWarningsResult) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[19] + 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 SchemaWarningsResult.ProtoReflect.Descriptor instead. +func (*SchemaWarningsResult) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{19} +} + +func (x *SchemaWarningsResult) GetWarnings() []*DeveloperWarning { + if x != nil { + return x.Warnings + } + return nil +} + var File_developer_v1_developer_proto protoreflect.FileDescriptor var file_developer_v1_developer_proto_rawDesc = []byte{ @@ -1385,7 +1488,7 @@ var file_developer_v1_developer_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x52, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x68, 0x69, 0x70, 0x73, 0x22, 0xf6, 0x02, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x68, 0x69, 0x70, 0x73, 0x22, 0xdc, 0x03, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x51, 0x0a, 0x10, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, @@ -1408,39 +1511,51 @@ var file_developer_v1_developer_proto_rawDesc = []byte{ 0x24, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x52, 0x16, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x53, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x22, 0xb6, 0x01, - 0x0a, 0x11, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x73, 0x12, 0x46, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, - 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x1a, 0x59, 0x0a, 0x0c, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x33, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x64, - 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xcd, 0x02, 0x0a, 0x0f, 0x4f, 0x70, 0x65, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x46, 0x0a, 0x0c, 0x63, 0x68, - 0x65, 0x63, 0x6b, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x23, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, - 0x43, 0x68, 0x65, 0x63, 0x6b, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x0b, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x12, 0x4e, 0x0a, 0x11, 0x61, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, - 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x75, 0x6e, - 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x52, 0x10, 0x61, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x12, 0x4e, 0x0a, 0x11, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, - 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x75, 0x6e, - 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x12, 0x52, 0x0a, 0x14, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x5f, 0x73, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x20, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, - 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x52, 0x12, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, + 0x65, 0x6d, 0x61, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x64, 0x0a, + 0x1a, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, + 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x26, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, + 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x52, 0x18, 0x73, 0x63, 0x68, 0x65, 0x6d, + 0x61, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, + 0x65, 0x72, 0x73, 0x22, 0xb6, 0x01, 0x0a, 0x11, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x46, 0x0a, 0x07, 0x72, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x64, 0x65, 0x76, + 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x73, 0x1a, 0x59, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x33, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, + 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xa7, 0x03, 0x0a, + 0x0f, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x12, 0x46, 0x0a, 0x0c, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, + 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x4f, 0x70, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x0b, 0x63, 0x68, 0x65, + 0x63, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x4e, 0x0a, 0x11, 0x61, 0x73, 0x73, 0x65, + 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, + 0x76, 0x31, 0x2e, 0x52, 0x75, 0x6e, 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x10, 0x61, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x4e, 0x0a, 0x11, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, + 0x76, 0x31, 0x2e, 0x52, 0x75, 0x6e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x52, 0x0a, 0x14, 0x66, 0x6f, 0x72, 0x6d, + 0x61, 0x74, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, + 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x53, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x12, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, + 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x58, 0x0a, 0x16, + 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x5f, + 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x64, + 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x52, 0x14, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x79, 0x0a, 0x10, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, @@ -1594,7 +1709,14 @@ var file_developer_v1_developer_proto_rawDesc = []byte{ 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x66, 0x6f, - 0x72, 0x6d, 0x61, 0x74, 0x74, 0x65, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x42, 0xb2, 0x01, + 0x72, 0x6d, 0x61, 0x74, 0x74, 0x65, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22, 0x1a, 0x0a, + 0x18, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x22, 0x52, 0x0a, 0x14, 0x53, 0x63, 0x68, + 0x65, 0x6d, 0x61, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x12, 0x3a, 0x0a, 0x08, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, + 0x76, 0x31, 0x2e, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x57, 0x61, 0x72, 0x6e, + 0x69, 0x6e, 0x67, 0x52, 0x08, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x42, 0xb2, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x42, 0x0e, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, @@ -1622,7 +1744,7 @@ func file_developer_v1_developer_proto_rawDescGZIP() []byte { } var file_developer_v1_developer_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_developer_v1_developer_proto_msgTypes = make([]protoimpl.MessageInfo, 19) +var file_developer_v1_developer_proto_msgTypes = make([]protoimpl.MessageInfo, 21) var file_developer_v1_developer_proto_goTypes = []any{ (DeveloperError_Source)(0), // 0: developer.v1.DeveloperError.Source (DeveloperError_ErrorKind)(0), // 1: developer.v1.DeveloperError.ErrorKind @@ -1645,51 +1767,56 @@ var file_developer_v1_developer_proto_goTypes = []any{ (*RunValidationResult)(nil), // 18: developer.v1.RunValidationResult (*FormatSchemaParameters)(nil), // 19: developer.v1.FormatSchemaParameters (*FormatSchemaResult)(nil), // 20: developer.v1.FormatSchemaResult - nil, // 21: developer.v1.OperationsResults.ResultsEntry - (*v1.RelationTuple)(nil), // 22: core.v1.RelationTuple - (*v11.DebugInformation)(nil), // 23: dispatch.v1.DebugInformation - (*v12.DebugInformation)(nil), // 24: authzed.api.v1.DebugInformation - (*v1.ObjectAndRelation)(nil), // 25: core.v1.ObjectAndRelation - (*structpb.Struct)(nil), // 26: google.protobuf.Struct + (*SchemaWarningsParameters)(nil), // 21: developer.v1.SchemaWarningsParameters + (*SchemaWarningsResult)(nil), // 22: developer.v1.SchemaWarningsResult + nil, // 23: developer.v1.OperationsResults.ResultsEntry + (*v1.RelationTuple)(nil), // 24: core.v1.RelationTuple + (*v11.DebugInformation)(nil), // 25: dispatch.v1.DebugInformation + (*v12.DebugInformation)(nil), // 26: authzed.api.v1.DebugInformation + (*v1.ObjectAndRelation)(nil), // 27: core.v1.ObjectAndRelation + (*structpb.Struct)(nil), // 28: google.protobuf.Struct } var file_developer_v1_developer_proto_depIdxs = []int32{ 5, // 0: developer.v1.DeveloperRequest.context:type_name -> developer.v1.RequestContext 6, // 1: developer.v1.DeveloperRequest.operations:type_name -> developer.v1.Operation 11, // 2: developer.v1.DeveloperResponse.developer_errors:type_name -> developer.v1.DeveloperErrors 7, // 3: developer.v1.DeveloperResponse.operations_results:type_name -> developer.v1.OperationsResults - 22, // 4: developer.v1.RequestContext.relationships:type_name -> core.v1.RelationTuple + 24, // 4: developer.v1.RequestContext.relationships:type_name -> core.v1.RelationTuple 12, // 5: developer.v1.Operation.check_parameters:type_name -> developer.v1.CheckOperationParameters 15, // 6: developer.v1.Operation.assertions_parameters:type_name -> developer.v1.RunAssertionsParameters 17, // 7: developer.v1.Operation.validation_parameters:type_name -> developer.v1.RunValidationParameters 19, // 8: developer.v1.Operation.format_schema_parameters:type_name -> developer.v1.FormatSchemaParameters - 21, // 9: developer.v1.OperationsResults.results:type_name -> developer.v1.OperationsResults.ResultsEntry - 13, // 10: developer.v1.OperationResult.check_result:type_name -> developer.v1.CheckOperationsResult - 16, // 11: developer.v1.OperationResult.assertions_result:type_name -> developer.v1.RunAssertionsResult - 18, // 12: developer.v1.OperationResult.validation_result:type_name -> developer.v1.RunValidationResult - 20, // 13: developer.v1.OperationResult.format_schema_result:type_name -> developer.v1.FormatSchemaResult - 0, // 14: developer.v1.DeveloperError.source:type_name -> developer.v1.DeveloperError.Source - 1, // 15: developer.v1.DeveloperError.kind:type_name -> developer.v1.DeveloperError.ErrorKind - 23, // 16: developer.v1.DeveloperError.check_debug_information:type_name -> dispatch.v1.DebugInformation - 24, // 17: developer.v1.DeveloperError.check_resolved_debug_information:type_name -> authzed.api.v1.DebugInformation - 10, // 18: developer.v1.DeveloperErrors.input_errors:type_name -> developer.v1.DeveloperError - 25, // 19: developer.v1.CheckOperationParameters.resource:type_name -> core.v1.ObjectAndRelation - 25, // 20: developer.v1.CheckOperationParameters.subject:type_name -> core.v1.ObjectAndRelation - 26, // 21: developer.v1.CheckOperationParameters.caveat_context:type_name -> google.protobuf.Struct - 2, // 22: developer.v1.CheckOperationsResult.membership:type_name -> developer.v1.CheckOperationsResult.Membership - 10, // 23: developer.v1.CheckOperationsResult.check_error:type_name -> developer.v1.DeveloperError - 23, // 24: developer.v1.CheckOperationsResult.debug_information:type_name -> dispatch.v1.DebugInformation - 14, // 25: developer.v1.CheckOperationsResult.partial_caveat_info:type_name -> developer.v1.PartialCaveatInfo - 24, // 26: developer.v1.CheckOperationsResult.resolved_debug_information:type_name -> authzed.api.v1.DebugInformation - 10, // 27: developer.v1.RunAssertionsResult.input_error:type_name -> developer.v1.DeveloperError - 10, // 28: developer.v1.RunAssertionsResult.validation_errors:type_name -> developer.v1.DeveloperError - 10, // 29: developer.v1.RunValidationResult.input_error:type_name -> developer.v1.DeveloperError - 10, // 30: developer.v1.RunValidationResult.validation_errors:type_name -> developer.v1.DeveloperError - 8, // 31: developer.v1.OperationsResults.ResultsEntry.value:type_name -> developer.v1.OperationResult - 32, // [32:32] is the sub-list for method output_type - 32, // [32:32] is the sub-list for method input_type - 32, // [32:32] is the sub-list for extension type_name - 32, // [32:32] is the sub-list for extension extendee - 0, // [0:32] is the sub-list for field type_name + 21, // 9: developer.v1.Operation.schema_warnings_parameters:type_name -> developer.v1.SchemaWarningsParameters + 23, // 10: developer.v1.OperationsResults.results:type_name -> developer.v1.OperationsResults.ResultsEntry + 13, // 11: developer.v1.OperationResult.check_result:type_name -> developer.v1.CheckOperationsResult + 16, // 12: developer.v1.OperationResult.assertions_result:type_name -> developer.v1.RunAssertionsResult + 18, // 13: developer.v1.OperationResult.validation_result:type_name -> developer.v1.RunValidationResult + 20, // 14: developer.v1.OperationResult.format_schema_result:type_name -> developer.v1.FormatSchemaResult + 22, // 15: developer.v1.OperationResult.schema_warnings_result:type_name -> developer.v1.SchemaWarningsResult + 0, // 16: developer.v1.DeveloperError.source:type_name -> developer.v1.DeveloperError.Source + 1, // 17: developer.v1.DeveloperError.kind:type_name -> developer.v1.DeveloperError.ErrorKind + 25, // 18: developer.v1.DeveloperError.check_debug_information:type_name -> dispatch.v1.DebugInformation + 26, // 19: developer.v1.DeveloperError.check_resolved_debug_information:type_name -> authzed.api.v1.DebugInformation + 10, // 20: developer.v1.DeveloperErrors.input_errors:type_name -> developer.v1.DeveloperError + 27, // 21: developer.v1.CheckOperationParameters.resource:type_name -> core.v1.ObjectAndRelation + 27, // 22: developer.v1.CheckOperationParameters.subject:type_name -> core.v1.ObjectAndRelation + 28, // 23: developer.v1.CheckOperationParameters.caveat_context:type_name -> google.protobuf.Struct + 2, // 24: developer.v1.CheckOperationsResult.membership:type_name -> developer.v1.CheckOperationsResult.Membership + 10, // 25: developer.v1.CheckOperationsResult.check_error:type_name -> developer.v1.DeveloperError + 25, // 26: developer.v1.CheckOperationsResult.debug_information:type_name -> dispatch.v1.DebugInformation + 14, // 27: developer.v1.CheckOperationsResult.partial_caveat_info:type_name -> developer.v1.PartialCaveatInfo + 26, // 28: developer.v1.CheckOperationsResult.resolved_debug_information:type_name -> authzed.api.v1.DebugInformation + 10, // 29: developer.v1.RunAssertionsResult.input_error:type_name -> developer.v1.DeveloperError + 10, // 30: developer.v1.RunAssertionsResult.validation_errors:type_name -> developer.v1.DeveloperError + 10, // 31: developer.v1.RunValidationResult.input_error:type_name -> developer.v1.DeveloperError + 10, // 32: developer.v1.RunValidationResult.validation_errors:type_name -> developer.v1.DeveloperError + 9, // 33: developer.v1.SchemaWarningsResult.warnings:type_name -> developer.v1.DeveloperWarning + 8, // 34: developer.v1.OperationsResults.ResultsEntry.value:type_name -> developer.v1.OperationResult + 35, // [35:35] is the sub-list for method output_type + 35, // [35:35] is the sub-list for method input_type + 35, // [35:35] is the sub-list for extension type_name + 35, // [35:35] is the sub-list for extension extendee + 0, // [0:35] is the sub-list for field type_name } func init() { file_developer_v1_developer_proto_init() } @@ -1914,6 +2041,30 @@ func file_developer_v1_developer_proto_init() { return nil } } + file_developer_v1_developer_proto_msgTypes[18].Exporter = func(v any, i int) any { + switch v := v.(*SchemaWarningsParameters); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[19].Exporter = func(v any, i int) any { + switch v := v.(*SchemaWarningsResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1921,7 +2072,7 @@ func file_developer_v1_developer_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_developer_v1_developer_proto_rawDesc, NumEnums: 3, - NumMessages: 19, + NumMessages: 21, NumExtensions: 0, NumServices: 0, }, diff --git a/pkg/proto/developer/v1/developer.pb.validate.go b/pkg/proto/developer/v1/developer.pb.validate.go index c268099ed5..1767bf480d 100644 --- a/pkg/proto/developer/v1/developer.pb.validate.go +++ b/pkg/proto/developer/v1/developer.pb.validate.go @@ -634,6 +634,35 @@ func (m *Operation) validate(all bool) error { } } + if all { + switch v := interface{}(m.GetSchemaWarningsParameters()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationValidationError{ + field: "SchemaWarningsParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationValidationError{ + field: "SchemaWarningsParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSchemaWarningsParameters()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationValidationError{ + field: "SchemaWarningsParameters", + reason: "embedded message failed validation", + cause: err, + } + } + } + if len(errors) > 0 { return OperationMultiError(errors) } @@ -997,6 +1026,35 @@ func (m *OperationResult) validate(all bool) error { } } + if all { + switch v := interface{}(m.GetSchemaWarningsResult()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationResultValidationError{ + field: "SchemaWarningsResult", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationResultValidationError{ + field: "SchemaWarningsResult", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSchemaWarningsResult()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationResultValidationError{ + field: "SchemaWarningsResult", + reason: "embedded message failed validation", + cause: err, + } + } + } + if len(errors) > 0 { return OperationResultMultiError(errors) } @@ -2754,3 +2812,241 @@ var _ interface { Cause() error ErrorName() string } = FormatSchemaResultValidationError{} + +// Validate checks the field values on SchemaWarningsParameters with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *SchemaWarningsParameters) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SchemaWarningsParameters with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// SchemaWarningsParametersMultiError, or nil if none found. +func (m *SchemaWarningsParameters) ValidateAll() error { + return m.validate(true) +} + +func (m *SchemaWarningsParameters) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return SchemaWarningsParametersMultiError(errors) + } + + return nil +} + +// SchemaWarningsParametersMultiError is an error wrapping multiple validation +// errors returned by SchemaWarningsParameters.ValidateAll() if the designated +// constraints aren't met. +type SchemaWarningsParametersMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SchemaWarningsParametersMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SchemaWarningsParametersMultiError) AllErrors() []error { return m } + +// SchemaWarningsParametersValidationError is the validation error returned by +// SchemaWarningsParameters.Validate if the designated constraints aren't met. +type SchemaWarningsParametersValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SchemaWarningsParametersValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SchemaWarningsParametersValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SchemaWarningsParametersValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SchemaWarningsParametersValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SchemaWarningsParametersValidationError) ErrorName() string { + return "SchemaWarningsParametersValidationError" +} + +// Error satisfies the builtin error interface +func (e SchemaWarningsParametersValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSchemaWarningsParameters.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SchemaWarningsParametersValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SchemaWarningsParametersValidationError{} + +// Validate checks the field values on SchemaWarningsResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *SchemaWarningsResult) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SchemaWarningsResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// SchemaWarningsResultMultiError, or nil if none found. +func (m *SchemaWarningsResult) ValidateAll() error { + return m.validate(true) +} + +func (m *SchemaWarningsResult) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetWarnings() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SchemaWarningsResultValidationError{ + field: fmt.Sprintf("Warnings[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SchemaWarningsResultValidationError{ + field: fmt.Sprintf("Warnings[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SchemaWarningsResultValidationError{ + field: fmt.Sprintf("Warnings[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return SchemaWarningsResultMultiError(errors) + } + + return nil +} + +// SchemaWarningsResultMultiError is an error wrapping multiple validation +// errors returned by SchemaWarningsResult.ValidateAll() if the designated +// constraints aren't met. +type SchemaWarningsResultMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SchemaWarningsResultMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SchemaWarningsResultMultiError) AllErrors() []error { return m } + +// SchemaWarningsResultValidationError is the validation error returned by +// SchemaWarningsResult.Validate if the designated constraints aren't met. +type SchemaWarningsResultValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SchemaWarningsResultValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SchemaWarningsResultValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SchemaWarningsResultValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SchemaWarningsResultValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SchemaWarningsResultValidationError) ErrorName() string { + return "SchemaWarningsResultValidationError" +} + +// Error satisfies the builtin error interface +func (e SchemaWarningsResultValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSchemaWarningsResult.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SchemaWarningsResultValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SchemaWarningsResultValidationError{} diff --git a/pkg/proto/developer/v1/developer_vtproto.pb.go b/pkg/proto/developer/v1/developer_vtproto.pb.go index 468c0a6878..c20d00e3e5 100644 --- a/pkg/proto/developer/v1/developer_vtproto.pb.go +++ b/pkg/proto/developer/v1/developer_vtproto.pb.go @@ -104,6 +104,7 @@ func (m *Operation) CloneVT() *Operation { r.AssertionsParameters = m.AssertionsParameters.CloneVT() r.ValidationParameters = m.ValidationParameters.CloneVT() r.FormatSchemaParameters = m.FormatSchemaParameters.CloneVT() + r.SchemaWarningsParameters = m.SchemaWarningsParameters.CloneVT() if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) copy(r.unknownFields, m.unknownFields) @@ -147,6 +148,7 @@ func (m *OperationResult) CloneVT() *OperationResult { r.AssertionsResult = m.AssertionsResult.CloneVT() r.ValidationResult = m.ValidationResult.CloneVT() r.FormatSchemaResult = m.FormatSchemaResult.CloneVT() + r.SchemaWarningsResult = m.SchemaWarningsResult.CloneVT() if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) copy(r.unknownFields, m.unknownFields) @@ -443,6 +445,45 @@ func (m *FormatSchemaResult) CloneMessageVT() proto.Message { return m.CloneVT() } +func (m *SchemaWarningsParameters) CloneVT() *SchemaWarningsParameters { + if m == nil { + return (*SchemaWarningsParameters)(nil) + } + r := new(SchemaWarningsParameters) + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SchemaWarningsParameters) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *SchemaWarningsResult) CloneVT() *SchemaWarningsResult { + if m == nil { + return (*SchemaWarningsResult)(nil) + } + r := new(SchemaWarningsResult) + if rhs := m.Warnings; rhs != nil { + tmpContainer := make([]*DeveloperWarning, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Warnings = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SchemaWarningsResult) CloneMessageVT() proto.Message { + return m.CloneVT() +} + func (this *DeveloperRequest) EqualVT(that *DeveloperRequest) bool { if this == that { return true @@ -562,6 +603,9 @@ func (this *Operation) EqualVT(that *Operation) bool { if !this.FormatSchemaParameters.EqualVT(that.FormatSchemaParameters) { return false } + if !this.SchemaWarningsParameters.EqualVT(that.SchemaWarningsParameters) { + return false + } return string(this.unknownFields) == string(that.unknownFields) } @@ -626,6 +670,9 @@ func (this *OperationResult) EqualVT(that *OperationResult) bool { if !this.FormatSchemaResult.EqualVT(that.FormatSchemaResult) { return false } + if !this.SchemaWarningsResult.EqualVT(that.SchemaWarningsResult) { + return false + } return string(this.unknownFields) == string(that.unknownFields) } @@ -1011,6 +1058,55 @@ func (this *FormatSchemaResult) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } +func (this *SchemaWarningsParameters) EqualVT(that *SchemaWarningsParameters) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SchemaWarningsParameters) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SchemaWarningsParameters) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *SchemaWarningsResult) EqualVT(that *SchemaWarningsResult) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Warnings) != len(that.Warnings) { + return false + } + for i, vx := range this.Warnings { + vy := that.Warnings[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &DeveloperWarning{} + } + if q == nil { + q = &DeveloperWarning{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SchemaWarningsResult) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SchemaWarningsResult) + if !ok { + return false + } + return this.EqualVT(that) +} func (m *DeveloperRequest) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -1220,6 +1316,16 @@ func (m *Operation) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } + if m.SchemaWarningsParameters != nil { + size, err := m.SchemaWarningsParameters.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } if m.FormatSchemaParameters != nil { size, err := m.FormatSchemaParameters.MarshalToSizedBufferVT(dAtA[:i]) if err != nil { @@ -1346,6 +1452,16 @@ func (m *OperationResult) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } + if m.SchemaWarningsResult != nil { + size, err := m.SchemaWarningsResult.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } if m.FormatSchemaResult != nil { size, err := m.FormatSchemaResult.MarshalToSizedBufferVT(dAtA[:i]) if err != nil { @@ -2112,6 +2228,84 @@ func (m *FormatSchemaResult) MarshalToSizedBufferVT(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *SchemaWarningsParameters) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SchemaWarningsParameters) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SchemaWarningsParameters) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + return len(dAtA) - i, nil +} + +func (m *SchemaWarningsResult) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SchemaWarningsResult) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SchemaWarningsResult) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Warnings) > 0 { + for iNdEx := len(m.Warnings) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Warnings[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *DeveloperRequest) SizeVT() (n int) { if m == nil { return 0 @@ -2202,6 +2396,10 @@ func (m *Operation) SizeVT() (n int) { l = m.FormatSchemaParameters.SizeVT() n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } + if m.SchemaWarningsParameters != nil { + l = m.SchemaWarningsParameters.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } n += len(m.unknownFields) return n } @@ -2251,6 +2449,10 @@ func (m *OperationResult) SizeVT() (n int) { l = m.FormatSchemaResult.SizeVT() n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } + if m.SchemaWarningsResult != nil { + l = m.SchemaWarningsResult.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } n += len(m.unknownFields) return n } @@ -2538,6 +2740,32 @@ func (m *FormatSchemaResult) SizeVT() (n int) { return n } +func (m *SchemaWarningsParameters) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *SchemaWarningsResult) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Warnings) > 0 { + for _, e := range m.Warnings { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + func (m *DeveloperRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3112,6 +3340,42 @@ func (m *Operation) UnmarshalVT(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaWarningsParameters", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SchemaWarningsParameters == nil { + m.SchemaWarningsParameters = &SchemaWarningsParameters{} + } + if err := m.SchemaWarningsParameters.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := protohelpers.Skip(dAtA[iNdEx:]) @@ -3473,6 +3737,42 @@ func (m *OperationResult) UnmarshalVT(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaWarningsResult", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SchemaWarningsResult == nil { + m.SchemaWarningsResult = &SchemaWarningsResult{} + } + if err := m.SchemaWarningsResult.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := protohelpers.Skip(dAtA[iNdEx:]) @@ -5106,3 +5406,139 @@ func (m *FormatSchemaResult) UnmarshalVT(dAtA []byte) error { } return nil } +func (m *SchemaWarningsParameters) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SchemaWarningsParameters: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SchemaWarningsParameters: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SchemaWarningsResult) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SchemaWarningsResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SchemaWarningsResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Warnings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Warnings = append(m.Warnings, &DeveloperWarning{}) + if err := m.Warnings[len(m.Warnings)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/proto/internal/developer/v1/developer.proto b/proto/internal/developer/v1/developer.proto index 844feea61a..1118cab302 100644 --- a/proto/internal/developer/v1/developer.proto +++ b/proto/internal/developer/v1/developer.proto @@ -47,6 +47,7 @@ message Operation { RunAssertionsParameters assertions_parameters = 2; RunValidationParameters validation_parameters = 3; FormatSchemaParameters format_schema_parameters = 4; + SchemaWarningsParameters schema_warnings_parameters = 5; } // OperationsResults holds the results for the operations, indexed by the operation. @@ -60,6 +61,7 @@ message OperationResult { RunAssertionsResult assertions_result = 2; RunValidationResult validation_result = 3; FormatSchemaResult format_schema_result = 4; + SchemaWarningsResult schema_warnings_result = 5; } // DeveloperWarning represents a single warning raised by the development package. @@ -220,3 +222,14 @@ message FormatSchemaParameters { message FormatSchemaResult { string formatted_schema = 1; } + + +// SchemaWarningsParameters are the parameters for a `schemaWarnings` operation. +message SchemaWarningsParameters { + // empty +} + +// SchemaWarningsResult is the result of the `schemaWarnings` operation. +message SchemaWarningsResult { + repeated DeveloperWarning warnings = 1; +}