-
Notifications
You must be signed in to change notification settings - Fork 55
fix: define default arch in cut command #256
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
base: main
Are you sure you want to change the base?
Changes from all commits
a080409
2fb3c32
53fe075
c80bc7b
4ce1609
7796bfc
842070c
f1ffee3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -369,7 +369,7 @@ func order(pkgs map[string]*Package, keys []SliceKey, arch string) ([]SliceKey, | |
| fqslice := slice.String() | ||
| predecessors := successors[fqslice] | ||
| for req, info := range slice.Essential { | ||
| if len(info.Arch) > 0 && !slices.Contains(info.Arch, arch) { | ||
| if len(info.Arch) > 0 && arch != "" && !slices.Contains(info.Arch, arch) { | ||
| continue | ||
| } | ||
| fqreq := req.String() | ||
|
|
@@ -465,6 +465,10 @@ func stripBase(baseDir, path string) string { | |
| func Select(release *Release, slices []SliceKey, arch string) (*Selection, error) { | ||
| logf("Selecting slices...") | ||
|
|
||
| if arch == "" { | ||
| return nil, fmt.Errorf(`cannot select slices: "arch" is unset`) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I actually have a question here: there's something suspect about this PR, which is the whole logic was actually handling the empty arch just fine until now, and suddenly because we introduced a v3-essential feature, the behavior is changing and we're unable to let the architecture empty, while before we could. It looks like there's something being missed here. Clearly we had a default architecture before. Where was it, and why is this PR not touching that, and also why isn't that place collaborating with the existing fix?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The arch was not needed prior to We also discussed calling
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If that was true we would not have an Maybe that's okay, but this is ignoring the point I made instead of addressing it.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prior to This parameter was added so the arch-specific essentials could be ignored if the arch was not matching. However the implementation of #246 did not consider the case of an empty
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. previously the default arch was having said that, this feels like a great place/use of enums |
||
| } | ||
|
|
||
| selection := &Selection{ | ||
| Release: release, | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3548,6 +3548,44 @@ var setupTests = []setupTest{{ | |
| `, | ||
| }, | ||
| relerror: `package "mypkg" repeats mypkg_myslice2 in essential fields`, | ||
| }, { | ||
| summary: "Cycles are detected with 'v3-essential'", | ||
| input: map[string]string{ | ||
| "slices/mydir/mypkg1.yaml": ` | ||
| package: mypkg1 | ||
| slices: | ||
| myslice: | ||
| v3-essential: | ||
| mypkg2_myslice: {arch: [amd64, i386]} | ||
| `, | ||
| "slices/mydir/mypkg2.yaml": ` | ||
| package: mypkg2 | ||
| slices: | ||
| myslice: | ||
| v3-essential: | ||
| mypkg1_myslice: {arch: [amd64, i386]} | ||
| `, | ||
| }, | ||
| relerror: "essential loop detected: mypkg1_myslice, mypkg2_myslice", | ||
| }, { | ||
| summary: "Cycles are detected with 'v3-essential' without architecture", | ||
| input: map[string]string{ | ||
| "slices/mydir/mypkg1.yaml": ` | ||
| package: mypkg1 | ||
| slices: | ||
| myslice: | ||
| v3-essential: | ||
| mypkg2_myslice: | ||
| `, | ||
| "slices/mydir/mypkg2.yaml": ` | ||
| package: mypkg2 | ||
| slices: | ||
| myslice: | ||
| v3-essential: | ||
| mypkg1_myslice: {arch: [amd64, i386]} | ||
| `, | ||
| }, | ||
| relerror: "essential loop detected: mypkg1_myslice, mypkg2_myslice", | ||
| }} | ||
|
|
||
| func (s *S) TestParseRelease(c *C) { | ||
|
|
@@ -3625,7 +3663,7 @@ func runParseReleaseTests(c *C, tests []setupTest) { | |
| } | ||
|
|
||
| if test.selslices != nil { | ||
| selection, err := setup.Select(release, test.selslices, "") | ||
| selection, err := setup.Select(release, test.selslices, "amd64") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. magic value. should be a constant imo. these are tests, so its maybe less important here, but nonetheless it does introduce a notion of a default architecture. maybe we should define that and the return it here:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not think it introduces the notion of a default architecture from the point of view of The behavior of falling back to inferring the arch is consistent with how the release is inferred in |
||
| if test.selerror != "" { | ||
| c.Assert(err, ErrorMatches, test.selerror) | ||
| continue | ||
|
|
@@ -3850,3 +3888,8 @@ func (s *S) TestYAMLPathGenerate(c *C) { | |
| c.Assert(result, Equals, test.result) | ||
| } | ||
| } | ||
|
|
||
| func (s *S) TestSelectEmptyArch(c *C) { | ||
| _, err := setup.Select(nil, nil, "") | ||
| c.Assert(err, ErrorMatches, `cannot select slices: "arch" is unset`) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2078,6 +2078,10 @@ func runSlicerTests(s *S, c *C, tests []slicerTest) { | |
| Slice: "manifest", | ||
| }) | ||
|
|
||
| if test.arch == "" { | ||
| test.arch = "amd64" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see this comment |
||
| } | ||
|
|
||
| selection, err := setup.Select(release, testSlices, test.arch) | ||
| c.Assert(err, IsNil) | ||
|
|
||
|
|
||
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: this is returning the
debArchfield ofarchPairis that the correct one to use? maybe in the future we should do an internal refactor forgoArchanddebArchto be enums to make it clear which one we're using where.. 🤔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
debArchis then used as a filter for values defined inpathso this is the one we want. The purpose ofdeb.InferArch()is to return the current runtimedebarchitecture. The fact it is inferred from the GOARCH is an implementation details I think.What do you think if the source of confusion?
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.
oh, just when reading the code there is both
goArchanddebArch, which are both strings so its not explicit which one should go where, and the name ofInferArchdoes not say which one it returns, so i could imagine someone making a mistake of thinking it returns the other one -- something which would not be caught by the compiler