Repository navigation
Keep MIG attribute order when matching a profile - #121
Merged
tariq1890 merged 1 commit intoOct 6, 2026
Merged
Conversation
tariq1890
reviewed
Oct 6, 2026
| sort.Strings(attrs2) | ||
| for i, a := range attrs2 { | ||
| if a != attrs1[i] { | ||
| left := append([]string(nil), attrs1...) |
Contributor
There was a problem hiding this comment.
Why not use slices.Clone instead?
See here for an example of how it is used.
Contributor
Author
There was a problem hiding this comment.
Thanks. slices.Clone is the same copy, and it keeps a nil slice nil. That is commit 81c855f. go test ./pkg/nvlib/device passed.
Contributor
|
Thank you, @SashaMIT ! |
Contributor
|
Can you squash your commit history? |
Matches sorted the profile's own attribute slices, so a successful match rewrote 1g.5gb+me,gfx as 1g.5gb+gfx,me. Compare copies instead. The copies use slices.Clone. Signed-off-by: Sasha Mitchell <sash.t.mitchell@gmail.com>
SashaMIT
force-pushed
the
fix/mig-match-keeps-attribute-order
branch
from
October 6, 2026 06:11
81c855f to
1f124ab
Compare
Contributor
Author
|
Done. Those two commits are now one, 1f124ab. |
tariq1890
approved these changes
Oct 6, 2026
Contributor
Author
|
Thanks for merging it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #120
Matchessorted the attribute slices it was given. Those slices share the profile's backing array, so the sort sticks.parseMigProfile("1g.5gb+me,gfx").String()is1g.5gb+me,gfx. AfterMatches("1g.5gb+gfx,me")returns true,String()is1g.5gb+gfx,me. Negative attributes go through the same helper.The comparison now sorts copies. A matching profile stays
1g.5gb+me,gfx.1g.5gb+gfx,mestill matches.TestMatchesKeepsAttributeOrderis red on tip (1g.5gb+gfx,me) and green after.TestParseMigProfilestill passes.