Skip to content

Commit

Permalink
chore: update readme to use example template, fix reading org ruleset…
Browse files Browse the repository at this point in the history
…s for free orgs
  • Loading branch information
Thomas Neidhart committed Dec 8, 2024
1 parent 1762893 commit 636a2c8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 22 deletions.
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,43 +72,36 @@ $ ./otterdog.sh -h

To start using the cli part of `otterdog` right away on a specific organization you have to set up the following:

- define a default configuration to use, you can use the [default config](https://github.com/EclipseFdn/otterdog-defaults/) of the Eclipse Foundation as starting point
- define a default configuration to use, you can use the following [default config](https://github.com/eclipse-csi/otterdog/blob/main/examples/template/otterdog-defaults.libsonnet) as a starting point
- create a `otterdog.json` file that contains the list of organizations you want to manage and some customizations
- start managing your organizations using the cli

### Default configuration @ Eclipse Foundation
### Default configuration

The default configuration that is in use by the Eclipse Foundation can be used right away. It has some hooks and configurations
defined that are not meaningful for other uses though. Also the `config` repsitory is set to `.eclipsefdn` and is defined like
that in the default configuration and will be created upon the first `apply` execution.

For simple testing though, you can use this base template: `https://github.com/EclipseFdn/otterdog-defaults#otterdog-defaults.libsonnet@main`.
You can define your own default configuration or use the following base template right away: `https://github.com/eclipse-csi/otterdog#examples/template/otterdog-defaults.libsonnet@main`.

### Otterdog configuration

The following example configuration is used to the manage the [Otterdogtest organization](https://github.com/OtterdogTest):
Create a `otterdog.json` file with the following content (replace bracketed values according to your setup):

```json
{
"defaults": {
"bitwarden": {
"api_token_key": "api_token_admin"
},
"jsonnet": {
"base_template": "https://github.com/EclipseFdn/otterdog-defaults#otterdog-defaults.libsonnet@main",
"base_template": "https://github.com/eclipse-csi/otterdog#examples/template/otterdog-defaults.libsonnet@main",
"config_dir": "orgs"
},
"github": {
"config_repo": ".eclipsefdn"
"config_repo": ".otterdog"
}
},
"organizations": [
{
"name": "OtterdogTest",
"github_id": "OtterdogTest",
"name": "<project-name>",
"github_id": "<github-id>",
"credentials": {
"provider": "bitwarden",
"item_id": "118276ad-158c-4720-b68d-af8c00fe3481"
"item_id": "<bitwarden item id>"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion examples/template/otterdog-defaults.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ local newOrg(id) = {
settings: {
name: null,
plan: "free",
billing_email: null,
billing_email: "",
company: null,
email: null,
twitter_username: null,
Expand Down
3 changes: 1 addition & 2 deletions otterdog/models/github_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ async def load_from_provider(
jsonnet_config: JsonnetConfig,
provider: GitHubProvider,
no_web_ui: bool = False,
printer: IndentingPrinter | None = None,
concurrency: int | None = None,
) -> GitHubOrganization:
start = datetime.now()
Expand Down Expand Up @@ -457,7 +456,7 @@ async def load_from_provider(
else:
_logger.debug("not reading org secrets, no default config available")

if jsonnet_config.default_org_ruleset_config is not None:
if jsonnet_config.default_org_ruleset_config is not None and org.settings.plan == "enterprise":
start = datetime.now()
_logger.trace("rulesets: reading...")

Expand Down
2 changes: 1 addition & 1 deletion otterdog/operations/diff_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def coerce_current_org(self) -> bool:

async def load_current_org(self, github_id: str, jsonnet_config: JsonnetConfig) -> GitHubOrganization:
return await GitHubOrganization.load_from_provider(
github_id, jsonnet_config, self.gh_client, self.no_web_ui, self.printer, self.concurrency
github_id, jsonnet_config, self.gh_client, self.no_web_ui, self.concurrency
)

def preprocess_orgs(
Expand Down
2 changes: 1 addition & 1 deletion otterdog/operations/import_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def execute(

async with GitHubProvider(credentials) as provider:
organization = await GitHubOrganization.load_from_provider(
github_id, jsonnet_config, provider, self.no_web_ui, self.printer
github_id, jsonnet_config, provider, self.no_web_ui
)

# copy secrets from existing configuration if it is present.
Expand Down
2 changes: 1 addition & 1 deletion otterdog/operations/show_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def execute(
)

organization = await GitHubOrganization.load_from_provider(
github_id, jsonnet_config, provider, self.no_web_ui, self.printer
github_id, jsonnet_config, provider, self.no_web_ui
)

for model_object, parent_object in organization.get_model_objects():
Expand Down

0 comments on commit 636a2c8

Please sign in to comment.