Merge pull request #6029 from thaJeztah/stack_deploy_failearly
stack deploy: fail early on invalid image reference format
This commit is contained in:
commit
eeda0af3f4
@ -12,6 +12,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/cli/cli/command/stack/options"
|
"github.com/docker/cli/cli/command/stack/options"
|
||||||
"github.com/docker/cli/cli/compose/loader"
|
"github.com/docker/cli/cli/compose/loader"
|
||||||
@ -49,6 +50,17 @@ func LoadComposefile(dockerCli command.Cli, opts options.Deploy) (*composetypes.
|
|||||||
_, _ = fmt.Fprintf(dockerCli.Err(), "Ignoring deprecated options:\n\n%s\n\n",
|
_, _ = fmt.Fprintf(dockerCli.Err(), "Ignoring deprecated options:\n\n%s\n\n",
|
||||||
propertyWarnings(deprecatedProperties))
|
propertyWarnings(deprecatedProperties))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate if each service has a valid image-reference.
|
||||||
|
for _, svc := range config.Services {
|
||||||
|
if svc.Image == "" {
|
||||||
|
return nil, errors.Errorf("invalid image reference for service %s: no image specified", svc.Name)
|
||||||
|
}
|
||||||
|
if _, err := reference.ParseAnyReference(svc.Image); err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "invalid image reference for service %s", svc.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user