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

Extend access list event types to allow printing title #47704

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kopiczko
Copy link
Contributor

@kopiczko kopiczko commented Oct 18, 2024

Title is the human-friendly field while the name is basically an ID. To improve UX we want to print the title in the audit log.

@kopiczko kopiczko added the no-changelog Indicates that a PR does not require a changelog entry label Oct 18, 2024
@kopiczko kopiczko force-pushed the kopiczko/access-list-events-ux-improvements branch from 6567b53 to 0c3bf52 Compare October 18, 2024 15:12
Comment on lines +6236 to +6301
// AccessList is common access list metadata.
AccessListMetadata AccessList = 4 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't love it's after the Status field, but that way it's backward compatible. (this isn't the only thing I introduced here I don't love about the field ordering)

@kopiczko kopiczko force-pushed the kopiczko/access-list-events-ux-improvements branch 3 times, most recently from d312ac6 to 2382a0e Compare October 18, 2024 16:43
@kopiczko kopiczko marked this pull request as ready for review October 18, 2024 17:16
@github-actions github-actions bot requested review from avatus and kiosion October 18, 2024 17:16
@kopiczko kopiczko requested review from tcsc, flyinghermit and smallinsky and removed request for avatus and kiosion October 18, 2024 17:16
@kopiczko kopiczko requested review from avatus and kiosion October 18, 2024 17:19
// AccessListMemberMetadata contains common metadata for access list member resource events.
message AccessListMemberMetadata {
// AccessListName is the name of the access list the members are being added to or removed from.
string AccessListName = 1 [(gogoproto.jsontag) = "access_list_name,omitempty"];

// Members are all members affected by the access list membership change.
repeated AccessListMember Members = 2 [(gogoproto.jsontag) = "members,omitempty"];

// AccessListTitle is a plain text short description of the access list the members are being added to or removed from.
string AccessListTitle = 3 [(gogoproto.jsontag) = "access_list_title,omitempty"];
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's a bit strange to include AccessListTitle inline in all these events. You already have AccessListMetadata defined above - can we instead just include that metadata object in all relevant events? Then it will be easier to extend do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked at it differently. I thought all AccessList{verb} events would have AccessListMetadata AccessList field and all AccessListMember{verb} events AccessListMemberMetadata AccessListMember field.

I can add AccessListMetadata AccessList to AccessListMember{verb} if you prefer. Please let me know what you think.

@@ -310,6 +319,9 @@ message AccessListReviewMetadata {

// RemovedMembers are the members that were removed as part of the review.
repeated string RemovedMembers = 6 [(gogoproto.jsontag) = "removed_members,omitempty"];

// AccessListTitle is the title of the reviewed access list.
string AccessListTitle = 7 [(gogoproto.jsontag) = "access_list_title,omitempty"];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as above - I don't think this should be included here, instead include AccessListMetadata where needed.

Comment on lines +255 to +257
// AccessListTitle is a plain text short description of the access list.
string AccessListTitle = 1 [(gogoproto.jsontag) = "access_list_title,omitempty"];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: "AccessList" prefix is redundant here.

Suggested change
// AccessListTitle is a plain text short description of the access list.
string AccessListTitle = 1 [(gogoproto.jsontag) = "access_list_title,omitempty"];
// Title is a plain text short description of the access list.
string Title = 1 [(gogoproto.jsontag) = "access_list_title,omitempty"];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem with that is that the generated types have embedded fields, e.g.:

// AccessListUpdate is emitted when an access list is updated.
type AccessListUpdate struct {
	// Metadata is common event metadata
	Metadata `protobuf:"bytes,1,opt,name=Metadata,proto3,embedded=Metadata" json:""`
	// Resource is common resource event metadata
	ResourceMetadata `protobuf:"bytes,2,opt,name=Resource,proto3,embedded=Resource" json:""`
	// Status indicates whether the resource operation was successful.
	Status `protobuf:"bytes,3,opt,name=Status,proto3,embedded=Status" json:""`
	// AccessList is common access list metadata.
	AccessListMetadata   `protobuf:"bytes,4,opt,name=AccessList,proto3,embedded=AccessList" json:""`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

so it is possible to:

var accessListUpdate AccessListUpdate
accessListUpdate.AccessListTitle // vs accessListUpdate.Title 

Again, please let me know if you'd still like to change it.

@kopiczko kopiczko requested a review from r0mant October 25, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v16 backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/sm ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants