Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions github/resource_github_actions_organization_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
Optional: true,
Description: "Whether actions in GitHub Marketplace from verified creators are allowed. Set to 'true' to allow all GitHub Marketplace actions by verified creators.",
},
"sha_pinning_required": {
Type: schema.TypeBool,
Optional: true,
Description: "Whether pinning to a specific SHA is required for all actions and reusable workflows in an organization.",
},
},
},
},
Expand Down Expand Up @@ -96,6 +101,10 @@
allowed.VerifiedAllowed = &x
}

if v, ok := data["sha_pinning_required"]; ok {
allowed.SHAPinningRequired = github.Bool(v.(bool))

Check failure on line 105 in github/resource_github_actions_organization_permissions.go

View workflow job for this annotation

GitHub Actions / Continuous Integration

allowed.SHAPinningRequired undefined (type *"github.com/google/go-github/v67/github".ActionsAllowed has no field or method SHAPinningRequired)
}

patternsAllowed := []string{}

switch t := data["patterns_allowed"].(type) {
Expand Down Expand Up @@ -226,6 +235,7 @@
"github_owned_allowed": actionsAllowed.GetGithubOwnedAllowed(),
"patterns_allowed": actionsAllowed.PatternsAllowed,
"verified_allowed": actionsAllowed.GetVerifiedAllowed(),
"sha_pinning_required": actionsAllowed.GetShaPinningRequired(),

Check failure on line 238 in github/resource_github_actions_organization_permissions.go

View workflow job for this annotation

GitHub Actions / Continuous Integration

actionsAllowed.GetShaPinningRequired undefined (type *"github.com/google/go-github/v67/github".ActionsAllowed has no field or method GetShaPinningRequired)
},
}); err != nil {
return err
Expand Down Expand Up @@ -306,3 +316,19 @@

return nil
}

func flattenActionsAllowed(d *schema.ResourceData, actionsAllowed *github.ActionsAllowed) error {
if actionsAllowed != nil {
config := make(map[string]interface{})
config["github_owned_allowed"] = actionsAllowed.GetGithubOwnedAllowed()
config["verified_allowed"] = actionsAllowed.GetVerifiedAllowed()
config["patterns_allowed"] = schema.NewSet(schema.HashString, interfaceSlice(actionsAllowed.GetPatternsAllowed()))

Check failure on line 325 in github/resource_github_actions_organization_permissions.go

View workflow job for this annotation

GitHub Actions / Continuous Integration

actionsAllowed.GetPatternsAllowed undefined (type *"github.com/google/go-github/v67/github".ActionsAllowed has no field or method GetPatternsAllowed)

Check failure on line 325 in github/resource_github_actions_organization_permissions.go

View workflow job for this annotation

GitHub Actions / Continuous Integration

undefined: interfaceSlice
config["sha_pinning_required"] = actionsAllowed.GetShaPinningRequired()

Check failure on line 326 in github/resource_github_actions_organization_permissions.go

View workflow job for this annotation

GitHub Actions / Continuous Integration

actionsAllowed.GetShaPinningRequired undefined (type *"github.com/google/go-github/v67/github".ActionsAllowed has no field or method GetShaPinningRequired)

if err := d.Set("allowed_actions_config", []interface{}{config}); err != nil {
return err
}
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestAccGithubActionsOrganizationPermissions(t *testing.T) {
enabledRepositories := "selected"
githubOwnedAllowed := true
verifiedAllowed := true
shaPinningRequired := true
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)

config := fmt.Sprintf(`
Expand All @@ -68,12 +69,13 @@ func TestAccGithubActionsOrganizationPermissions(t *testing.T) {
github_owned_allowed = %t
patterns_allowed = ["actions/cache@*", "actions/checkout@*"]
verified_allowed = %t
sha_pinning_required = %t
}
enabled_repositories_config {
repository_ids = [github_repository.test.repo_id]
}
}
`, randomID, allowedActions, enabledRepositories, githubOwnedAllowed, verifiedAllowed)
`, randomID, allowedActions, enabledRepositories, githubOwnedAllowed, verifiedAllowed, shaPinningRequired)

check := resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
Expand Down
10 changes: 10 additions & 0 deletions github/resource_github_actions_repository_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
Optional: true,
Description: "Whether actions in GitHub Marketplace from verified creators are allowed. Set to 'true' to allow all GitHub Marketplace actions by verified creators.",
},
"sha_pinning_required": {
Type: schema.TypeBool,
Optional: true,
Description: "Whether pinning to a specific SHA is required for all actions and reusable workflows in a repository.",
},
},
},
},
Expand Down Expand Up @@ -85,6 +90,10 @@
allowed.VerifiedAllowed = &x
}

if v, ok := data["sha_pinning_required"]; ok {
allowed.SHAPinningRequired = github.Bool(v.(bool))

Check failure on line 94 in github/resource_github_actions_repository_permissions.go

View workflow job for this annotation

GitHub Actions / Continuous Integration

allowed.SHAPinningRequired undefined (type *"github.com/google/go-github/v67/github".ActionsAllowed has no field or method SHAPinningRequired)
}

patternsAllowed := []string{}

switch t := data["patterns_allowed"].(type) {
Expand Down Expand Up @@ -189,6 +198,7 @@
"github_owned_allowed": actionsAllowed.GetGithubOwnedAllowed(),
"patterns_allowed": actionsAllowed.PatternsAllowed,
"verified_allowed": actionsAllowed.GetVerifiedAllowed(),
"sha_pinning_required": actionsAllowed.GetShaPinningRequired(),

Check failure on line 201 in github/resource_github_actions_repository_permissions.go

View workflow job for this annotation

GitHub Actions / Continuous Integration

actionsAllowed.GetShaPinningRequired undefined (type *"github.com/google/go-github/v67/github".ActionsAllowed has no field or method GetShaPinningRequired)) (typecheck)
},
}); err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func TestAccGithubActionsRepositoryPermissions(t *testing.T) {
allowedActions := "selected"
githubOwnedAllowed := true
verifiedAllowed := true
shaPinningRequired := true
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)

config := fmt.Sprintf(`
Expand All @@ -77,10 +78,11 @@ func TestAccGithubActionsRepositoryPermissions(t *testing.T) {
github_owned_allowed = %t
patterns_allowed = ["actions/cache@*", "actions/checkout@*"]
verified_allowed = %t
sha_pinning_required = %t
}
repository = github_repository.test.name
}
`, randomID, allowedActions, githubOwnedAllowed, verifiedAllowed)
`, randomID, allowedActions, githubOwnedAllowed, verifiedAllowed, shaPinningRequired)

check := resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ require (
github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e // indirect
github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-github/v79 v79.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gordonklaus/ineffassign v0.2.0 // indirect
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/go-github/v67 v67.0.0 h1:g11NDAmfaBaCO8qYdI9fsmbaRipHNWRIU/2YGvlh4rg=
github.com/google/go-github/v67 v67.0.0/go.mod h1:zH3K7BxjFndr9QSeFibx4lTKkYS3K9nDanoI1NjaOtY=
github.com/google/go-github/v79 v79.0.0 h1:MdodQojuFPBhmtwHiBcIGLw/e/wei2PvFX9ndxK0X4Y=
github.com/google/go-github/v79 v79.0.0/go.mod h1:OAFbNhq7fQwohojb06iIIQAB9CBGYLq999myfUFnrS4=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down
2 changes: 2 additions & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ github.com/google/go-cmp/cmp/internal/value
# github.com/google/go-github/v67 v67.0.0
## explicit; go 1.21
github.com/google/go-github/v67/github
# github.com/google/go-github/v79 v79.0.0
## explicit; go 1.24.0
# github.com/google/go-querystring v1.1.0
## explicit; go 1.10
github.com/google/go-querystring/query
Expand Down
Loading