Skip to content

Commit

Permalink
fix err msg
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng committed Jul 5, 2018
1 parent dd80c7c commit bac541f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions tools/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ func RegisterDomain(c *cli.Context) {

description := c.String(FlagDescription)
ownerEmail := c.String(FlagOwnerEmail)
domainDataStr := c.String(FlagDomainData)
retentionDays := defaultDomainRetentionDays
if c.IsSet(FlagRetentionDays) {
retentionDays = c.Int(FlagRetentionDays)
Expand All @@ -194,16 +193,22 @@ func RegisterDomain(c *cli.Context) {
return
}
}
domainData, err := parseDomainDataKVs(domainDataStr)
if err != nil {
fmt.Printf("Register Domain failed: %v.\n", err.Error())
return
}
err = checkRequiredDomainDataKVs(domainData)
if err != nil {
fmt.Printf("Register Domain failed: %v.\n", err.Error())
return

domainData := map[string]string{}
if len(requiredDomainDataKeys) > 0 {
domainDataStr := getRequiredOption(c, FlagDomainData)
domainData, err = parseDomainDataKVs(domainDataStr)
if err != nil {
fmt.Printf("Register Domain failed: %v.\n", err.Error())
return
}
err = checkRequiredDomainDataKVs(domainData)
if err != nil {
fmt.Printf("Register Domain failed: %v.\n", err.Error())
return
}
}

var activeClusterName string
if c.IsSet(FlagActiveClusterName) {
activeClusterName = c.String(FlagActiveClusterName)
Expand Down
2 changes: 1 addition & 1 deletion tools/cli/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func checkRequiredDomainDataKVs(domainData map[string]string) error {
for _, k := range requiredDomainDataKeys {
_, ok := domainData[k]
if !ok {
return fmt.Errorf("domain data error, missing required key %v", k)
return fmt.Errorf("domain data error, missing required key %v . All required keys: %v", k, requiredDomainDataKeys)
}
}
return nil
Expand Down

0 comments on commit bac541f

Please sign in to comment.