Skip to content

Commit f5c8a7a

Browse files
bpaquetkfcampbell
andauthored
Improve github team resource (#1722)
Co-authored-by: Keegan Campbell <me@kfcampbell.com>
1 parent a4d57ba commit f5c8a7a

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

github/resource_github_team.go

+23-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,24 @@ func resourceGithubTeam() *schema.Resource {
5050
Type: schema.TypeString,
5151
Optional: true,
5252
Description: "The ID or slug of the parent team, if this is a nested team.",
53+
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
54+
if d.Get("parent_team_id") == d.Get("parent_team_read_id") || d.Get("parent_team_id") == d.Get("parent_team_read_slug") {
55+
return true
56+
}
57+
return false
58+
},
59+
},
60+
"parent_team_read_id": {
61+
Type: schema.TypeString,
62+
Optional: true,
63+
Computed: true,
64+
Description: "The id of the parent team read in Github.",
65+
},
66+
"parent_team_read_slug": {
67+
Type: schema.TypeString,
68+
Optional: true,
69+
Computed: true,
70+
Description: "The id of the parent team read in Github.",
5371
},
5472
"ldap_dn": {
5573
Type: schema.TypeString,
@@ -196,7 +214,9 @@ func resourceGithubTeamRead(d *schema.ResourceData, meta interface{}) error {
196214
d.Set("name", team.GetName())
197215
d.Set("privacy", team.GetPrivacy())
198216
if parent := team.Parent; parent != nil {
199-
d.Set("parent_team_id", parent.GetID())
217+
d.Set("parent_team_id", strconv.FormatInt(team.Parent.GetID(), 10))
218+
d.Set("parent_team_read_id", strconv.FormatInt(team.Parent.GetID(), 10))
219+
d.Set("parent_team_read_slug", parent.Slug)
200220
} else {
201221
d.Set("parent_team_id", "")
202222
}
@@ -305,6 +325,8 @@ func resourceGithubTeamImport(d *schema.ResourceData, meta interface{}) ([]*sche
305325
}
306326

307327
d.SetId(strconv.FormatInt(teamId, 10))
328+
d.Set("create_default_maintainer", false)
329+
308330
return []*schema.ResourceData{d}, nil
309331
}
310332

0 commit comments

Comments
 (0)