Skip to content

Commit 11fc028

Browse files
authored
feat: Refactor repository collaborators (#3233)
Signed-off-by: Steve Hipwell <steve.hipwell@gmail.com>
1 parent 080c081 commit 11fc028

17 files changed

+1446
-1103
lines changed

github/resource_github_emu_group_mapping.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func resourceGithubEMUGroupMappingCreate(ctx context.Context, d *schema.Resource
8989

9090
tflog.Debug(ctx, "Successfully updated connected external group")
9191

92-
teamID, err := lookupTeamID(ctx, meta.(*Owner), teamSlug)
92+
teamID, err := lookupTeamID(ctx, client, orgName, teamSlug)
9393
if err != nil {
9494
return diag.FromErr(err)
9595
}
@@ -306,7 +306,11 @@ func resourceGithubEMUGroupMappingDelete(ctx context.Context, d *schema.Resource
306306
return nil
307307
}
308308

309-
func resourceGithubEMUGroupMappingImport(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
309+
func resourceGithubEMUGroupMappingImport(ctx context.Context, d *schema.ResourceData, m any) ([]*schema.ResourceData, error) {
310+
meta := m.(*Owner)
311+
client := meta.v3client
312+
orgName := meta.name
313+
310314
importID := d.Id()
311315
tflog.Trace(ctx, "Importing EMU group mapping with two-part ID", map[string]any{
312316
"import_id": importID,
@@ -329,7 +333,7 @@ func resourceGithubEMUGroupMappingImport(ctx context.Context, d *schema.Resource
329333
"team_slug": teamSlug,
330334
})
331335

332-
teamID, err := lookupTeamID(ctx, meta.(*Owner), teamSlug)
336+
teamID, err := lookupTeamID(ctx, client, orgName, teamSlug)
333337
if err != nil {
334338
return nil, err
335339
}

github/resource_github_emu_group_mapping_migration.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ func resourceGithubEMUGroupMappingV0() *schema.Resource {
3131
}
3232

3333
func resourceGithubEMUGroupMappingStateUpgradeV0(ctx context.Context, rawState map[string]any, meta any) (map[string]any, error) {
34+
client := meta.(*Owner).v3client
3435
orgName := meta.(*Owner).name
3536
tflog.Trace(ctx, "GitHub EMU Group Mapping State before migration", map[string]any{"state": rawState, "owner": orgName})
3637

37-
client := meta.(*Owner).v3client
38-
3938
teamSlug := rawState["team_slug"].(string)
4039
// We need to bypass the etag because we need to get the latest group
4140
ctx = context.WithValue(ctx, ctxEtag, nil)
@@ -52,7 +51,7 @@ func resourceGithubEMUGroupMappingStateUpgradeV0(ctx context.Context, rawState m
5251
}
5352

5453
group := groupsList.Groups[0]
55-
teamID, err := lookupTeamID(ctx, meta.(*Owner), teamSlug)
54+
teamID, err := lookupTeamID(ctx, client, orgName, teamSlug)
5655
if err != nil {
5756
return nil, err
5857
}

0 commit comments

Comments
 (0)