-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add support for APA template. Part 1 #1882
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
Conversation
@guptasu: Adding do-not-merge/release-note-label-needed because the release note process has not been followed. One of the following labels is required "release-note", "release-note-action-required", or "release-note-none". Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Codecov Report
@@ Coverage Diff @@
## master #1882 +/- ##
=========================================
- Coverage 81.72% 81.2% -0.52%
=========================================
Files 200 187 -13
Lines 20330 18778 -1552
=========================================
- Hits 16615 15249 -1366
+ Misses 3251 3104 -147
+ Partials 464 425 -39
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1882 +/- ##
==========================================
+ Coverage 81.16% 82.26% +1.09%
==========================================
Files 190 194 +4
Lines 19430 20160 +730
==========================================
+ Hits 15771 16584 +813
+ Misses 3197 3113 -84
- Partials 462 463 +1
Continue to review full report at Codecov.
|
LGTM |
@@ -27,6 +27,8 @@ import ( | |||
"github.com/gogo/protobuf/protoc-gen-gogo/descriptor" | |||
"golang.org/x/tools/imports" | |||
|
|||
"regexp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a linter error, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. that is what make fmt did for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I manually moved it up now.
} | ||
return "string" | ||
func trimPackageName(fullName string, pkgName string) string { | ||
re := regexp.MustCompile(`(?i)` + pkgName + "\\.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we compile this regexp in an init() or something, instead of here (i feel like MustCompile
is meant for globals)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D
} | ||
|
||
func (g *Generator) getAugmentedProtoContent(model *modelgen.Model) ([]byte, error) { | ||
imports := make([]string, 0) | ||
|
||
var stringify func(protoType modelgen.TypeInfo) string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth extracting signature to a non-exported type (type stringifyFn func(modelgen.TypeInfo) string
) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D
@@ -6,7 +6,7 @@ syntax = "proto3"; | |||
/* | |||
Additional overview of what metric is etc.. | |||
*/ | |||
package istio.mixer.adapter.metric; | |||
package istio.mixer.adapter.metricEntry; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to include these changes in this PR ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR, I have fixed a bug where if the name is camelCase and it is referenced using full name inside the proto, things were not compiling in the generated code. This change tests that broken functionality. I can take it out if you think it should be its own PR.
This PR adds the artifacts that we generate for APA templates, example * Template message * Output message * Handler interface * HandlerBuilder interface Note: * Note the attribute_binding field generated inside the InstanceParam message. It is a map<string, string>. Operators will use this field to provide the mapping between the new attribute and the expression using the $out.<fieldName> style of expressions. * In APA we do not allow ValueTypes because it does not make sense for APA to request for, or return, a dynamic data. * Therefore, in APA the HandlerBuilder does not contain Set*Type methods. Instead HandlerBuilder is a simple passthrough to adapter.HandlerBuilder (which contains the Build method) Next PR will contain the bootstraping code that will parse the operator config and generate instances, read the response from adapter and fill in the new attribute values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed comments from @douglas-reid
PTAL.
@@ -27,6 +27,8 @@ import ( | |||
"github.com/gogo/protobuf/protoc-gen-gogo/descriptor" | |||
"golang.org/x/tools/imports" | |||
|
|||
"regexp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. that is what make fmt did for me.
@@ -27,6 +27,8 @@ import ( | |||
"github.com/gogo/protobuf/protoc-gen-gogo/descriptor" | |||
"golang.org/x/tools/imports" | |||
|
|||
"regexp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I manually moved it up now.
} | ||
return "string" | ||
func trimPackageName(fullName string, pkgName string) string { | ||
re := regexp.MustCompile(`(?i)` + pkgName + "\\.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D
} | ||
|
||
func (g *Generator) getAugmentedProtoContent(model *modelgen.Model) ([]byte, error) { | ||
imports := make([]string, 0) | ||
|
||
var stringify func(protoType modelgen.TypeInfo) string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D
@@ -6,7 +6,7 @@ syntax = "proto3"; | |||
/* | |||
Additional overview of what metric is etc.. | |||
*/ | |||
package istio.mixer.adapter.metric; | |||
package istio.mixer.adapter.metricEntry; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR, I have fixed a bug where if the name is camelCase and it is referenced using full name inside the proto, things were not compiling in the generated code. This change tests that broken functionality. I can take it out if you think it should be its own PR.
@douglas-reid @geeknoid friendly ping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: douglas-reid The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. |
What this PR does / why we need it:
This PR adds the artifacts that we generate for APA templates, example
Note:
Next PR will contain the bootstraping code that will parse the operator config and generate instances, read the response from adapter and fill in the new attribute values.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
Release note: