shared: Allow empty URL
Signed-off-by: Thomas Hipp <thomas.hipp@canonical.com>
This commit is contained in:
parent
b6c1538356
commit
c9b245a820
@ -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",
|
||||
|
@ -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{
|
||||
|
Loading…
x
Reference in New Issue
Block a user