Skip to content

Add proto for analysis messages #1179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Makefile.core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ gen: \
generate-rbac \
generate-authn \
generate-security \
generate-analysis \
generate-envoy \
generate-policy \
generate-annotations \
Expand Down Expand Up @@ -396,6 +397,28 @@ generate-security: $(security_v1beta1_pb_gos) $(security_v1beta1_pb_docs) $(secu
clean-security:
@rm -fr $(security_v1beta1_pb_gos) $(security_v1beta1_pb_docs) $(security_v1beta1_pb_pythons) $(security_v1beta1_k8s_gos)

#####################
# analysis/...
#####################

analysis_v1alpha1_path := analysis/v1alpha1
analysis_v1alpha1_protos := $(wildcard $(analysis_v1alpha1_path)/*.proto)
analysis_v1alpha1_pb_gos := $(analysis_v1alpha1_protos:.proto=.pb.go)
analysis_v1alpha1_pb_pythons := $(patsubst $(analysis_v1alpha1_path)/%.proto,$(python_output_path)/$(analysis_v1alpha1_path)/%_pb2.py,$(analysis_v1alpha1_protos))
analysis_v1alpha1_pb_docs := $(analysis_v1alpha1_protos:.proto=.pb.html)
analysis_v1alpha1_openapi := $(analysis_v1alpha1_protos:.proto=.gen.json)


$(analysis_v1alpha1_pb_gos) $(analysis_v1alpha1_pb_docs) $(analysis_v1alpha1_pb_pythons): $(analysis_v1alpha1_protos)
@$(protolock) status
@$(protoc) $(gogofast_plugin) $(protoc_gen_docs_plugin_per_file)$(analysis_v1alpha1_path) $(protoc_gen_python_plugin) $^
@cp -r /tmp/istio.io/api/analysis/* analysis

generate-analysis: $(analysis_v1alpha1_pb_gos) $(analysis_v1alpha1_pb_docs) $(analysis_v1alpha1_pb_pythons)

clean-analysis:
@rm -fr $(analysis_v1alpha1_pb_gos) $(analysis_v1alpha1_pb_docs) $(analysis_v1alpha1_pb_pythons)

#####################
# envoy/...
#####################
Expand Down Expand Up @@ -471,6 +494,7 @@ all_protos := \
$(rbac_v1alpha1_protos) \
$(authn_v1alpha1_protos) \
$(security_v1beta1_protos) \
$(analysis_v1alpha1_protos) \
$(type_v1beta1_protos)

all_openapi := \
Expand All @@ -486,6 +510,7 @@ all_openapi := \
$(rbac_v1alpha1_openapi) \
$(authn_v1alpha1_openapi) \
$(security_v1beta1_openapi) \
$(analysis_v1alpha1_openapi) \
$(type_v1beta1_openapi)

all_openapi_crd := kubernetes/customresourcedefinitions.gen.yaml
Expand Down Expand Up @@ -525,6 +550,7 @@ clean: \
clean-annotations \
clean-openapi-schema \
clean-security \
generate-analysis \
clean-type \
clean-openapi-crd

Expand Down
130 changes: 130 additions & 0 deletions analysis/v1alpha1/message.gen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"openapi": "3.0.0",
"info": {
"title": "Describes the structure of messages generated by Istio analyzers.",
"version": "v1alpha1"
},
"components": {
"schemas": {
"istio.analysis.v1alpha1.AnalysisMessageBase": {
"description": "AnalysisMessageBase describes some common information that is needed for all messages. All information should be static with respect to the error code.",
"type": "object",
"properties": {
"type": {
"$ref": "#/components/schemas/istio.analysis.v1alpha1.AnalysisMessageBase.Type"
},
"level": {
"$ref": "#/components/schemas/istio.analysis.v1alpha1.AnalysisMessageBase.Level"
},
"documentationUrl": {
"description": "A url pointing to the Istio documentation for this specific error type. Should be of the form `^http(s)?://(preliminary\\.)?istio.io/docs/reference/config/analysis/` Required.",
"type": "string",
"format": "string"
}
}
},
"istio.analysis.v1alpha1.AnalysisMessageBase.Type": {
"description": "A unique identifier for the type of message. Name is intended to be human-readable, code is intended to be machine readable. There should be a one-to-one mapping between name and code. (i.e. do not re-use names or codes between message types.)",
"type": "object",
"properties": {
"name": {
"description": "A human-readable name for the message type. e.g. \"InternalError\", \"PodMissingProxy\". This should be the same for all messages of the same type. Required.",
"type": "string",
"format": "string"
},
"code": {
"description": "A 7 character code matching `^IST[0-9]{4}$` intended to uniquely identify the message type. (e.g. \"IST0001\" is mapped to the \"InternalError\" message type.) 0000-0100 are reserved. Required.",
"type": "string",
"format": "string"
}
}
},
"istio.analysis.v1alpha1.AnalysisMessageBase.Level": {
"description": "The values here are chosen so that more severe messages get sorted higher, as well as leaving space in between to add more later",
"type": "string",
"enum": [
"UNKNOWN",
"ERROR",
"WARNING",
"INFO"
]
},
"istio.analysis.v1alpha1.AnalysisMessageWeakSchema": {
"description": "AnalysisMessageWeakSchema is the set of information that's needed to define a weakly-typed schema. The purpose of this proto is to provide a mechanism for validating istio/istio/galley/pkg/config/analysis/msg/messages.yaml to make sure that we don't allow committing underspecified types.",
"type": "object",
"properties": {
"messageBase": {
"$ref": "#/components/schemas/istio.analysis.v1alpha1.AnalysisMessageBase"
},
"description": {
"description": "A human readable description of what the error means. Required.",
"type": "string",
"format": "string"
},
"template": {
"description": "A go-style template string (https://golang.org/pkg/fmt/#hdr-Printing) defining how to combine the args for a particular message into a log line. Required.",
"type": "string",
"format": "string"
},
"args": {
"description": "A description of the arguments for a particular message type",
"type": "array",
"items": {
"$ref": "#/components/schemas/istio.analysis.v1alpha1.AnalysisMessageWeakSchema.ArgType"
}
}
}
},
"istio.analysis.v1alpha1.AnalysisMessageWeakSchema.ArgType": {
"type": "object",
"properties": {
"name": {
"description": "Required",
"type": "string",
"format": "string"
},
"goType": {
"description": "Required. Should be a golang type, used in code generation. Ideally this will change to a less language-pinned type before this gets out of alpha, but for compatibility with current istio/istio code it's go_type for now.",
"type": "string",
"format": "string"
}
}
},
"istio.analysis.v1alpha1.GenericAnalysisMessage": {
"description": "GenericAnalysisMessage is an instance of an AnalysisMessage defined by a schema, whose metaschema is AnalysisMessageWeakSchema. (Names are hard.) Code should be able to perform validation of arguments as needed by using the message type information to look at the AnalysisMessageWeakSchema and examine the list of args at runtime. Developers can also create stronger-typed versions of GenericAnalysisMessage for well-known and stable message types.",
"type": "object",
"properties": {
"messageBase": {
"$ref": "#/components/schemas/istio.analysis.v1alpha1.AnalysisMessageBase"
},
"args": {
"description": "Any message-type specific arguments that need to get codified. Optional.",
"type": "object"
},
"resourcePaths": {
"description": "A list of strings specifying the resource identifiers that were the cause of message generation. A \"path\" here is a (NAMESPACE\\/)?RESOURCETYPE/NAME tuple that uniquely identifies a particular resource. There doesn't seem to be a single concept for this, but this is intuitively taken from https://kubernetes.io/docs/reference/using-api/api-concepts/#standard-api-terminology At least one is required.",
"type": "array",
"items": {
"type": "string",
"format": "string"
}
}
}
},
"istio.analysis.v1alpha1.InternalErrorAnalysisMessage": {
"description": "InternalErrorAnalysisMessage is a strongly-typed message representing some error in Istio code that prevented us from performing analysis at all.",
"type": "object",
"properties": {
"messageBase": {
"$ref": "#/components/schemas/istio.analysis.v1alpha1.AnalysisMessageBase"
},
"detail": {
"description": "Any detail regarding specifics of the error. Should be human-readable.",
"type": "string",
"format": "string"
}
}
}
}
}
}
Loading