Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from koor-tech/fix_required_flags
Browse files Browse the repository at this point in the history
  • Loading branch information
galexrt authored Oct 15, 2022
2 parents 694d991 + 35a2e61 commit eb9a7e3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type CmdLineOpts struct {

var opts CmdLineOpts

var requiredFlags = []string{"rgw-host", "rgw-access-key", "rgw-secret-key"}

func init() {
flags.BoolVar(&opts.Version, "version", false, "Show version info and exit")
flags.StringVar(&opts.LogLevel, "log-level", "INFO", "Set log level")
Expand Down Expand Up @@ -122,10 +124,10 @@ func main() {
log.SetLevel(l)

// Check if required flags are given
for _, k := range []string{"rgw-host", "rgw-user", "rgw-password"} {
flag := flags.Lookup(k)
for _, f := range requiredFlags {
flag := flags.Lookup(f)
if flag == nil {
log.Fatalf("flag %s not found during lookup", k)
log.Fatalf("required flag %s not found during lookup in flags list, please report this to the developer", f)
}
if !flag.Changed {
log.Fatalf("required flag %s not set", flag.Name)
Expand Down

0 comments on commit eb9a7e3

Please sign in to comment.