@@ -48,6 +48,23 @@ func (r *RootCmd) organizationSettings(orgContext *OrganizationContext) *serpent
48
48
return cli .RoleIDPSyncSettings (ctx , org .String ())
49
49
},
50
50
},
51
+ {
52
+ Name : "organization-sync" ,
53
+ Aliases : []string {"organizationsync" , "org-sync" , "orgsync" },
54
+ Short : "Organization sync settings to sync organization memberships from an IdP." ,
55
+ DisableOrgContext : true ,
56
+ Patch : func (ctx context.Context , cli * codersdk.Client , _ uuid.UUID , input json.RawMessage ) (any , error ) {
57
+ var req codersdk.OrganizationSyncSettings
58
+ err := json .Unmarshal (input , & req )
59
+ if err != nil {
60
+ return nil , xerrors .Errorf ("unmarshalling organization sync settings: %w" , err )
61
+ }
62
+ return cli .PatchOrganizationIDPSyncSettings (ctx , req )
63
+ },
64
+ Fetch : func (ctx context.Context , cli * codersdk.Client , _ uuid.UUID ) (any , error ) {
65
+ return cli .OrganizationIDPSyncSettings (ctx )
66
+ },
67
+ },
51
68
}
52
69
cmd := & serpent.Command {
53
70
Use : "settings" ,
@@ -68,8 +85,13 @@ type organizationSetting struct {
68
85
Name string
69
86
Aliases []string
70
87
Short string
71
- Patch func (ctx context.Context , cli * codersdk.Client , org uuid.UUID , input json.RawMessage ) (any , error )
72
- Fetch func (ctx context.Context , cli * codersdk.Client , org uuid.UUID ) (any , error )
88
+ // DisableOrgContext is kinda a kludge. It tells the command constructor
89
+ // to not require an organization context. This is used for the organization
90
+ // sync settings which are not tied to a specific organization.
91
+ // It feels excessive to build a more elaborate solution for this one-off.
92
+ DisableOrgContext bool
93
+ Patch func (ctx context.Context , cli * codersdk.Client , org uuid.UUID , input json.RawMessage ) (any , error )
94
+ Fetch func (ctx context.Context , cli * codersdk.Client , org uuid.UUID ) (any , error )
73
95
}
74
96
75
97
func (r * RootCmd ) setOrganizationSettings (orgContext * OrganizationContext , settings []organizationSetting ) * serpent.Command {
@@ -107,9 +129,14 @@ func (r *RootCmd) setOrganizationSettings(orgContext *OrganizationContext, setti
107
129
),
108
130
Handler : func (inv * serpent.Invocation ) error {
109
131
ctx := inv .Context ()
110
- org , err := orgContext .Selected (inv , client )
111
- if err != nil {
112
- return err
132
+ var org codersdk.Organization
133
+ var err error
134
+
135
+ if ! set .DisableOrgContext {
136
+ org , err = orgContext .Selected (inv , client )
137
+ if err != nil {
138
+ return err
139
+ }
113
140
}
114
141
115
142
// Read in the json
@@ -178,9 +205,14 @@ func (r *RootCmd) printOrganizationSetting(orgContext *OrganizationContext, sett
178
205
),
179
206
Handler : func (inv * serpent.Invocation ) error {
180
207
ctx := inv .Context ()
181
- org , err := orgContext .Selected (inv , client )
182
- if err != nil {
183
- return err
208
+ var org codersdk.Organization
209
+ var err error
210
+
211
+ if ! set .DisableOrgContext {
212
+ org , err = orgContext .Selected (inv , client )
213
+ if err != nil {
214
+ return err
215
+ }
184
216
}
185
217
186
218
output , err := fetch (ctx , client , org .ID )
0 commit comments