Skip to content

Commit 5d4f7ae

Browse files
author
Clayton Pence
committed
Add proto for analysis messages
1 parent f0abe0c commit 5d4f7ae

File tree

2 files changed

+258
-0
lines changed

2 files changed

+258
-0
lines changed

analysis/v1alpha1/message.proto

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// Copyright 2019 Istio Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
// $title: Analysis Messages
18+
// $description: Describes the structure of messages generated by Istio analyzers.
19+
// $location: https://istio.io/docs/reference/config/istio.analysis.v1alpha1.html
20+
// $weight: 20
21+
22+
// Describes the structure of messages generated by Istio analyzers.
23+
package istio.analysis.v1alpha1;
24+
25+
option go_package="istio.io/api/analysis/v1alpha1";
26+
27+
// AnalysisMessageType describes some common information that is needed for both
28+
// creating a message schema or a reified message. Weakly typed message schemas
29+
// are defined in istio/istio/galley/pkg/config/analysis/msg/messages.yaml
30+
message AnalysisMessageType {
31+
// A human-readable name for the message type. e.g. "InternalError",
32+
// "Deprecated". This should be the same for all messages of the same type.
33+
// Required.
34+
string name = 1;
35+
36+
// A 7 character code matching `^IST[0-9]{4}$` intended to uniquely identify
37+
// the message type. (e.g. "IST0001" is mapped to the "InternalError" message
38+
// type.) 0000-0100 are reserved. Required.
39+
string code = 2;
40+
41+
// The values here are chosen so that more severe messages get sorted higher,
42+
// as well as leaving space in between to add more later
43+
enum Level {
44+
UNKNOWN = 0; // invalid, but included for proto compatibility for 0 values
45+
ERROR = 3;
46+
WARNING = 8;
47+
INFO = 12;
48+
}
49+
50+
// Represents how severe a message is. Required.
51+
Level level = 3;
52+
53+
enum MessageTypeVersion {
54+
V1ALPHA1 = 0;
55+
}
56+
57+
// The version of this proto schema that the message was build with. Required.
58+
MessageTypeVersion base_message_schema = 4;
59+
60+
// A url pointing to the Istio documentation for this specific error type.
61+
// Should be of the form
62+
// `^http(s)?://(preliminary\.)?istio.io/docs/reference/config/analysis/`
63+
// Required.
64+
string documentation_url = 5;
65+
66+
}
67+
68+
// AnalysisMessageSchema is the set of information that's needed to define a
69+
// weakly-typed schema. The purpose of this proto is to provide a mechanism for
70+
// validating istio/istio/galley/pkg/config/analysis/msg/messages.yaml to make
71+
// sure that we don't allow committing underspecified types.
72+
message AnalysisMessageSchema {
73+
// Required
74+
AnalysisMessageType type_info = 1;
75+
76+
// A human readable description of what the error means. Required when
77+
// defining a schema in YAML.
78+
string description = 2;
79+
80+
// A go-style template string defining how to combine the args for a
81+
// particular message into a log line. Required when defining a schema in
82+
// YAML.
83+
string template = 3;
84+
85+
message ArgType {
86+
// Required
87+
string name = 1;
88+
// Required. Should be an OpenAPI data type:
89+
// https://swagger.io/docs/specification/data-models/data-types/
90+
string type = 2;
91+
}
92+
93+
// A description of the arguments for a particular message type
94+
repeated ArgType args = 4;
95+
}
96+
97+
// GenericAnalysisMessage is an instance of an AnalysisMessage defined by a
98+
// schema, whose metaschema is AnalysisMessageSchema. (Names are hard.) Code
99+
// should be able to perform validation of arguments as needed by using the
100+
// message type information to look at the AnalysisMessageSchema and examine the
101+
// list of args at runtime. Developers can also create stronger-typed versions
102+
// of GenericAnalysisMessage for well-known and stable message types.
103+
message GenericAnalysisMessage {
104+
// Required
105+
AnalysisMessageType type_info = 1;
106+
107+
// Any message-type specific arguments that need to get codified. Optional.
108+
map<string, string> args = 2;
109+
110+
// A list of strings specifying the path for resources which were the cause of
111+
// message generation. At least one is required.
112+
repeated string resource_paths = 3;
113+
}

proto.lock

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,150 @@
11
{
22
"definitions": [
3+
{
4+
"protopath": "analysis:/:v1alpha1:/:message.proto",
5+
"def": {
6+
"enums": [
7+
{
8+
"name": "AnalysisMessageType.Level",
9+
"enum_fields": [
10+
{
11+
"name": "UNKNOWN"
12+
},
13+
{
14+
"name": "ERROR",
15+
"integer": 3
16+
},
17+
{
18+
"name": "WARNING",
19+
"integer": 8
20+
},
21+
{
22+
"name": "INFO",
23+
"integer": 12
24+
}
25+
]
26+
},
27+
{
28+
"name": "AnalysisMessageType.MessageTypeVersion",
29+
"enum_fields": [
30+
{
31+
"name": "V1ALPHA1"
32+
}
33+
]
34+
}
35+
],
36+
"messages": [
37+
{
38+
"name": "AnalysisMessageType",
39+
"fields": [
40+
{
41+
"id": 1,
42+
"name": "name",
43+
"type": "string"
44+
},
45+
{
46+
"id": 2,
47+
"name": "code",
48+
"type": "string"
49+
},
50+
{
51+
"id": 3,
52+
"name": "level",
53+
"type": "Level"
54+
},
55+
{
56+
"id": 4,
57+
"name": "base_message_schema",
58+
"type": "MessageTypeVersion"
59+
},
60+
{
61+
"id": 5,
62+
"name": "documentation_url",
63+
"type": "string"
64+
}
65+
]
66+
},
67+
{
68+
"name": "AnalysisMessageSchema",
69+
"fields": [
70+
{
71+
"id": 1,
72+
"name": "type_info",
73+
"type": "AnalysisMessageType"
74+
},
75+
{
76+
"id": 2,
77+
"name": "description",
78+
"type": "string"
79+
},
80+
{
81+
"id": 3,
82+
"name": "template",
83+
"type": "string"
84+
},
85+
{
86+
"id": 4,
87+
"name": "args",
88+
"type": "ArgType",
89+
"is_repeated": true
90+
}
91+
],
92+
"messages": [
93+
{
94+
"name": "ArgType",
95+
"fields": [
96+
{
97+
"id": 1,
98+
"name": "name",
99+
"type": "string"
100+
},
101+
{
102+
"id": 2,
103+
"name": "type",
104+
"type": "string"
105+
}
106+
]
107+
}
108+
]
109+
},
110+
{
111+
"name": "GenericAnalysisMessage",
112+
"fields": [
113+
{
114+
"id": 1,
115+
"name": "type_info",
116+
"type": "AnalysisMessageType"
117+
},
118+
{
119+
"id": 3,
120+
"name": "resource_paths",
121+
"type": "string",
122+
"is_repeated": true
123+
}
124+
],
125+
"maps": [
126+
{
127+
"key_type": "string",
128+
"field": {
129+
"id": 2,
130+
"name": "args",
131+
"type": "string"
132+
}
133+
}
134+
]
135+
}
136+
],
137+
"package": {
138+
"name": "istio.analysis.v1alpha1"
139+
},
140+
"options": [
141+
{
142+
"name": "go_package",
143+
"value": "istio.io/api/analysis/v1alpha1"
144+
}
145+
]
146+
}
147+
},
3148
{
4149
"protopath": "authentication:/:v1alpha1:/:policy.proto",
5150
"def": {

0 commit comments

Comments
 (0)