Skip to content

Commit

Permalink
add --skip-master option
Browse files Browse the repository at this point in the history
  • Loading branch information
yuuki committed Oct 18, 2018
1 parent f4cd485 commit ad52d89
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions check-redis/lib/check-redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,13 @@ func checkReachable(args []string) *checkers.Checker {
)
}

type replicationOpts struct {
redisSetting
SkipMaster bool `long:"skip-master" description:"return ok if redis role is master"`
}

func checkReplication(args []string) *checkers.Checker {
opts := redisSetting{}
opts := replicationOpts{}
psr := flags.NewParser(&opts, flags.Default)
psr.Usage = "replication [OPTIONS]"
_, err := psr.ParseArgs(args)
Expand All @@ -146,14 +151,14 @@ func checkReplication(args []string) *checkers.Checker {
os.Exit(1)
}

c, info, err := connectRedisGetInfo(opts)
c, info, err := connectRedisGetInfo(opts.redisSetting)
if err != nil {
return checkers.Unknown(err.Error())
}
defer c.Close()

if role, ok := (*info)["role"]; ok {
if role != "slave" {
if role != "slave" && opts.SkipMaster {
return checkers.Ok("role is not slave")
}
} else {
Expand Down

0 comments on commit ad52d89

Please sign in to comment.