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 6649ba8 commit 1911858
Showing 1 changed file with 13 additions and 4 deletions.
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 1911858

Please sign in to comment.