eclipse-csi / otterdog

OtterDog is a tool to manage GitHub organizations at scale using a configuration as code approach. It is actively used by the Eclipse Foundation to manage its numerous projects hosted on GitHub.
https://otterdog.readthedocs.org
Eclipse Public License 2.0
23 stars 3 forks source link

JSONNet Example for use of "template repo" #242

Closed stbischof closed 3 months ago

stbischof commented 3 months ago

Most of the repos looks the same

 orgs.newRepo('%__THE_REPO_NAME__%') {
      allow_squash_merge: false,
      allow_update_branch: false,
      delete_branch_on_merge: false,
      dependabot_security_updates_enabled: true,
      description: "%__THE_REPO_DESCRIPTION__%",
      has_wiki: false,
      variables: [
        orgs.newRepoVariable('SONAR_ORGANIZATION') {
          value: "eclipse-daanse",
        },
        orgs.newRepoVariable('SONAR_PROJECT_KEY') {
          value: "eclipse-daanse_%__THE_REPO_NAME__%",
        },
      ],
      branch_protection_rules: [
        orgs.newBranchProtectionRule('main') {
          required_approving_review_count: 0,
          requires_linear_history: true,
          requires_strict_status_checks: true,
        },
      ],
    },

The only diff is:

would me great if jsopnnet could help me by reusing existing repo:

 orgs.newRepo: self.templaeRepo { name: "Foo" ,description "Bar" },

Could you provide support/examples?

mbarbero commented 3 months ago

One of Jsonnet's strengths is the ability to define functions that reuse or extend existing functions. You can see an example of this in the Adoptium Jsonnet settings.

Please let us know if you need more information or support with this.

netomi commented 3 months ago

Another nice example can be found here: https://github.com/eclipse-vertx/.eclipsefdn/blob/main/otterdog/eclipse-vertx.jsonnet#L10

netomi commented 3 months ago

To dynamically create strings from other properties you can use some build in functions of jsonnet, again the adoptium project does something like that here: https://github.com/adoptium/.eclipsefdn/blob/main/otterdog/adoptium.jsonnet#L45

Using the playground at https://daanse.org/.eclipsefdn/playground/ should also allow you to experiment with that.

stbischof commented 3 months ago

Thx. i looked for this!!