-
Notifications
You must be signed in to change notification settings - Fork 61
feat: upgrade existing filesystem #264
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 73 commits
491cd0c
a6e57f7
5da0450
5703751
26bb2b3
4a14230
865c1b8
0343ddc
e116424
5b9d408
7861c8d
27a0d22
5f377b0
f74265c
799373c
dbe3f30
becfe42
3c994b8
6ebb893
ceac217
7e34e32
e1d4e17
c3db9d4
e1e9c43
da567ba
2a6c891
398e032
7c17f18
7caf3ba
a259d1d
fad2cb7
d095953
d0b70cd
83e7af6
d217c43
8a7066b
87d1496
f8e2bd6
6dd701c
8523aa5
2ceb21a
10a1744
6cf317c
0d1103b
78e3f51
d14c056
4217131
a902099
08b3edd
cf90f0d
46f872c
2052ee5
0fbc47a
30f1c32
a675ad8
558b827
ab11797
9ff9bcc
f1324a8
78efc45
b8d695f
b811661
acebd11
6e6b09e
76483c5
fb41a11
9e87404
fea8434
aacc37e
cf9aa78
25be459
882c557
1ec1b4a
bdbba3c
b12185b
17d7935
0c9b7bd
c5fa3b8
059422c
4f868da
b44ef37
85ea2b6
91780f4
7bd6655
908b49b
e68f1f6
3f19c2c
59a4d7f
d1c3919
ac1be1b
5cda705
7dd133d
0e892f7
18a7b22
4550747
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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import ( | |
| "fmt" | ||
| "io" | ||
| "io/fs" | ||
| "maps" | ||
| "path/filepath" | ||
| "slices" | ||
| "sort" | ||
|
|
@@ -34,6 +35,24 @@ func FindPaths(slices []*setup.Slice) map[string][]*setup.Slice { | |
| return manifestSlices | ||
| } | ||
|
|
||
| // FindPathsInRelease finds all the paths marked with "generate:manifest" | ||
| // for the given release. | ||
| func FindPathsInRelease(r *setup.Release) []string { | ||
| manifestPaths := make(map[string]struct{}) | ||
| for _, pkg := range r.Packages { | ||
| for _, slice := range pkg.Slices { | ||
| for path, info := range slice.Contents { | ||
| if info.Generate == setup.GenerateManifest { | ||
| dir := strings.TrimSuffix(path, "**") | ||
| path = filepath.Join(dir, DefaultFilename) | ||
|
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. This is too loose. Imagine what happens if path is "/hmm/oops**", for instance, or just "/oops". We need to be strict about how a manifest path looks like. Hopefully this is already the case elsewhere so there's already a pattern to follow. If not, please let me know.
Collaborator
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. Following our discussion offline, see 85ea2b6. The validation function is heavily inspired from
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. Can you please outline what was the outcome here? Many comments here saying "See XYZ.", but it's not practical to go to several different links trying to find out how you handled the issue that was outlined here.
Collaborator
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 added a |
||
| manifestPaths[path] = struct{}{} | ||
|
upils marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| } | ||
| } | ||
| return slices.Sorted(maps.Keys(manifestPaths)) | ||
| } | ||
|
|
||
| type WriteOptions struct { | ||
| PackageInfo []*archive.PackageInfo | ||
| Selection []*setup.Slice | ||
|
|
||
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 must never ever happen if
err != nil. This is an important invariant to keep in mind in every Go project we work on. If we skip this rule, we're straight into billion Euro mistake territory. If you asked to select a valid manifest, and it did not return an error, it must have selected a valid manifest!Let's please fix the function implementation and drop this verification from every call site.
cc @letFunny
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.
I completely agree. I brought the same point in the past out of muscle memory but I couldn't find any document to justify it properly. Maybe we should include it in the go style document that Ed wrote here.
Uh oh!
There was an error while loading. Please reload this page.
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.
I reworked it and added a custom error type. In
cmd_cut.gothe error message is not used but I wonder if it should be logged or not. If we are not planning on doing anything with these messages the implementation could be simplified by removing themessagefield or even by replacing the custom type by a named error.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.
As a rule of thumb, if we don't have a use case for the error type we don't introduce the error type, but I'm not sure I understand what you're asking, as it sounds like you're both saying "I added a custom error type" and "I don't need to add an error type".