Skip to content

Commit 0da08b1

Browse files
committed
Address review comments
Signed-off-by: Timo Sand <[email protected]>
1 parent cecf36c commit 0da08b1

1 file changed

Lines changed: 7 additions & 22 deletions

File tree

github/resource_github_emu_group_mapping.go

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ func resourceGithubEMUGroupMapping() *schema.Resource {
6464
}
6565

6666
func resourceGithubEMUGroupMappingCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
67-
resourceID := d.Id()
68-
tflog.Trace(ctx, "Creating EMU group mapping", map[string]any{
69-
"resource_id": resourceID,
70-
})
67+
tflog.Trace(ctx, "Creating EMU group mapping")
7168

7269
err := checkOrganization(meta)
7370
if err != nil {
@@ -100,12 +97,12 @@ func resourceGithubEMUGroupMappingCreate(ctx context.Context, d *schema.Resource
10097
return diag.FromErr(err)
10198
}
10299

103-
if err := d.Set("team_id", teamID); err != nil {
100+
newResourceID, err := buildID(strconv.FormatInt(teamID, 10), teamSlug, strconv.FormatInt(groupID, 10))
101+
if err != nil {
104102
return diag.FromErr(err)
105103
}
106104

107-
newResourceID, err := buildID(strconv.FormatInt(teamID, 10), teamSlug, strconv.FormatInt(groupID, 10))
108-
if err != nil {
105+
if err := d.Set("team_id", teamID); err != nil {
109106
return diag.FromErr(err)
110107
}
111108

@@ -207,24 +204,12 @@ func resourceGithubEMUGroupMappingRead(ctx context.Context, d *schema.ResourceDa
207204
return diag.FromErr(err)
208205
}
209206

210-
teamID, err := lookupTeamID(ctx, meta.(*Owner), teamSlug)
211-
if err != nil {
212-
return diag.FromErr(err)
213-
}
214-
if teamID != toInt64(d.Get("team_id")) {
215-
return diag.Errorf("configured Team does not match with any team mapped to external group: %d != %d", teamID, toInt64(d.Get("team_id")))
216-
}
217-
if err := d.Set("team_id", teamID); err != nil {
218-
return diag.FromErr(err)
219-
}
220-
221207
return nil
222208
}
223209

224210
func resourceGithubEMUGroupMappingUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
225-
resourceID := d.Id()
226211
tflog.Trace(ctx, "Updating EMU group mapping", map[string]any{
227-
"resource_id": resourceID,
212+
"resource_id": d.Id(),
228213
})
229214

230215
err := checkOrganization(meta)
@@ -331,8 +316,8 @@ func resourceGithubEMUGroupMappingImport(ctx context.Context, d *schema.Resource
331316
"strategy": "two_part_id",
332317
})
333318

334-
// <team-slug>:<group-id>
335-
teamSlug, groupIDString, err := parseID2(d.Id())
319+
// <group-id>:<team-slug>
320+
groupIDString, teamSlug, err := parseID2(d.Id())
336321
if err != nil {
337322
return nil, err
338323
}

0 commit comments

Comments
 (0)