Skip to content

Commit 2a17feb

Browse files
Fixing enterprise id reference (#2274)
Co-authored-by: Keegan Campbell <[email protected]>
1 parent 5ce4588 commit 2a17feb

4 files changed

+36
-51
lines changed

github/resource_github_enterprise_actions_permissions.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ func resourceGithubActionsEnterprisePermissions() *schema.Resource {
2020
},
2121

2222
Schema: map[string]*schema.Schema{
23-
"enterprise_id": {
23+
"enterprise_slug": {
2424
Type: schema.TypeString,
2525
Required: true,
2626
ForceNew: true,
27-
Description: "The ID of the enterprise.",
27+
Description: "The slug of the enterprise.",
2828
},
2929
"allowed_actions": {
3030
Type: schema.TypeString,
@@ -145,7 +145,7 @@ func resourceGithubActionsEnterprisePermissionsCreateOrUpdate(d *schema.Resource
145145
ctx = context.WithValue(ctx, ctxId, d.Id())
146146
}
147147

148-
enterpriseId := d.Get("enterprise_id").(string)
148+
enterpriseId := d.Get("enterprise_slug").(string)
149149
allowedActions := d.Get("allowed_actions").(string)
150150
enabledOrganizations := d.Get("enabled_organizations").(string)
151151

@@ -264,6 +264,9 @@ func resourceGithubActionsEnterprisePermissionsRead(d *schema.ResourceData, meta
264264
if err = d.Set("enabled_organizations", actionsPermissions.GetEnabledOrganizations()); err != nil {
265265
return err
266266
}
267+
if err = d.Set("enterprise_slug", d.Id()); err != nil {
268+
return err
269+
}
267270

268271
return nil
269272
}
@@ -275,7 +278,7 @@ func resourceGithubActionsEnterprisePermissionsDelete(d *schema.ResourceData, me
275278

276279
// This will nullify any allowedActions elements
277280
_, _, err := client.Actions.EditActionsPermissionsInEnterprise(ctx,
278-
d.Get("enterprise_id").(string),
281+
d.Get("enterprise_slug").(string),
279282
github.ActionsPermissionsEnterprise{
280283
AllowedActions: github.String("all"),
281284
EnabledOrganizations: github.String("all"),

github/resource_github_enterprise_actions_permissions_test.go

+24-38
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ func TestAccGithubActionsEnterprisePermissions(t *testing.T) {
1616
enabledOrganizations := "all"
1717

1818
config := fmt.Sprintf(`
19-
data "github_enterprise" "enterprise" {
20-
slug = "%s"
21-
}
22-
2319
resource "github_enterprise_actions_permissions" "test" {
24-
enterprise_id = data.github_enterprise.enterprise.id
20+
enterprise_slug = "%s"
2521
allowed_actions = "%s"
2622
enabled_organizations = "%s"
2723
}
@@ -74,27 +70,23 @@ func TestAccGithubActionsEnterprisePermissions(t *testing.T) {
7470
desc := "Initial org description"
7571

7672
config := fmt.Sprintf(`
77-
data "github_enterprise" "enterprise" {
78-
slug = "%s"
79-
}
80-
8173
data "github_user" "current" {
8274
username = ""
8375
}
8476
8577
resource "github_enterprise_organization" "org" {
86-
enterprise_id = data.github_enterprise.enterprise.id
87-
name = "%s"
88-
display_name = "%s"
89-
description = "%s"
90-
billing_email = data.github_user.current.email
91-
admin_logins = [
78+
enterprise_slug = "%s"
79+
name = "%s"
80+
display_name = "%s"
81+
description = "%s"
82+
billing_email = data.github_user.current.email
83+
admin_logins = [
9284
data.github_user.current.login
9385
]
9486
}
9587
9688
resource "github_enterprise_actions_permissions" "test" {
97-
enterprise_id = data.github_enterprise.enterprise.id
89+
enterprise_slug = "%s"
9890
allowed_actions = "%s"
9991
enabled_organizations = "%s"
10092
allowed_actions_config {
@@ -106,7 +98,7 @@ func TestAccGithubActionsEnterprisePermissions(t *testing.T) {
10698
organization_ids = [github_enterprise_organization.org.id]
10799
}
108100
}
109-
`, testEnterprise, orgName, displayName, desc, allowedActions, enabledOrganizations, githubOwnedAllowed, verifiedAllowed)
101+
`, testEnterprise, orgName, displayName, desc, testEnterprise, allowedActions, enabledOrganizations, githubOwnedAllowed, verifiedAllowed)
110102

111103
check := resource.ComposeTestCheckFunc(
112104
resource.TestCheckResourceAttr(
@@ -160,11 +152,8 @@ func TestAccGithubActionsEnterprisePermissions(t *testing.T) {
160152
verifiedAllowed := true
161153

162154
config := fmt.Sprintf(`
163-
data "github_enterprise" "enterprise" {
164-
slug = "%s"
165-
}
166155
resource "github_enterprise_actions_permissions" "test" {
167-
enterprise_id = data.github_enterprise.enterprise.id
156+
enterprise_slug = "%s"
168157
allowed_actions = "%s"
169158
enabled_organizations = "%s"
170159
allowed_actions_config {
@@ -227,41 +216,38 @@ func TestAccGithubActionsEnterprisePermissions(t *testing.T) {
227216
desc2 := fmt.Sprintf("Initial org description %s", randomID2)
228217

229218
config := fmt.Sprintf(`
230-
data "github_enterprise" "enterprise" {
231-
slug = "%s"
232-
}
233219
data "github_user" "current" {
234220
username = ""
235221
}
236222
resource "github_enterprise_organization" "org" {
237-
enterprise_id = data.github_enterprise.enterprise.id
238-
name = "%s"
239-
display_name = "%s"
240-
description = "%s"
241-
billing_email = data.github_user.current.email
242-
admin_logins = [
223+
enterprise_slug = "%s"
224+
name = "%s"
225+
display_name = "%s"
226+
description = "%s"
227+
billing_email = data.github_user.current.email
228+
admin_logins = [
243229
data.github_user.current.login
244230
]
245231
}
246232
resource "github_enterprise_organization" "org2" {
247-
enterprise_id = data.github_enterprise.enterprise.id
248-
name = "%s"
249-
display_name = "%s"
250-
description = "%s"
251-
billing_email = data.github_user.current.email
252-
admin_logins = [
233+
enterprise_slug = "%s"
234+
name = "%s"
235+
display_name = "%s"
236+
description = "%s"
237+
billing_email = data.github_user.current.email
238+
admin_logins = [
253239
data.github_user.current.login
254240
]
255241
}
256242
resource "github_enterprise_actions_permissions" "test" {
257-
enterprise_id = data.github_enterprise.enterprise.id
243+
enterprise_slug = "%s"
258244
allowed_actions = "%s"
259245
enabled_organizations = "%s"
260246
enabled_organizations_config {
261247
organization_ids = [github_enterprise_organization.org.id, github_enterprise_organization.org2.id]
262248
}
263249
}
264-
`, testEnterprise, orgName, displayName, desc, orgName2, displayName2, desc2, allowedActions, enabledOrganizations)
250+
`, testEnterprise, orgName, displayName, desc, testEnterprise, orgName2, displayName2, desc2, testEnterprise, allowedActions, enabledOrganizations)
265251

266252
check := resource.ComposeTestCheckFunc(
267253
resource.TestCheckResourceAttr(

website/docs/r/enterprise_actions_permissions.html.markdown

+5-9
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@ You must have admin access to an enterprise to use this resource.
1313
## Example Usage
1414

1515
```hcl
16-
data "github_enterprise" "example-enterprise" {
17-
slug = "my-enterprise"
18-
}
19-
2016
data "github_organization" "example-org" {
2117
name = "my-org"
2218
}
2319
2420
resource "github_enterprise_actions_permissions" "test" {
25-
enterprise_id = data.github_enterprise.example-enterprise.slug
21+
enterprise_slug = "my-enterprise"
2622
allowed_actions = "selected"
2723
enabled_organizations = "selected"
2824
allowed_actions_config {
@@ -39,10 +35,10 @@ resource "github_enterprise_actions_permissions" "test" {
3935
## Argument Reference
4036

4137
The following arguments are supported:
42-
* `enterprise_id` - (Required) The ID of the enterprise.
43-
* `allowed_actions` - (Optional) The permissions policy that controls the actions that are allowed to run. Can be one of: `all`, `local_only`, or `selected`.
44-
* `enabled_organizations` - (Required) The policy that controls the organizations in the enterprise that are allowed to run GitHub Actions. Can be one of: `all`, `none`, or `selected`.
45-
* `allowed_actions_config` - (Optional) Sets the actions that are allowed in an enterprise. Only available when `allowed_actions` = `selected`. See [Allowed Actions Config](#allowed-actions-config) below for details.
38+
* `"my-enterprise"` - (Required) The slug of the enterprise.
39+
* `allowed_actions` - (Optional) The permissions policy that controls the actions that are allowed to run. Can be one of: `all`, `local_only`, or `selected`.
40+
* `enabled_organizations` - (Required) The policy that controls the organizations in the enterprise that are allowed to run GitHub Actions. Can be one of: `all`, `none`, or `selected`.
41+
* `allowed_actions_config` - (Optional) Sets the actions that are allowed in an enterprise. Only available when `allowed_actions` = `selected`. See [Allowed Actions Config](#allowed-actions-config) below for details.
4642
* `enabled_organizations_config` - (Optional) Sets the list of selected organizations that are enabled for GitHub Actions in an enterprise. Only available when `enabled_organizations` = `selected`. See [Enabled Organizations Config](#enabled-organizations-config) below for details.
4743

4844
### Allowed Actions Config

0 commit comments

Comments
 (0)