mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 09:16:29 +00:00
Validate output before doing the work
Signed-off-by: French Ben <frenchben@docker.com>
This commit is contained in:
parent
dec7f8bb2b
commit
23856c1e46
@ -65,6 +65,13 @@ func build(args []string) {
|
||||
|
||||
log.Debugf("Outputs selected: %s", buildOut.String())
|
||||
|
||||
err := validateOutputs(buildOut)
|
||||
if err != nil {
|
||||
log.Errorf("Error parsing outputs: %v", err)
|
||||
buildCmd.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(remArgs) == 0 {
|
||||
fmt.Println("Please specify a configuration file")
|
||||
buildCmd.Usage()
|
||||
|
@ -119,15 +119,29 @@ var outFuns = map[string]func(string, []byte) error{
|
||||
},
|
||||
}
|
||||
|
||||
func outputs(base string, image []byte, out outputList) error {
|
||||
log.Debugf("output: %v %s", out, base)
|
||||
func validateOutputs(out outputList) error {
|
||||
log.Debugf("validating output: %v", out)
|
||||
|
||||
for _, o := range out {
|
||||
f := outFuns[o]
|
||||
if f == nil {
|
||||
return fmt.Errorf("Unknown output type %s", o)
|
||||
}
|
||||
err := f(base, image)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func outputs(base string, image []byte, out outputList) error {
|
||||
log.Debugf("output: %v %s", out, base)
|
||||
|
||||
err := validateOutputs(out)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, o := range out {
|
||||
f := outFuns[o]
|
||||
err = f(base, image)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user