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
10 changes: 10 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.",
},
Comment on lines +60 to +64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This field should be moved to top-level. It's not part of the allowed_actions_config

},
},
},
Expand Down Expand Up @@ -96,6 +101,10 @@
allowed.VerifiedAllowed = &x
}

if v, ok := data["sha_pinning_required"]; ok {
allowed.SHAPinningRequired = github.Ptr(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/v81/github".ActionsAllowed has no field or method SHAPinningRequired)

Check failure on line 105 in github/resource_github_actions_organization_permissions.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

allowed.SHAPinningRequired undefined (type *"github.com/google/go-github/v81/github".ActionsAllowed has no field or method SHAPinningRequired)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: SHAPinningRequired is not a field in ActionsAllowed but ActionsPermissions, you need to move where this is set

}

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/v81/github".ActionsAllowed has no field or method GetShaPinningRequired)

Check failure on line 238 in github/resource_github_actions_organization_permissions.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

actionsAllowed.GetShaPinningRequired undefined (type *"github.com/google/go-github/v81/github".ActionsAllowed has no field or method GetShaPinningRequired)
},
}); err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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 @@ -62,12 +63,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.Ptr(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/v81/github".ActionsAllowed has no field or method SHAPinningRequired)

Check failure on line 94 in github/resource_github_actions_repository_permissions.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

allowed.SHAPinningRequired undefined (type *"github.com/google/go-github/v81/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/v81/github".ActionsAllowed has no field or method GetShaPinningRequired)) (typecheck)

Check failure on line 201 in github/resource_github_actions_repository_permissions.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

actionsAllowed.GetShaPinningRequired undefined (type *"github.com/google/go-github/v81/github".ActionsAllowed has no field or method GetShaPinningRequired)
},
}); err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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 @@ -63,10 +64,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
Loading