Skip to content

Commit

Permalink
feat: make suites mandatory in archive config (#161)
Browse files Browse the repository at this point in the history
This PR makes the suites attribute of archives in the chisel.yaml mandatory. All other attributes are already mandatory (version, components and keys).

There was an old fallback logic which would set suites to the release adjective if left unset, but this logic was only configured for 4 ubuntu releases, one of which (bionic) is no longer supported by chisel, and all other three have their suites properly configured in their chisel.yaml already, so this piece of logic never triggers (focal, jammy, kinetic).
  • Loading branch information
HadrienPatte authored Oct 14, 2024
1 parent 3880d2b commit 022d771
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions cmd/chisel/cmd_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ var defaultChiselYaml = `
ubuntu:
version: 22.04
components: [main, universe]
suites: [jammy]
public-keys: [test-key]
public-keys:
test-key:
Expand Down
13 changes: 1 addition & 12 deletions internal/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,6 @@ type yamlPubKey struct {
Armor string `yaml:"armor"`
}

var ubuntuAdjectives = map[string]string{
"18.04": "bionic",
"20.04": "focal",
"22.04": "jammy",
"22.10": "kinetic",
}

func parseRelease(baseDir, filePath string, data []byte) (*Release, error) {
release := &Release{
Path: baseDir,
Expand Down Expand Up @@ -525,11 +518,7 @@ func parseRelease(baseDir, filePath string, data []byte) (*Release, error) {
return nil, fmt.Errorf("%s: archive %q missing version field", fileName, archiveName)
}
if len(details.Suites) == 0 {
adjective := ubuntuAdjectives[details.Version]
if adjective == "" {
return nil, fmt.Errorf("%s: archive %q missing suites field", fileName, archiveName)
}
details.Suites = []string{adjective}
return nil, fmt.Errorf("%s: archive %q missing suites field", fileName, archiveName)
}
if len(details.Components) == 0 {
return nil, fmt.Errorf("%s: archive %q missing components field", fileName, archiveName)
Expand Down
13 changes: 13 additions & 0 deletions internal/setup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,18 @@ var setupTests = []setupTest{{
},
},
},
}, {
summary: "Archive with suites unset",
input: map[string]string{
"chisel.yaml": `
format: v1
archives:
ubuntu:
version: 22.04
components: [main, other]
`,
},
relerror: `chisel.yaml: archive "ubuntu" missing suites field`,
}, {
summary: "Extra fields in YAML are ignored (necessary for forward compatibility)",
input: map[string]string{
Expand Down Expand Up @@ -1589,6 +1601,7 @@ var defaultChiselYaml = `
ubuntu:
version: 22.04
components: [main, universe]
suites: [jammy]
public-keys: [test-key]
public-keys:
test-key:
Expand Down
3 changes: 3 additions & 0 deletions internal/slicer/slicer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,11 +778,13 @@ var slicerTests = []slicerTest{{
foo:
version: 22.04
components: [main, universe]
suites: [jammy]
default: true
public-keys: [test-key]
bar:
version: 22.04
components: [main]
suites: [jammy]
public-keys: [test-key]
public-keys:
test-key:
Expand Down Expand Up @@ -1202,6 +1204,7 @@ var defaultChiselYaml = `
ubuntu:
version: 22.04
components: [main, universe]
suites: [jammy]
public-keys: [test-key]
public-keys:
test-key:
Expand Down

0 comments on commit 022d771

Please sign in to comment.