Skip to content

Commit

Permalink
Allow separate additional repository validations
Browse files Browse the repository at this point in the history
Signed-off-by: Atanas Dinov <[email protected]>
  • Loading branch information
atanasdinov committed Apr 16, 2024
1 parent 6a1dad0 commit b5b3045
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
12 changes: 2 additions & 10 deletions pkg/image/validation/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,6 @@ func validateSuma(os *image.OperatingSystem) []FailedValidation {
func validatePackages(os *image.OperatingSystem) []FailedValidation {
var failures []FailedValidation

if len(os.Packages.PKGList) == 0 {
if len(os.Packages.AdditionalRepos) > 0 {
failures = append(failures, FailedValidation{
UserMessage: "The 'packageList' field is required if any entries are specified under 'additionalRepos'.",
})
}

return failures
}

if slices.Contains(os.Packages.PKGList, "") {
failures = append(failures, FailedValidation{
UserMessage: "The 'packageList' field cannot contain empty values.",
Expand All @@ -206,6 +196,8 @@ func validatePackages(os *image.OperatingSystem) []FailedValidation {
})
}

// It is possible to only provide `additionalRepos` without listing any packages
// under `packageList` in the cases where RPMs are side-loaded under the `/rpms` directory.
var repoURLs []string

for _, repo := range os.Packages.AdditionalRepos {
Expand Down
12 changes: 0 additions & 12 deletions pkg/image/validation/os_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,18 +486,6 @@ func TestPackages(t *testing.T) {
"The 'packageList' field cannot contain empty values.",
},
},
`missing packages`: {
Packages: image.Packages{
AdditionalRepos: []image.AddRepo{
{
URL: "foo",
},
},
},
ExpectedFailedMessages: []string{
"The 'packageList' field is required if any entries are specified under 'additionalRepos'.",
},
},
`duplicate packages`: {
Packages: image.Packages{
PKGList: []string{"foo", "bar", "foo", "bar", "baz"},
Expand Down

0 comments on commit b5b3045

Please sign in to comment.