diff --git a/shared/definition.go b/shared/definition.go index 5d70918..64bfd0d 100644 --- a/shared/definition.go +++ b/shared/definition.go @@ -32,7 +32,7 @@ type DefinitionImage struct { // A DefinitionSource specifies the download type and location type DefinitionSource struct { Downloader string `yaml:"downloader"` - URL string `yaml:"url"` + URL string `yaml:"url,omitempty"` Keys []string `yaml:"keys,omitempty"` Keyserver string `yaml:"keyserver,omitempty"` Variant string `yaml:"variant,omitempty"` @@ -122,10 +122,6 @@ func ValidateDefinition(def Definition) error { return fmt.Errorf("source.downloader must be one of %v", validDownloaders) } - if strings.TrimSpace(def.Source.URL) == "" { - return errors.New("source.url may not be empty") - } - validManagers := []string{ "apk", "apt", diff --git a/shared/definition_test.go b/shared/definition_test.go index 32b1886..ded182f 100644 --- a/shared/definition_test.go +++ b/shared/definition_test.go @@ -65,6 +65,23 @@ func TestValidateDefinition(t *testing.T) { "", false, }, + { + "valid Defintion without source.url", + Definition{ + Image: DefinitionImage{ + Distribution: "ubuntu", + Release: "artful", + }, + Source: DefinitionSource{ + Downloader: "debootstrap", + }, + Packages: DefinitionPackages{ + Manager: "apt", + }, + }, + "", + false, + }, { "empty image.distribution", Definition{}, @@ -85,20 +102,6 @@ func TestValidateDefinition(t *testing.T) { "source.downloader must be one of .+", true, }, - { - "empty source.url", - Definition{ - Image: DefinitionImage{ - Distribution: "ubuntu", - Release: "artful", - }, - Source: DefinitionSource{ - Downloader: "debootstrap", - }, - }, - "source.url may not be empty", - true, - }, { "invalid package.manager", Definition{