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

Use branch protection template function everywhere #9

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

netomi
Copy link
Contributor

@netomi netomi commented Oct 16, 2023

As discussed in #8 .

Fyi: for another project we started to use now repository rulesets which are cleaner designed branch protection rules that also have additional features (able to define them on organization level and change between auditing and enforcing mode).

This is currently not supported by the self-service but we will make this a priority to support them, to give you a heads up in case you are wondering or are interested in using them.

Link to the ticket to also explain some use-case that can not be modelled with existing branch protection rules: https://gitlab.eclipse.org/eclipsefdn/security/otterdog/-/issues/53

@netomi netomi requested review from a team as code owners October 16, 2023 09:29
@github-actions
Copy link

Diff for 11a9535:
Printing local diff for configuration at '/home/runner/work/.eclipsefdn/.eclipsefdn/otterdog-configs/otterdog.json'

Actions are indicated with the following symbols:
+   create
!   modify
!   forced update
-   delete

Organization eclipse-vertx[id=eclipse-vertx]
  there have been 34 validation infos, enable verbose output with '-v' to to display them.
  
  Plan: 0 to add, 0 to change, 0 to delete.
Showing diff to a canonical version of the configuration at '/home/runner/work/.eclipsefdn/.eclipsefdn/otterdog-configs/otterdog.json'

Organization eclipse-vertx[id=eclipse-vertx]
--- original
+++ canonical
@@ -1,7 +1,38 @@
 local orgs = import 'vendor/otterdog-defaults/otterdog-defaults.libsonnet';
 
+local vertxBranchProtectionRule(branchName) = orgs.newBranchProtectionRule(branchName) {
+
+  required_approving_review_count: null
+  requires_pull_request: false
+  requires_status_checks: false
+  requires_strict_status_checks: true
+};
+local newVertxRepo(repoName, default_branch = 'main') = orgs.newRepo(repoName) {
+
+  allow_merge_commit: true
+  allow_update_branch: false
+  branch_protection_rules: [
+    vertxBranchProtectionRule($.default_branch) {}
+  ]
+  default_branch: default_branch
+  delete_branch_on_merge: false
+  homepage: "http://vertx.io"
+  web_commit_signoff_required: false
 orgs.newOrg('eclipse-vertx') {
   _repositories+:: [
+    newVertxRepo('vertx-service-resolver', 'main') {
+      description: "Vert.x Service Resolver"
+      homepage: ""
+      topics+: [
+        "java"
+        "jvm"
+        "kubernetes"
+        "loadbalancing"
+        "microservices"
+        "servicediscovery"
+        "vertx"
+      ]
+    }
     orgs.newRepo('.github') {
       allow_merge_commit: true
       allow_update_branch: false
@@ -23,24 +54,9 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('3.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('4.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('master') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
+        vertxBranchProtectionRule('3.*')
+        vertxBranchProtectionRule('4.*')
+        vertxBranchProtectionRule('master')
       ]
       default_branch: "master"
       delete_branch_on_merge: false
@@ -72,24 +88,9 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('3.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('4.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('master') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
+        vertxBranchProtectionRule('3.*')
+        vertxBranchProtectionRule('4.*')
+        vertxBranchProtectionRule('master')
       ]
       default_branch: "master"
       delete_branch_on_merge: false
@@ -111,24 +112,9 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('3.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('4.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('master') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
+        vertxBranchProtectionRule('3.*')
+        vertxBranchProtectionRule('4.*')
+        vertxBranchProtectionRule('master')
       ]
       default_branch: "master"
       delete_branch_on_merge: false
@@ -148,18 +134,8 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('4.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('main') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
+        vertxBranchProtectionRule('4.*')
+        vertxBranchProtectionRule('main')
       ]
       delete_branch_on_merge: false
       dependabot_alerts_enabled: false
@@ -170,18 +146,8 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('4.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('main') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
+        vertxBranchProtectionRule('4.*')
+        vertxBranchProtectionRule('main')
       ]
       delete_branch_on_merge: false
       dependabot_alerts_enabled: false
@@ -192,18 +158,8 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('4.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('master') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
+        vertxBranchProtectionRule('4.*')
+        vertxBranchProtectionRule('master')
       ]
       default_branch: "master"
       delete_branch_on_merge: false
@@ -222,18 +178,8 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('4.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('master') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
+        vertxBranchProtectionRule('4.*')
+        vertxBranchProtectionRule('master')
       ]
       default_branch: "master"
       delete_branch_on_merge: false
@@ -264,18 +210,8 @@
     orgs.newRepo('vertx-openapi') {
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('4.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('main') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
+        vertxBranchProtectionRule('4.*')
+        vertxBranchProtectionRule('main')
       ]
       delete_branch_on_merge: false
       dependabot_alerts_enabled: false
@@ -286,70 +222,20 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('main') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
+        vertxBranchProtectionRule('main')
       ]
       delete_branch_on_merge: false
       dependabot_alerts_enabled: false
       web_commit_signoff_required: false
     }
-    orgs.newRepo('vertx-service-resolver') {
-      allow_merge_commit: true
-      allow_update_branch: false
-      branch_protection_rules: [
-        orgs.newBranchProtectionRule('main') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-      ]
-      delete_branch_on_merge: false
-      description: "Vert.x Service Resolver"
-      homepage: ""
-      topics+: [
-        "java"
-        "jvm"
-        "kubernetes"
-        "loadbalancing"
-        "microservices"
-        "servicediscovery"
-        "vertx"
-      ]
-      web_commit_signoff_required: false
-    }
     orgs.newRepo('vertx-sql-client') {
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('3.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('4.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('_old/*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('master') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
+        vertxBranchProtectionRule('3.*')
+        vertxBranchProtectionRule('4.*')
+        vertxBranchProtectionRule('_old/*')
+        vertxBranchProtectionRule('master')
       ]
       default_branch: "master"
       delete_branch_on_merge: false
@@ -380,18 +266,8 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('4.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('master') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
+        vertxBranchProtectionRule('4.*')
+        vertxBranchProtectionRule('master')
       ]
       default_branch: "master"
       delete_branch_on_merge: false
@@ -412,18 +288,8 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('4.*') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
-        orgs.newBranchProtectionRule('main') {
-          required_approving_review_count: null
-          requires_pull_request: false
-          requires_status_checks: false
-          requires_strict_status_checks: true
-        }
+        vertxBranchProtectionRule('4.*')
+        vertxBranchProtectionRule('main')
       ]
       delete_branch_on_merge: false
       dependabot_alerts_enabled: false
@@ -469,3 +335,4 @@
     }
   }
 }
+};

@netomi netomi requested a review from vietj October 16, 2023 09:30
@netomi netomi merged commit 74e7b36 into main Oct 16, 2023
2 checks passed
@netomi netomi deleted the simplify-existing-bprs branch October 16, 2023 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants