mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: create workspaces and templates for multiple orgs (#13866)
* chore: creating workspaces and templates to work with orgs * handle wrong org selected * create org member in coderdtest helper
This commit is contained in:
+10
-1
@@ -641,9 +641,10 @@ func NewOrganizationContext() *OrganizationContext {
|
||||
return &OrganizationContext{}
|
||||
}
|
||||
|
||||
func (*OrganizationContext) optionName() string { return "Organization" }
|
||||
func (o *OrganizationContext) AttachOptions(cmd *serpent.Command) {
|
||||
cmd.Options = append(cmd.Options, serpent.Option{
|
||||
Name: "Organization",
|
||||
Name: o.optionName(),
|
||||
Description: "Select which organization (uuid or name) to use.",
|
||||
// Only required if the user is a part of more than 1 organization.
|
||||
// Otherwise, we can assume a default value.
|
||||
@@ -655,6 +656,14 @@ func (o *OrganizationContext) AttachOptions(cmd *serpent.Command) {
|
||||
})
|
||||
}
|
||||
|
||||
func (o *OrganizationContext) ValueSource(inv *serpent.Invocation) (string, serpent.ValueSource) {
|
||||
opt := inv.Command.Options.ByName(o.optionName())
|
||||
if opt == nil {
|
||||
return o.FlagSelect, serpent.ValueSourceNone
|
||||
}
|
||||
return o.FlagSelect, opt.ValueSource
|
||||
}
|
||||
|
||||
func (o *OrganizationContext) Selected(inv *serpent.Invocation, client *codersdk.Client) (codersdk.Organization, error) {
|
||||
// Fetch the set of organizations the user is a member of.
|
||||
orgs, err := client.OrganizationsByUser(inv.Context(), codersdk.Me)
|
||||
|
||||
Reference in New Issue
Block a user