Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cmd/influx): add hints to ID-related errors in DBRP CLI commands #20204

Merged
merged 2 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## unreleased

### Features

1. [20204](https://github.com/influxdata/influxdb/pull/20204): Improve ID-related error messages for `influx v1 dbrp` commands.

### Bug Fixes

1. [20201](https://github.com/influxdata/influxdb/pull/20201): Optimize shard lookup in groups containing only one shard. Thanks @StoneYunZhao!
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