mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: handle CLI default organization when none exists in <v2.9.0 coderd (#12594)
* chore: 'coder org set' help message was incorrect * fix: handler coder cli against older versions of Coder
This commit is contained in:
+8
-1
@@ -749,7 +749,14 @@ func CurrentOrganization(r *RootCmd, inv *clibase.Invocation, client *codersdk.C
|
||||
return org.IsDefault
|
||||
})
|
||||
if index < 0 {
|
||||
return codersdk.Organization{}, xerrors.Errorf("unable to determine current organization. Use 'coder set <org>' to select an organization to use")
|
||||
if len(orgs) == 1 {
|
||||
// If there is no "isDefault", but only 1 org is present. We can just
|
||||
// assume the single organization is correct. This is mainly a helper
|
||||
// for cli hitting an old instance, or a user that belongs to a single
|
||||
// org that is not the default.
|
||||
return orgs[0], nil
|
||||
}
|
||||
return codersdk.Organization{}, xerrors.Errorf("unable to determine current organization. Use 'coder org set <org>' to select an organization to use")
|
||||
}
|
||||
|
||||
return orgs[index], nil
|
||||
|
||||
Reference in New Issue
Block a user