Skip to content

Commit

Permalink
feat: Add RepositoryRuleset resource
Browse files Browse the repository at this point in the history
Signed-off-by: Asaf Haim <[email protected]>
  • Loading branch information
asafhm committed Dec 15, 2024
1 parent 0fab624 commit 9a9835e
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ spec:
| `RepositoryAutolinkReference` | `repo` | `github_repository_autolink_reference` | |
| `RepositoryCollaborator` | `repo` | `github_repository_collaborator` | |
| `RepositoryWebhook` | `repo` | `github_repository_webhook` | |
| `RepositoryRuleset` | `repo` | `github_repository_ruleset` | |
| `PullRequest` | `repo` | `github_repository_pull_request` | |
| `DeployKey` | `repo` | `github_repository_deploy_key` | |
| `Team` | `team` | `github_team` | |
Expand Down
2 changes: 2 additions & 0 deletions config/external_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ var terraformPluginSDKExternalNameConfigs = map[string]config.ExternalName{
"github_repository_collaborator": config.IdentifierFromProvider,
// Can be imported using the following format: {{ repository }}:{{ environment }}
"github_repository_environment": config.IdentifierFromProvider,
// Can be imported using the following format: {{ repository }}:{{ ruleset id }}
"github_repository_ruleset": config.IdentifierFromProvider,
// Can be imported using the following format: {{ runner id }}
"github_actions_runner_group": config.IdentifierFromProvider,
}
Expand Down
2 changes: 2 additions & 0 deletions config/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/crossplane-contrib/provider-upjet-github/config/repositoryautolinkreference"
"github.com/crossplane-contrib/provider-upjet-github/config/repositorycollaborator"
"github.com/crossplane-contrib/provider-upjet-github/config/repositoryfile"
"github.com/crossplane-contrib/provider-upjet-github/config/repositoryruleset"
"github.com/crossplane-contrib/provider-upjet-github/config/repositorywebhook"
"github.com/crossplane-contrib/provider-upjet-github/config/team"
"github.com/crossplane-contrib/provider-upjet-github/config/teammembership"
Expand Down Expand Up @@ -83,6 +84,7 @@ func GetProvider(ctx context.Context) (*ujconfig.Provider, error) {
organizationruleset.Configure,
repositoryautolinkreference.Configure,
repositorycollaborator.Configure,
repositoryruleset.Configure,
membership.Configure,
teamsettings.Configure,
teamsyncgroupmapping.Configure,
Expand Down
17 changes: 17 additions & 0 deletions config/repositoryruleset/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package repositoryruleset

import "github.com/crossplane/upjet/pkg/config"

// Configure github_repository_ruleset resource.
func Configure(p *config.Provider) {
p.AddResourceConfigurator("github_repository_ruleset", func(r *config.Resource) {
// We need to override the default group that upjet generated for
// this resource, which would be "github"
r.Kind = "RepositoryRuleset"
r.ShortGroup = "repo"

r.References["repository"] = config.Reference{
TerraformName: "github_repository",
}
})
}
41 changes: 41 additions & 0 deletions tests/cases/repo-ruleset/repository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
apiVersion: repo.github.upbound.io/v1alpha1
kind: Repository
metadata:
name: github-crossplane-repo-ruleset-test
spec:
forProvider:
visibility: public
autoInit: true
gitignoreTemplate: Terraform
providerConfigRef:
name: default
---
apiVersion: repo.github.upbound.io/v1alpha1
kind: RepositoryRuleset
metadata:
name: repo-ruleset
spec:
forProvider:
repositoryRef:
name: github-crossplane-repo-ruleset-test
target: "branch"
enforcement: "active"
conditions:
- refName:
- include: ["~ALL"]
exclude: []
bypassActors:
- actorId: 13473
actorType: "Integration"
bypassMode: "always"
rules:
- creation: true
update: true
deletion: true
requiredLinearHistory: true
requiredSignatures: true
requiredDeployments:
- requiredDeploymentEnvironments: ["test"]
providerConfigRef:
name: default

0 comments on commit 9a9835e

Please sign in to comment.