add default-user, default-password, and default-command options to client.yml config
This commit is contained in:
parent
28975e9433
commit
8956837443
3 changed files with 43 additions and 8 deletions
|
@ -175,11 +175,32 @@ func doSubscribe(c *cli.Context, cl *client.Client, conf *client.Config, topic,
|
|||
for filter, value := range s.If {
|
||||
topicOptions = append(topicOptions, client.WithFilter(filter, value))
|
||||
}
|
||||
if s.User != "" && s.Password != "" {
|
||||
topicOptions = append(topicOptions, client.WithBasicAuth(s.User, s.Password))
|
||||
var user, password string
|
||||
if s.User != "" {
|
||||
user = s.User
|
||||
} else if conf.DefaultUser != "" {
|
||||
user = conf.DefaultUser
|
||||
} else {
|
||||
user = ""
|
||||
}
|
||||
if s.Password != "" {
|
||||
password = s.Password
|
||||
} else if conf.DefaultPassword != "" {
|
||||
password = conf.DefaultPassword
|
||||
} else {
|
||||
password = ""
|
||||
}
|
||||
if user != "" && password != "" {
|
||||
topicOptions = append(topicOptions, client.WithBasicAuth(user, password))
|
||||
}
|
||||
subscriptionID := cl.Subscribe(s.Topic, topicOptions...)
|
||||
cmds[subscriptionID] = s.Command
|
||||
if s.Command != "" {
|
||||
cmds[subscriptionID] = s.Command
|
||||
} else if conf.DefaultCommand != "" {
|
||||
cmds[subscriptionID] = conf.DefaultCommand
|
||||
} else {
|
||||
cmds[subscriptionID] = ""
|
||||
}
|
||||
}
|
||||
if topic != "" {
|
||||
subscriptionID := cl.Subscribe(topic, options...)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue