Skip to content

Commit

Permalink
feat: add validation for gh_pages_source_path setting of a repository
Browse files Browse the repository at this point in the history
  • Loading branch information
netomi committed Oct 16, 2024
1 parent 46dd16d commit f5b0225
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- Added validation for setting `gh_pages_source_path` of a repository to check for allowed values.
- Added a playground and visualization of the default settings for a project to the dashboard. ([#293](https://github.com/eclipse-csi/otterdog/issues/293))
- Added support for overriding default settings in the `otterdog config` from a file `.otterdog-defaults.json`.
- Added support for setting `required_merge_queue` in repository rulesets. ([#282](https://github.com/eclipse-csi/otterdog/issues/282))
Expand Down
12 changes: 10 additions & 2 deletions otterdog/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def validate(self, context: ValidationContext, parent_object: Any) -> None:
context.add_failure(
FailureType.ERROR,
f"'gh_pages_build_type' has value '{self.gh_pages_build_type}', "
f"only values ('disabled' | 'legacy' | 'workflow') are allowed.",
f"only values ['disabled' | 'legacy' | 'workflow'] are allowed.",
)

if self.gh_pages_build_type == "disabled":
Expand All @@ -432,12 +432,20 @@ def validate(self, context: ValidationContext, parent_object: Any) -> None:
f"but no corresponding 'github-pages' environment, please add such an environment.",
)

if self.gh_pages_build_type == "legacy" and self.gh_pages_source_path not in ["/", "/docs"]:
context.add_failure(
FailureType.ERROR,
f"{self.get_model_header(parent_object)} has"
f" 'gh_pages_source_path' with value '{self.gh_pages_source_path}', "
f"only values ['/' | '/docs'] are allowed.",
)

if is_set_and_valid(self.code_scanning_default_query_suite):
if self.code_scanning_default_query_suite not in {"default", "extended"}:
context.add_failure(
FailureType.ERROR,
f"'code_scanning_default_query_suite' has value '{self.code_scanning_default_query_suite}', "
f"only values ('default' | 'extended') are allowed.",
f"only values ['default' | 'extended'] are allowed.",
)

if is_set_and_valid(self.code_scanning_default_languages):
Expand Down

0 comments on commit f5b0225

Please sign in to comment.