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

feat: make suites mandatory in archive config #161

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
HadrienPatte marked this conversation as resolved.
Show resolved Hide resolved
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
Loading