Skip to content

Commit

Permalink
Merge branch 'main' into feat/gpg/verify-release
Browse files Browse the repository at this point in the history
  • Loading branch information
letFunny committed Dec 14, 2023
2 parents 44d6f41 + 2266288 commit d9ffa47
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func readSlices(release *Release, baseDir, dirName string) error {

type yamlRelease struct {
Format string `yaml:"format"`
Archives map[string]yamlArchive `yaml:"archives`
Archives map[string]yamlArchive `yaml:"archives"`
PublicKeys map[string]yamlPublicKey `yaml:"public-keys"`
}

Expand Down Expand Up @@ -411,7 +411,7 @@ func parseRelease(baseDir, filePath string, data []byte) (*Release, error) {

yamlVar := yamlRelease{}
dec := yaml.NewDecoder(bytes.NewBuffer(data))
dec.KnownFields(true)
dec.KnownFields(false)
err := dec.Decode(&yamlVar)
if err != nil {
return nil, fmt.Errorf("%s: cannot parse release definition: %v", fileName, err)
Expand Down Expand Up @@ -490,7 +490,7 @@ func parsePackage(baseDir, pkgName, pkgPath string, data []byte) (*Package, erro

yamlPkg := yamlPackage{}
dec := yaml.NewDecoder(bytes.NewBuffer(data))
dec.KnownFields(true)
dec.KnownFields(false)
err := dec.Decode(&yamlPkg)
if err != nil {
return nil, fmt.Errorf("cannot parse package %q slice definitions: %v", pkgName, err)
Expand Down
58 changes: 58 additions & 0 deletions internal/setup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,64 @@ var setupTests = []setupTest{{
},
},
},
}, {
summary: "Extra fields in YAML are ignored (necessary for forward compatibility)",
input: map[string]string{
"chisel.yaml": `
format: chisel-v1
archives:
ubuntu:
version: 22.04
components: [main, other]
suites: [jammy, jammy-security]
public-keys: [test-key]
madeUpKey1: whatever
madeUpKey2: whatever
public-keys:
test-key:
id: ` + testKey.ID + `
armor: |` + "\n" + testutil.PrefixEachLine(testKey.ArmoredPublicKey, "\t\t\t\t\t\t") + `
madeUpKey6: whatever
`,
"slices/mydir/mypkg.yaml": `
package: mypkg
madeUpKey3: whatever
slices:
myslice:
madeUpKey4: whatever
contents:
/path: {madeUpKey5: whatever}
`,
},
release: &setup.Release{
DefaultArchive: "ubuntu",

Archives: map[string]*setup.Archive{
"ubuntu": {
Name: "ubuntu",
Version: "22.04",
Suites: []string{"jammy", "jammy-security"},
Components: []string{"main", "other"},
PublicKeys: []*packet.PublicKey{testKey.PublicKey},
},
},
Packages: map[string]*setup.Package{
"mypkg": {
Archive: "ubuntu",
Name: "mypkg",
Path: "slices/mydir/mypkg.yaml",
Slices: map[string]*setup.Slice{
"myslice": {
Package: "mypkg",
Name: "myslice",
Contents: map[string]setup.PathInfo{
"/path": {Kind: "copy"},
},
},
},
},
},
},
}, {
summary: "Archives with public keys",
input: map[string]string{
Expand Down

0 comments on commit d9ffa47

Please sign in to comment.