@@ -10,6 +10,15 @@ import (
1010 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
1111)
1212
13+ const (
14+ teamIDKey = "team_id"
15+ teamSlugKey = "slug"
16+ teamNameKey = "name"
17+ teamDescriptionKey = "description"
18+ teamOrganizationSelectionKey = "organization_selection_type"
19+ teamGroupIDKey = "group_id"
20+ )
21+
1322func dataSourceGithubEnterpriseTeams () * schema.Resource {
1423 return & schema.Resource {
1524 Description : "Lists all GitHub enterprise teams in an enterprise." ,
@@ -28,32 +37,32 @@ func dataSourceGithubEnterpriseTeams() *schema.Resource {
2837 Description : "All teams in the enterprise." ,
2938 Elem : & schema.Resource {
3039 Schema : map [string ]* schema.Schema {
31- "team_id" : {
40+ teamIDKey : {
3241 Type : schema .TypeInt ,
3342 Computed : true ,
3443 Description : "The numeric ID of the enterprise team." ,
3544 },
36- "slug" : {
45+ teamSlugKey : {
3746 Type : schema .TypeString ,
3847 Computed : true ,
3948 Description : "The slug of the enterprise team." ,
4049 },
41- "name" : {
50+ teamNameKey : {
4251 Type : schema .TypeString ,
4352 Computed : true ,
4453 Description : "The name of the enterprise team." ,
4554 },
46- "description" : {
55+ teamDescriptionKey : {
4756 Type : schema .TypeString ,
4857 Computed : true ,
4958 Description : "A description of the enterprise team." ,
5059 },
51- "organization_selection_type" : {
60+ teamOrganizationSelectionKey : {
5261 Type : schema .TypeString ,
5362 Computed : true ,
5463 Description : "Specifies which organizations in the enterprise should have access to this team." ,
5564 },
56- "group_id" : {
65+ teamGroupIDKey : {
5766 Type : schema .TypeString ,
5867 Computed : true ,
5968 Description : "The ID of the IdP group to assign team membership with." ,
@@ -76,14 +85,14 @@ func dataSourceGithubEnterpriseTeamsRead(ctx context.Context, d *schema.Resource
7685 flat := make ([]any , 0 , len (teams ))
7786 for _ , t := range teams {
7887 m := map [string ]any {
79- "team_id" : int (t .ID ),
80- "slug" : t .Slug ,
81- "name" : t .Name ,
88+ teamIDKey : int (t .ID ),
89+ teamSlugKey : t .Slug ,
90+ teamNameKey : t .Name ,
8291 }
8392 if t .Description != nil {
84- m ["description" ] = * t .Description
93+ m [teamDescriptionKey ] = * t .Description
8594 } else {
86- m ["description" ] = ""
95+ m [teamDescriptionKey ] = ""
8796 }
8897 orgSel := ""
8998 if t .OrganizationSelectionType != nil {
@@ -92,11 +101,11 @@ func dataSourceGithubEnterpriseTeamsRead(ctx context.Context, d *schema.Resource
92101 if orgSel == "" {
93102 orgSel = "disabled"
94103 }
95- m ["organization_selection_type" ] = orgSel
104+ m [teamOrganizationSelectionKey ] = orgSel
96105 if t .GroupID != "" {
97- m ["group_id" ] = t .GroupID
106+ m [teamGroupIDKey ] = t .GroupID
98107 } else {
99- m ["group_id" ] = ""
108+ m [teamGroupIDKey ] = ""
100109 }
101110 flat = append (flat , m )
102111 }
0 commit comments