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

Order by name first and by id by default #337

Merged
merged 4 commits into from
Apr 26, 2021
Merged

Order by name first and by id by default #337

merged 4 commits into from
Apr 26, 2021

Conversation

mmorel-35
Copy link
Contributor

No description provided.

@mmorel-35 mmorel-35 requested a review from a team as a code owner April 22, 2021 06:25
Copy link
Contributor

@mflendrich mflendrich left a comment

Choose a reason for hiding this comment

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

The change looks good, but two more things are needed:

  1. Please unit test the id (sortKey, as to be renamed to) functions on individual types, and the respective functions that sort their objects (in file/writer.go)
  2. Please see the attached comment below

@hbagdi should we consider this a breaking change?

file/types.go Outdated Show resolved Hide resolved
Copy link
Contributor

@mflendrich mflendrich left a comment

Choose a reason for hiding this comment

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

Renaming looks good - the other part of my review seems to remain unsolved:

  1. Please unit test the id (sortKey, as to be renamed to) functions on individual types, and the respective functions that sort their objects (in file/writer.go)

@hbagdi
Copy link
Member

hbagdi commented Apr 23, 2021

@hbagdi should we consider this a breaking change?

This is borderline but I feel this is NOT a breaking change:

  • The schema of the state file is part of the compat promise. The ordering inside is not.
  • This is a positive change that most users will welcome. I'm sure there are more people who want their git diffs of kong's configuration to look better.
  • I can't think of a case where a change in ordering will break someone's workflow. The ordering was nondeterministic in the first place. I mean the ordering was based on ID but someone depending on UUID-based ordering sounds really odd.

Is that fair enough?

@codecov-commenter
Copy link

Codecov Report

Merging #337 (b16927c) into main (f38e18d) will increase coverage by 1.07%.
The diff coverage is 71.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #337      +/-   ##
==========================================
+ Coverage   52.58%   53.66%   +1.07%     
==========================================
  Files          60       60              
  Lines        4874     4877       +3     
==========================================
+ Hits         2563     2617      +54     
+ Misses       2013     1962      -51     
  Partials      298      298              
Impacted Files Coverage Δ
file/writer.go 15.28% <6.66%> (+0.26%) ⬆️
file/types.go 69.50% <100.00%> (+26.06%) ⬆️
dump/dump.go 1.56% <0.00%> (-0.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f38e18d...b16927c. Read the comment docs.

}
if p.Route != nil {
key += *p.Route.ID
if p.Name != nil {
Copy link
Member

Choose a reason for hiding this comment

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

non-blocker: you could simplify this. A plugin's name field can never be nil.

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 thought so too, but then I realized that even if it's impossible, the sortkey() shouldn't trigger an error for that situation as it's responsability is to sort and not to validate what it is sorting. That's why I wrote it this way.

if s.Name != nil {
return *s.Name
}
if s.ID != nil {
return *s.ID
}
return ""
}
Copy link
Member

Choose a reason for hiding this comment

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

The sort key for FServiceVersion seems to be missing and we should add that.
It can be done separately or part of this PR - either is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was neither any compareID() associated with this type, it seems like it was never sorted

Copy link
Member

Choose a reason for hiding this comment

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

I've added #348 to track it.
If you are interested, please take that on once you this PR is merged in.
Thanks you!

@hbagdi
Copy link
Member

hbagdi commented Apr 26, 2021

This looks good from a product perspective. Let's merge once technical review is complete.

@rainest rainest requested a review from a team April 26, 2021 17:01
@rainest rainest merged commit fc24613 into Kong:main Apr 26, 2021
@mmorel-35 mmorel-35 deleted the refactor/file_entities_ordering branch April 27, 2021 05:51
AntoineJac pushed a commit that referenced this pull request Jan 23, 2024
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.

5 participants