Skip to content

Commit

Permalink
eext.yaml sanity check
Browse files Browse the repository at this point in the history
If repo path for any package under extern dependencies is left empty
it would throw an error. If unsupported architecture is provided in
multilib it would throw an error. These issues are handeled in this commit.
Sanity check is added for eextgen in eext.yaml file.
- Check added to catch empty repo paths for a package in yaml:"external-dependencies"
- Check added to catch unsupported architectures in yaml:"multilib"

Fixes: BUG1001386
  • Loading branch information
manishk-arista committed Sep 6, 2024
1 parent 7374f58 commit c0db5e4
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
16 changes: 15 additions & 1 deletion manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ type Manifest struct {

func (m Manifest) sanityCheck() error {
allowedPkgTypes := []string{"srpm", "unmodified-srpm", "tarball", "standalone"}

allowedArchs := []string{"i686", "x86_64"}
for _, pkgSpec := range m.Package {
if pkgSpec.Name == "" {
return fmt.Errorf("Package name not specified in manifest")
Expand Down Expand Up @@ -203,6 +203,20 @@ func (m Manifest) sanityCheck() error {
pkgSpec.Name)
}
}

for pkgName, pkgPath := range pkgSpec.Build.Generator.ExternalDependencies {
if pkgPath == "" {
return fmt.Errorf("Empty repo path in yaml:external-dependencies for package %s",
pkgName)
}
}

for arch := range pkgSpec.Build.Generator.Multilib {
if !slices.Contains(allowedArchs, arch) {
return fmt.Errorf("Architecture %s not suported", arch)
}
}

}
return nil
}
Expand Down
10 changes: 10 additions & 0 deletions manifest/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ func TestManifestNegative(t *testing.T) {
ManifestFile: "sampleManifest3.yaml",
ExpectedErr: "Conflicting signatures for Build in package tcpdump, provide full-url or source-bundle",
},
"testEmptyExtDepsRepoPath": manifestTestVariant{
TestPkg: "pkg4",
ManifestFile: "sampleManifest4.yaml",
ExpectedErr: "Empty repo path in yaml:external-dependencies for package crypto-policies",
},
"testUnsupportedArch": manifestTestVariant{
TestPkg: "pkg5",
ManifestFile: "sampleManifest5.yaml",
ExpectedErr: "Architecture aarch64 not suported",
},
}
for testName, variant := range testCases {
t.Logf("%s: Copy sample manifest to test directory", testName)
Expand Down
20 changes: 20 additions & 0 deletions manifest/testData/sampleManifest4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
package:
- name: openssl
upstream-sources:
- source-bundle:
name: srpm
override:
version: 3.0.7-27.el9
type: srpm
build:
repo-bundle:
- name: el9
dependencies:
all:
- crypto-policies
- openssl3-fips
eextgen:
external-dependencies:
crypto-policies:
openssl3-fips: code.arista.io/eos/eext/openssl3-fips/
23 changes: 23 additions & 0 deletions manifest/testData/sampleManifest5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
package:
- name: openssl
upstream-sources:
- source-bundle:
name: srpm
override:
version: 3.0.7-27.el9
type: srpm
build:
repo-bundle:
- name: el9
dependencies:
all:
- crypto-policies
- openssl3-fips
eextgen:
multilib:
aarch64:
other-arch:
patterns:
- "openssl-devel*.rpm"
remove: True

0 comments on commit c0db5e4

Please sign in to comment.