-
Notifications
You must be signed in to change notification settings - Fork 41
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 data sources protobuf #4962
base: main
Are you sure you want to change the base?
Conversation
626835b
to
46d02b6
Compare
e4e6bc3
to
0d2d439
Compare
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 is looking good! Since this will be a public API, I gave more-detailed feedback than I might otherwise.
proto/minder/v1/minder.proto
Outdated
// type is the data source type | ||
string type = 2 [ | ||
(buf.validate.field).string = { | ||
pattern: "^data-source$", |
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.
Do you want to use in
instead of a pattern here?
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.
Also, do we need this field now, or can we back-fill this later?
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.
(The same could be true for version
, but I'm willing to leave that one in.)
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.
We don't trully need it now, but it does make it work with our parsing primitives.
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.
You mean our YAML-to-foo apply
methods?
Hmm -- I'd almost prefer that those dropped the type
field after parsing, particularly if type
must be set by all clients.
For rule types, Charlie Egan pointed me to Rego metadata yesterday, which feels like it might enhance the rego rule authoring experience by allowing you to use e.g. Rego mode in VSCode.
// name is the name of the data source. | ||
string name = 4 [ | ||
(buf.validate.field).string = { | ||
pattern: "^[A-Za-z][-[:word:]]*$", |
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 assume that names are case-insensitively unique within a project?
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.
How do data source names resolve in descendant projects?
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.
They are case insensitive within a project. I'm thinking they'd have the same mechanics as profiles. That is, they apply and trickle down to subprojects, but are not modifiable by child projects. That allows for child projects to leverage data sources in profiles targetted at those child projects.
I suspect data sources will be more nuanced that this, so we may want to make this configurable in the future.
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.
Not sure if you want to leave a note that these are case-insensitive and must be unique in a project and all parents
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.
You are right, I'll add a comment here.
// headers is a map of headers to send with the request. | ||
google.protobuf.Struct headers = 3; | ||
|
||
oneof body { |
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.
Do you want to do a message-level CEL expression to allow body
only for POST/PUT/PATCH requests?
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.
(Later is a fine answer)
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.
How does one do that?
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.
Note, I don't consider this required, but I'm looking to seed the knowledge of this capability.
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.
That sounds handy, though I'm still not quite sure how to use it. Mind adding this in a subsequent PR?
0d2d439
to
03ad165
Compare
(buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE | ||
]; | ||
|
||
message Fallback { |
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.
question: is embedding these structs a good idea? I remember @evankanderson having concerns on this approach.
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.
We can stop embedding these. But it's highly specific to the Rest driver, and would end up looking like RestFallback
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.
It's ok for me, just raising awareness.
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.
Embedding the structs has a few consequences on the naming:
- In go, the struct will be called
RestDataSource_Fallback
, which is slighly long. We have some worse offenders that take up about half a line... - If we end up with other places where a fallback should be used, we end up needing to duplicate the message, its validation, etc. I think there are a couple places where we ended up making second messages because the first was embedded in an unrelated message.
I don't think it's a major problems, so I didn't bother to raise it here.
Embedding enums inside message definitions or nested message definitions also tends to lead to unreadably-long names in Go.
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, a couple comments, but nothing that needs to block.
I would prefer that the server be able to ignore the type
field rather than requiring all clients to set it to a static value, but I don't feel super strongly.
// name is the name of the data source. | ||
string name = 4 [ | ||
(buf.validate.field).string = { | ||
pattern: "^[A-Za-z][-[:word:]]*$", |
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.
Not sure if you want to leave a note that these are case-insensitive and must be unique in a project and all parents
// headers is a map of headers to send with the request. | ||
google.protobuf.Struct headers = 3; | ||
|
||
oneof body { |
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.
Note, I don't consider this required, but I'm looking to seed the knowledge of this capability.
(buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE | ||
]; | ||
|
||
message Fallback { |
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.
Embedding the structs has a few consequences on the naming:
- In go, the struct will be called
RestDataSource_Fallback
, which is slighly long. We have some worse offenders that take up about half a line... - If we end up with other places where a fallback should be used, we end up needing to duplicate the message, its validation, etc. I think there are a couple places where we ended up making second messages because the first was embedded in an unrelated message.
I don't think it's a major problems, so I didn't bother to raise it here.
Embedding enums inside message definitions or nested message definitions also tends to lead to unreadably-long names in Go.
proto/minder/v1/minder.proto
Outdated
// type is the data source type | ||
string type = 2 [ | ||
(buf.validate.field).string = { | ||
pattern: "^data-source$", |
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.
You mean our YAML-to-foo apply
methods?
Hmm -- I'd almost prefer that those dropped the type
field after parsing, particularly if type
must be set by all clients.
For rule types, Charlie Egan pointed me to Rego metadata yesterday, which feels like it might enhance the rego rule authoring experience by allowing you to use e.g. Rego mode in VSCode.
This adds the protobuf definition of data sources. We'll re-use this protobuf around Minder to create the CRUD interface and reason about the rest of the implementation. Signed-off-by: Juan Antonio Osorio <[email protected]>
Signed-off-by: Juan Antonio Osorio <[email protected]>
03ad165
to
ebc3fa4
Compare
Summary
This adds the protobuf definition of data sources. We'll re-use this
protobuf around Minder to create the CRUD interface and reason about the
rest of the implementation.
This implements https://docs.google.com/document/d/1x8ZXs81e2vB16_vnunV4eRMOklH4Dv9vP30zKYSIKMI/edit?usp=sharing
Change Type
Mark the type of change your PR introduces:
Testing
Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.
Review Checklist: