mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 01:59:07 +00:00
Merge pull request #61 from FrenchBen/validate-output
Validate output before doing the work
This commit is contained in:
commit
cde8329d2f
@ -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