Skip to content
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

Add protoc-gen-go-deepcopy plugin support to buf generate #331

Merged
merged 4 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
84 changes: 48 additions & 36 deletions api/aperture/common/labelmatcher/v1/labelmatcher.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,29 @@ message LabelMatcher {
// Label selector requirement which is a selector that contains values, a key, and an operator that relates the key and values.
message K8sLabelMatcherRequirement {
// Label key that the selector applies to.
string key = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
string key = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
}
}
}
}]; // @gotags: validate:"required"
]; // @gotags: validate:"required"

// Logical operator which represents a key's relationship to a set of values.
// Valid operators are In, NotIn, Exists and DoesNotExist.
string operator = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "oneof=In NotIn Exists DoesNotExists"
string operator = 2 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "oneof=In NotIn Exists DoesNotExists"
}
}
}
}]; // @gotags: validate:"oneof=In NotIn Exists DoesNotExists"
]; // @gotags: validate:"oneof=In NotIn Exists DoesNotExists"

// An array of string values that relates to the key by an operator.
// If the operator is In or NotIn, the values array must be non-empty.
Expand Down Expand Up @@ -92,14 +96,16 @@ message MatchExpression {
List any = 3;

// The expression is true when label with given name exists.
string label_exists = 4 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
string label_exists = 4 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
}
}
}
}]; // @gotags: validate:"required"
]; // @gotags: validate:"required"

// The expression is true when label value equals given value.
EqualsMatchExpression label_equals = 5;
Expand All @@ -112,14 +118,16 @@ message MatchExpression {
// Label selector expression of the equal form "label == value".
message EqualsMatchExpression {
// Name of the label to equal match the value.
string label = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
string label = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
}
}
}
}]; // @gotags: validate:"required"
]; // @gotags: validate:"required"

// Exact value that the label should be equal to.
string value = 2;
Expand All @@ -128,23 +136,27 @@ message EqualsMatchExpression {
// Label selector expression of the matches form "label matches regex".
message MatchesMatchExpression {
// Name of the label to match the regular expression.
string label = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
string label = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
}
}
}
}]; // @gotags: validate:"required"
]; // @gotags: validate:"required"

// Regular expression that should match the label value.
// It uses [golang's regular expression syntax](https://github.com/google/re2/wiki/Syntax).
string regex = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
string regex = 2 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
}
}
}
}]; // @gotags: validate:"required"
]; // @gotags: validate:"required"
}
56 changes: 32 additions & 24 deletions api/aperture/common/selector/v1/selector.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ import "protoc-gen-openapiv2/options/annotations.proto";
// ```
message Selector {
// Describes where this selector applies to.
string agent_group = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-default"
value: {
string_value: "default"
string agent_group = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-default"
value: {
string_value: "default"
}
}
}
}]; // @gotags: default:"default"
]; // @gotags: default:"default"

// The service (name) of the entities.
// In k8s, this is the FQDN of the Service object.
Expand All @@ -43,14 +45,16 @@ message Selector {
string service = 2;

// Describes control point within the entity where the policy should apply to.
ControlPoint control_point = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
ControlPoint control_point = 3 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
}
}
}
}]; // @gotags: validate:"required"
]; // @gotags: validate:"required"

// Label matcher allows to add _additional_ condition on
// [flow labels](/concepts/flow-control/label/label.md)
Expand Down Expand Up @@ -78,28 +82,32 @@ message ControlPoint {
// Feature corresponds to a block of code that can be "switched off" which usually is a "named opentelemetry's Span".
//
// Note: Flowcontrol only.
string feature = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
string feature = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
}
}
}
}]; //@gotags: validate:"required"
]; //@gotags: validate:"required"

// Type of traffic service, either "ingress" or "egress".
// Apply the policy to the whole incoming/outgoing traffic of a service.
// Usually powered by integration with a proxy (like envoy) or a web framework.
//
// * Flowcontrol: Blockable atom here is a single HTTP-transaction.
// * Classification: Apply the classification rules to every incoming/outgoing request and attach the resulting flow labels to baggage and telemetry.
string traffic = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required,oneof=ingress egress"
string traffic = 2 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required,oneof=ingress egress"
}
}
}
}]; // @gotags: validate:"required,oneof=ingress egress"
]; // @gotags: validate:"required,oneof=ingress egress"
}
}
42 changes: 24 additions & 18 deletions api/aperture/policy/language/v1/classifier.proto
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,16 @@ message Extractor {
// ```
message JSONExtractor {
// Attribute path pointing to some strings - eg. "request.http.body".
string from = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
string from = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
}
}
}
}]; //@gotags: validate:"required"
]; //@gotags: validate:"required"

// Json pointer represents a parsed json pointer which allows to select a specified field from the json payload.
//
Expand All @@ -189,14 +191,16 @@ message JSONExtractor {
// ```
message AddressExtractor {
// Attribute path pointing to some string - eg. "source.address".
string from = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
string from = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
}
}
}
}]; //@gotags: validate:"required"
]; //@gotags: validate:"required"
}

// Parse the attribute as JWT and read the payload
Expand All @@ -213,14 +217,16 @@ message AddressExtractor {
// ```
message JWTExtractor {
// Jwt token can be pulled from any input attribute, but most likely you'd want to use "request.http.bearer".
string from = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
string from = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-validate"
value: {
string_value: "required"
}
}
}
}]; //@gotags: validate:"required"
]; //@gotags: validate:"required"

// Json pointer allowing to select a specified field from the json payload.
//
Expand Down
14 changes: 8 additions & 6 deletions api/aperture/policy/language/v1/fluxmeter.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ message FluxMeter {
common.selector.v1.Selector selector = 1;

// Latency histogram buckets (in ms) for this FluxMeter.
repeated double histogram_buckets = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-default"
value: {
string_value: "[5.0,10.0,25.0,50.0,100.0,250.0,500.0,1000.0,2500.0,5000.0,10000.0]"
repeated double histogram_buckets = 2 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
extensions: {
key: "x-go-default"
value: {
string_value: "[5.0,10.0,25.0,50.0,100.0,250.0,500.0,1000.0,2500.0,5000.0,10000.0]"
}
}
}
}]; // @gotags: default:"[5.0,10.0,25.0,50.0,100.0,250.0,500.0,1000.0,2500.0,5000.0,10000.0]"
]; // @gotags: default:"[5.0,10.0,25.0,50.0,100.0,250.0,500.0,1000.0,2500.0,5000.0,10000.0]"
}
Loading