Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add file path protection to rulesets #2415

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
18 changes: 18 additions & 0 deletions github/resource_github_repository_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,24 @@ func resourceGithubRepositoryRuleset() *schema.Resource {
},
},
},
"file_path_restriction": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: "Prevent commits that include changes in specified file paths from being pushed to the commit graph.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"restricted_file_paths": {
Type: schema.TypeList,
Required: true,
Description: "The file paths that are restricted from being pushed to the commit graph.",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
},
},
},
Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/repository_ruleset.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ The `rules` block supports the following:

* `tag_name_pattern` - (Optional) (Block List, Max: 1) Parameters to be used for the tag_name_pattern rule. This rule only applies to repositories within an enterprise, it cannot be applied to repositories owned by individuals or regular organizations. Conflicts with `branch_name_pattern` as it only applied to rulesets with target `tag`. (see [below for nested schema](#rules.tag_name_pattern))

* `file_path_restriction` -(Optional) (Block List, Max 1) Parameters to be used for the file_path_restriction rule. When enabled restricts access to files within the repository. (See [Below for nested schema](#rules.file_path_restriction))

* `update` - (Optional) (Boolean) Only allow users with bypass permission to update matching refs.

* `update_allows_fetch_and_merge` - (Optional) (Boolean) Branch can pull changes from its upstream repository. This is only applicable to forked repositories. Requires `update` to be set to `true`. Note: behaviour is affected by a known bug on the GitHub side which may cause issues when using this parameter.
Expand Down Expand Up @@ -192,6 +194,10 @@ The `rules` block supports the following:
* `negate` - (Optional) (Boolean) If true, the rule will fail if the pattern matches.


#### rules.file_path_restriction ####

* `restricted_file_paths` - (Required) (String) The file paths that are restricted from being pushed to the commit graph.


#### bypass_actors ####

Expand Down
Loading