Skip to content

Commit

Permalink
feat(cmd/influx): add hints to ID-related errors in DBRP CLI commands (
Browse files Browse the repository at this point in the history
  • Loading branch information
danxmoran committed Dec 3, 2020
1 parent c9d0246 commit e974b0b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ want to use the default.
1. [20128](https://github.com/influxdata/influxdb/pull/20128): Allow password to be specified as a CLI option in `influx v1 auth set-password`.
1. [20146](https://github.com/influxdata/influxdb/pull/20146): Allow for users to specify where V2 config should be written in `influxd upgrade`.
1. [20243](https://github.com/influxdata/influxdb/pull/20243): Implement delete with predicate.
1. [20204](https://github.com/influxdata/influxdb/pull/20204): Improve ID-related error messages for `influx v1 dbrp` commands.

### Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion cmd/influx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ func (o *organization) getID(orgSVC influxdb.OrganizationService) (influxdb.ID,
if o.id != "" {
influxOrgID, err := influxdb.IDFromString(o.id)
if err != nil {
return 0, fmt.Errorf("invalid org ID provided: %s", err.Error())
return 0, fmt.Errorf("invalid org ID '%s' provided: %w (did you pass an org name instead of an ID?)", o.id, err)
}
return *influxOrgID, nil
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/influx/v1_authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func makeV1AuthorizationCreateE(opt genericCLIOpts) func(*cobra.Command, []strin
for _, p := range bp.perms {
var id influxdb.ID
if err := id.DecodeFromString(p); err != nil {
return err
return fmt.Errorf("invalid bucket ID '%s': %w (did you pass a bucket name instead of an ID?)", p, err)
}

p, err := influxdb.NewPermissionAtID(id, bp.action, influxdb.BucketsResourceType, orgID)
Expand Down Expand Up @@ -253,7 +253,7 @@ func v1AuthorizationFindF(cmd *cobra.Command, _ []string) error {
if v1AuthorizationFindFlags.userID != "" {
uID, err := influxdb.IDFromString(v1AuthorizationFindFlags.userID)
if err != nil {
return err
return fmt.Errorf("invalid user ID '%s': %w (did you pass a username instead of an ID?)", v1AuthorizationFindFlags.userID, err)
}
filter.UserID = uID
}
Expand All @@ -263,7 +263,7 @@ func v1AuthorizationFindF(cmd *cobra.Command, _ []string) error {
if v1AuthorizationFindFlags.org.id != "" {
oID, err := influxdb.IDFromString(v1AuthorizationFindFlags.org.id)
if err != nil {
return err
return fmt.Errorf("invalid org ID '%s': %w (did you pass an org name instead of an ID?)", v1AuthorizationFindFlags.org.id, err)
}
filter.OrgID = oID
}
Expand Down

0 comments on commit e974b0b

Please sign in to comment.