|
| 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 | +import "google/protobuf/struct.proto"; |
| 26 | + |
| 27 | +option go_package="istio.io/api/analysis/v1alpha1"; |
| 28 | + |
| 29 | +// There are four messages described in this file. One of them is a struct |
| 30 | +// common to the other three: AnalysisMessageBase. Using this, we can construct |
| 31 | +// one of three different structures. |
| 32 | +// One is the AnalysisMessageWeakSchema, a YAML only description of a message |
| 33 | +// type intended to be used where strong API guarantees are not necessary. |
| 34 | +// One is the GenericAnalysisMessage, which is the struct that we guarantee that |
| 35 | +// you can deserialize any analysis message to. Istio internally uses generated |
| 36 | +// golang types from messages.yaml, so in order to reduce friction in creating |
| 37 | +// new analyzers we offer a path that doesn't require committing to two |
| 38 | +// different repos and solidifying the interface. |
| 39 | +// Finally, we can create a new proto message of a specific message type and |
| 40 | +// commit it to istio/api when we need a strong guarantee for cross platform |
| 41 | +// communication. |
| 42 | + |
| 43 | +// AnalysisMessageBase describes some common information that is needed for all |
| 44 | +// messages. All information should be static with respect to the error code. |
| 45 | +message AnalysisMessageBase { |
| 46 | + // A human-readable name for the message type. e.g. "InternalError", |
| 47 | + // "PodMissingProxy". This should be the same for all messages of the same type. |
| 48 | + // Required. |
| 49 | + string name = 1; |
| 50 | + |
| 51 | + // A 7 character code matching `^IST[0-9]{4}$` intended to uniquely identify |
| 52 | + // the message type. (e.g. "IST0001" is mapped to the "InternalError" message |
| 53 | + // type.) 0000-0100 are reserved. Required. |
| 54 | + string code = 2; |
| 55 | + |
| 56 | + // The values here are chosen so that more severe messages get sorted higher, |
| 57 | + // as well as leaving space in between to add more later |
| 58 | + enum Level { |
| 59 | + UNKNOWN = 0; // invalid, but included for proto compatibility for 0 values |
| 60 | + ERROR = 3; |
| 61 | + WARNING = 8; |
| 62 | + INFO = 12; |
| 63 | + } |
| 64 | + |
| 65 | + // Represents how severe a message is. Required. |
| 66 | + Level level = 3; |
| 67 | + |
| 68 | + // A url pointing to the Istio documentation for this specific error type. |
| 69 | + // Should be of the form |
| 70 | + // `^http(s)?://(preliminary\.)?istio.io/docs/reference/config/analysis/` |
| 71 | + // Required. |
| 72 | + string documentation_url = 4; |
| 73 | + |
| 74 | +} |
| 75 | + |
| 76 | +// AnalysisMessageWeakSchema is the set of information that's needed to define a |
| 77 | +// weakly-typed schema. The purpose of this proto is to provide a mechanism for |
| 78 | +// validating istio/istio/galley/pkg/config/analysis/msg/messages.yaml to make |
| 79 | +// sure that we don't allow committing underspecified types. |
| 80 | +message AnalysisMessageWeakSchema { |
| 81 | + // Required |
| 82 | + AnalysisMessageBase message_base = 1; |
| 83 | + |
| 84 | + // A human readable description of what the error means. Required. |
| 85 | + string description = 2; |
| 86 | + |
| 87 | + // A go-style template string defining how to combine the args for a |
| 88 | + // particular message into a log line. Required. |
| 89 | + string template = 3; |
| 90 | + |
| 91 | + message ArgType { |
| 92 | + // Required |
| 93 | + string name = 1; |
| 94 | + // Required. Should be a golang type, used in code generation |
| 95 | + string go_type = 2; |
| 96 | + } |
| 97 | + |
| 98 | + // A description of the arguments for a particular message type |
| 99 | + repeated ArgType args = 4; |
| 100 | +} |
| 101 | + |
| 102 | +// GenericAnalysisMessage is an instance of an AnalysisMessage defined by a |
| 103 | +// schema, whose metaschema is AnalysisMessageWeakSchema. (Names are hard.) Code |
| 104 | +// should be able to perform validation of arguments as needed by using the |
| 105 | +// message type information to look at the AnalysisMessageWeakSchema and examine the |
| 106 | +// list of args at runtime. Developers can also create stronger-typed versions |
| 107 | +// of GenericAnalysisMessage for well-known and stable message types. |
| 108 | +message GenericAnalysisMessage { |
| 109 | + // Required |
| 110 | + AnalysisMessageBase message_base = 1; |
| 111 | + |
| 112 | + // Any message-type specific arguments that need to get codified. Optional. |
| 113 | + google.protobuf.Struct args = 2; |
| 114 | + |
| 115 | + // A list of strings specifying the path for resources which were the cause of |
| 116 | + // message generation. At least one is required. |
| 117 | + repeated string resource_paths = 3; |
| 118 | +} |
| 119 | + |
| 120 | +// InternalErrorAnalysisMessage is a strongly-typed message representing some |
| 121 | +// error in Istio code that prevented us from performing analysis at all. |
| 122 | +message InternalErrorAnalysisMessage { |
| 123 | + // Required |
| 124 | + AnalysisMessageBase message_base = 1; |
| 125 | + |
| 126 | + // Any detail regarding specifics of the error. Should be human-readable. |
| 127 | + string detail = 2; |
| 128 | +} |
0 commit comments