Skip to content

Commit

Permalink
Return code 1 to system if config is invalid or any sync failed
Browse files Browse the repository at this point in the history
  • Loading branch information
juliogonzalez committed Feb 26, 2020
1 parent 2863630 commit ba04cfc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"net/url"
"path/filepath"
"os"

"github.com/uyuni-project/minima/get"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -44,19 +45,25 @@ var syncCmd = &cobra.Command{
# archs: [x86_64]
`,
Run: func(cmd *cobra.Command, args []string) {
var errorflag bool = false
syncers, err := syncersFromConfig(cfgString)
if err != nil {
log.Fatal(err)
errorflag = true
}
for _, syncer := range syncers {
log.Printf("Processing repo: %s", syncer.URL.String())
err := syncer.StoreRepo()
if err != nil {
log.Println(err)
errorflag = true
} else {
log.Println("...done.")
}
}
if errorflag {
os.Exit(1)
}
},
}

Expand Down

0 comments on commit ba04cfc

Please sign in to comment.