Skip to content

Commit 1941bfd

Browse files
committed
review
1 parent 2fb0bd4 commit 1941bfd

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

internal/provider/organization_group_sync_resource.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy