Skip to content

Commit b25f691

Browse files
committed
Use lookupTeamID instead of getTeamID
Signed-off-by: Timo Sand <[email protected]>
1 parent 9c10e70 commit b25f691

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

github/resource_github_emu_group_mapping.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func resourceGithubEMUGroupMappingImport(ctx context.Context, d *schema.Resource
362362
"team_slug": teamSlug,
363363
})
364364

365-
teamID, err := getTeamID(teamSlug, meta)
365+
teamID, err := lookupTeamID(ctx, meta.(*Owner), teamSlug)
366366
if err != nil {
367367
return nil, err
368368
}
@@ -429,7 +429,7 @@ func hasNewTeamID(ctx context.Context, diff *schema.ResourceDiff, meta any) bool
429429

430430
// Resolve new team_slug to team ID via API
431431
oldTeamSlug, newTeamSlug := diff.GetChange("team_slug")
432-
newTeamID, err := getTeamID(newTeamSlug.(string), meta)
432+
newTeamID, err := lookupTeamID(ctx, meta.(*Owner), newTeamSlug.(string))
433433
if err != nil {
434434
// If team doesn't exist or API fails, skip ForceNew check and let Read handle it
435435
tflog.Debug(ctx, "Unable to resolve new team_slug to team ID, skipping ForceNew check", map[string]any{

github/util.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,15 @@ func toInt64(v any) int64 {
359359
return 0
360360
}
361361
}
362+
363+
// lookupTeamID looks up the ID of a team by its slug.
364+
func lookupTeamID(ctx context.Context, meta *Owner, slug string) (int64, error) {
365+
client := meta.v3client
366+
owner := meta.name
367+
368+
team, _, err := client.Teams.GetTeamBySlug(ctx, owner, slug)
369+
if err != nil {
370+
return 0, err
371+
}
372+
return team.GetID(), nil
373+
}

0 commit comments

Comments
 (0)