From b5b30454a9516b7da1b70f6bc2a4440d2ff80d3e Mon Sep 17 00:00:00 2001 From: Atanas Dinov Date: Tue, 16 Apr 2024 10:55:52 +0300 Subject: [PATCH] Allow separate additional repository validations Signed-off-by: Atanas Dinov --- pkg/image/validation/os.go | 12 ++---------- pkg/image/validation/os_test.go | 12 ------------ 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/pkg/image/validation/os.go b/pkg/image/validation/os.go index 41363c14..05444759 100644 --- a/pkg/image/validation/os.go +++ b/pkg/image/validation/os.go @@ -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.", @@ -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 { diff --git a/pkg/image/validation/os_test.go b/pkg/image/validation/os_test.go index cc609afb..d8314e00 100644 --- a/pkg/image/validation/os_test.go +++ b/pkg/image/validation/os_test.go @@ -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"},