Skip to content

Commit

Permalink
feat(influx): extend CLI org type to support config orgs in global co…
Browse files Browse the repository at this point in the history
…nfig
  • Loading branch information
jsteenb2 committed Apr 21, 2020
1 parent 5cd57d4 commit 43b7d65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

1. [17618](https://github.com/influxdata/influxdb/pull/17618): Add index for URM by user ID to improve lookup performance
1. [17751](https://github.com/influxdata/influxdb/pull/17751): Existing session expiration time is respected on session renewal
1. [17817](https://github.com/influxdata/influxdb/pull/17817): Make CLI respect env vars and flags in addition to the configs and extend support for config orgs to all commands

### UI Improvements

Expand Down
17 changes: 13 additions & 4 deletions cmd/influx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,16 +408,25 @@ func (o *organization) getID(orgSVC influxdb.OrganizationService) (influxdb.ID,
return 0, fmt.Errorf("invalid org ID provided: %s", err.Error())
}
return *influxOrgID, nil
} else if o.name != "" {
}

getOrgByName := func(name string) (influxdb.ID, error) {
org, err := orgSVC.FindOrganization(context.Background(), influxdb.OrganizationFilter{
Name: &o.name,
Name: &name,
})
if err != nil {
return 0, fmt.Errorf("%v", err)
return 0, err
}
return org.ID, nil
}
return 0, fmt.Errorf("failed to locate an organization id")
if o.name != "" {
return getOrgByName(o.name)
}
// last check is for the org set in the CLI config. This will be last in priority.
if flags.Org != "" {
return getOrgByName(flags.Org)
}
return 0, fmt.Errorf("failed to locate organization criteria")
}

func (o *organization) validOrgFlags(f *globalFlags) error {
Expand Down

0 comments on commit 43b7d65

Please sign in to comment.