@@ -225,15 +225,8 @@ func (r *OrganizationGroupSyncResource) Delete(ctx context.Context, req resource
225225 "organization_id" : orgID ,
226226 })
227227
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 {})
237230 if err != nil {
238231 if isNotFound (err ) {
239232 // Organization doesn't exist, so group sync is already "deleted"
@@ -256,16 +249,16 @@ func (r *OrganizationGroupSyncResource) patchGroupSync(
256249) diag.Diagnostics {
257250 var diags diag.Diagnostics
258251
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+ }
261257
262258 if ! data .RegexFilter .IsNull () {
263259 groupSync .RegexFilter = regexp .MustCompile (data .RegexFilter .ValueString ())
264260 }
265261
266- groupSync .AutoCreateMissing = data .AutoCreateMissing .ValueBool ()
267- groupSync .Mapping = make (map [string ][]uuid.UUID )
268-
269262 // Mapping is required, so always process it (can be empty)
270263 // Terraform doesn't know how to turn one our `UUID` Terraform values into a
271264 // `uuid.UUID`, so we have to do the unwrapping manually here.
0 commit comments