@@ -225,15 +225,8 @@ func (r *OrganizationGroupSyncResource) Delete(ctx context.Context, req resource
225
225
"organization_id" : orgID ,
226
226
})
227
227
228
- // Disable group sync by setting field to empty string
229
- var groupSync codersdk.GroupSyncSettings
230
- groupSync .Field = "" // Empty field disables group sync
231
- groupSync .AutoCreateMissing = false
232
- groupSync .Mapping = make (map [string ][]uuid.UUID )
233
- groupSync .RegexFilter = nil
234
-
235
- // Perform the PATCH to disable group sync
236
- _ , err := r .Client .PatchGroupIDPSyncSettings (ctx , orgID .String (), groupSync )
228
+ // Sending all zero-values will delete the group sync configuration
229
+ _ , err := r .Client .PatchGroupIDPSyncSettings (ctx , orgID .String (), codersdk.GroupSyncSettings {})
237
230
if err != nil {
238
231
if isNotFound (err ) {
239
232
// Organization doesn't exist, so group sync is already "deleted"
@@ -256,16 +249,16 @@ func (r *OrganizationGroupSyncResource) patchGroupSync(
256
249
) diag.Diagnostics {
257
250
var diags diag.Diagnostics
258
251
259
- var groupSync codersdk.GroupSyncSettings
260
- groupSync .Field = data .Field .ValueString ()
252
+ groupSync := codersdk.GroupSyncSettings {
253
+ Field : data .Field .ValueString (),
254
+ AutoCreateMissing : data .AutoCreateMissing .ValueBool (),
255
+ Mapping : make (map [string ][]uuid.UUID ),
256
+ }
261
257
262
258
if ! data .RegexFilter .IsNull () {
263
259
groupSync .RegexFilter = regexp .MustCompile (data .RegexFilter .ValueString ())
264
260
}
265
261
266
- groupSync .AutoCreateMissing = data .AutoCreateMissing .ValueBool ()
267
- groupSync .Mapping = make (map [string ][]uuid.UUID )
268
-
269
262
// Mapping is required, so always process it (can be empty)
270
263
// Terraform doesn't know how to turn one our `UUID` Terraform values into a
271
264
// `uuid.UUID`, so we have to do the unwrapping manually here.
0 commit comments