Skip to content

Commit

Permalink
Introduce badass "doNotFail option"
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanilves committed Oct 13, 2017
1 parent e4a6281 commit 86595fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Options struct {
PushPrefix string `short:"R" long:"push-prefix" description:"[Re]Push pulled images with a specified repo path prefix" env:"PUSH_PREFIX"`
InsecureRegistry bool `short:"i" long:"insecure-registry" description:"Use insecure plain-HTTP connection to registries (not recommended!)" env:"INSECURE_REGISTRY"`
TraceRequests bool `short:"T" long:"trace-requests" description:"Trace Docker registry HTTP requests" env:"TRACE_REQUESTS"`
DoNotFail bool `short:"N" long:"do-not-fail" description:"Do not fail on errors (could be dangerous!)" env:"DO_NOT_FAIL"`
Version bool `short:"V" long:"version" description:"Show version and exit"`
Positional struct {
Repositories []string `positional-arg-name:"REPO1 REPO2 REPOn" description:"Docker repositories to operate on, e.g.: alpine nginx~/1\\.13\\.5$/ busybox~/1.27.2/"`
Expand Down
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ import (
"github.com/ivanilves/lstags/tag/registry"
)

var doNotFail bool

func suicide(err error) {
fmt.Printf("%s\n", err.Error())
os.Exit(1)

if !doNotFail {
os.Exit(1)
}
}

func getVersion() string {
Expand Down Expand Up @@ -49,6 +54,8 @@ func main() {
auth.WebSchema = o.GetWebSchema()
registry.WebSchema = o.GetWebSchema()

doNotFail = o.DoNotFail

const format = "%-12s %-45s %-15s %-25s %s\n"
fmt.Printf(format, "<STATE>", "<DIGEST>", "<(local) ID>", "<Created At>", "<TAG>")

Expand Down

0 comments on commit 86595fe

Please sign in to comment.