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

feat: add ability to retrieve policy resources by id or name #1901

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

strantalis
Copy link
Member

@strantalis strantalis commented Feb 3, 2025

Proposed Changes

Allowing us to make Get request by policy resource names will open up the doors to using friendly names versus uuid in the cli. This will help with the new key mapping support in the cli.

Copilot Summary

This pull request includes several changes to the documentation and codebase to support new query parameters and mark certain fields as deprecated. The most important changes are grouped by theme below:

Documentation Updates:

Code Updates:

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

@strantalis strantalis marked this pull request as ready for review February 3, 2025 21:00
@strantalis strantalis requested review from a team as code owners February 3, 2025 21:00
// string kas_name = 2;
// // Optional
// string kas_uri = 3;
oneof identifier {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not concerned about these breaking changes as we haven't released this new functionality yet.

Comment on lines +101 to +102
if req.Msg.GetId() != "" { //nolint:staticcheck // Id can still be used until removed
identifier = req.Msg.GetId() //nolint:staticcheck // Id can still be used until removed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we need this if it's only running in the platform. Is this related to ConnectRPC and legacy gRPC requests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this is because I moved the fields to a oneof in the proto definition. So the id field would be removed in a later release.

The intention of the oneof was so a user could only set either x_id or fqn/name. But after syncing with @jakedoublev it might not be worth the extra effort to move to the oneof.

@@ -86,10 +86,17 @@ message ListAttributesResponse {
}

message GetAttributeRequest {
// Required
// Deprecated
string id = 1 [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to discuss this breaking change and the pros/cons. An alternative could be allowing either id or fqn without oneof, then logically preferring id in the event both were provided.

@@ -412,6 +428,14 @@ func TestGetAttributeValueRequest(t *testing.T) {
}
err = getValidator().Validate(req)
require.NoError(t, err)

req = &attributes.GetAttributeValueRequest{
Identifier: &attributes.GetAttributeValueRequest_ValueId{
Copy link
Contributor

@jakedoublev jakedoublev Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do an FQN test here across these proto test suites?

case string:
av, err = c.Queries.GetAttributeValueById(ctx, i)
default:
// Hopefully this will never happen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we keep a switch for the oneof / deprecation, can we defined a typed error for this then wrap it with the unknown type?

return nil, fmt.Errorf("type: %T, %w", ErrTypeIdentifierInvalid")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants