diff --git a/src/pages/docs/platform-hub/policies/schema.md b/src/pages/docs/platform-hub/policies/schema.md index f060d037c5..b22ce825cc 100644 --- a/src/pages/docs/platform-hub/policies/schema.md +++ b/src/pages/docs/platform-hub/policies/schema.md @@ -148,6 +148,24 @@ These two fields work together. A step that's skipped still appears in `Steps`, | SlugOrId | string | Yes | The slug or ID of the step or process template | | Version | string | No | The pinned version, if one is set | +**Example usage:** + +```ruby +# Check that no steps are skipped +result := {"allowed": true} if { + count(input.SkippedSteps) == 0 +} + +# Check a specific step template is present and not skipped +result := {"allowed": true} if { + some step in input.Steps + step.Source.Type == "Step Template" + step.Source.SlugOrId == "" + not step.Id in input.SkippedSteps + step.Enabled == true +} +``` + #### Packages array | Property | Type | Always Present | Description | @@ -158,34 +176,37 @@ These two fields work together. A step that's skipped still appears in `Steps`, | GitRef | string | No | The Git reference for the package. Sourced from linked Build Information | | [Feed](#feed-object) | object | No | Details of the feed the package is sourced from | -#### Feed object - -| Property | Type | Always Present | Description | -| :--- | :--- | :--- | :--- | -| Id | string | Yes | The unique identifier for the feed | -| Name | string | Yes | Display name of the feed | -| Slug | string | Yes | The URL-safe slug for the feed | -| Type | string | Yes | The feed type (e.g. `BuiltIn`, `Docker`) | -| Uri | string | No | The configured endpoint for the feed | - **Example usage:** ```ruby -# Check that no steps are skipped +package packages_from_main_branch + +default result := {"allowed": false, "action": "warn"} + +all_packages := [pkg | some step in input.Steps; some pkg in step.Packages] + result := {"allowed": true} if { - count(input.SkippedSteps) == 0 + count(all_packages) == 0 } -# Check a specific step template is present and not skipped result := {"allowed": true} if { - some step in input.Steps - step.Source.Type == "Step Template" - step.Source.SlugOrId == "" - not step.Id in input.SkippedSteps - step.Enabled == true + count(all_packages) > 0 + every pkg in all_packages { + pkg.GitRef == "refs/heads/main" + } } ``` +#### Feed object + +| Property | Type | Always Present | Description | +| :--- | :--- | :--- | :--- | +| Id | string | Yes | The unique identifier for the feed | +| Name | string | Yes | Display name of the feed | +| Slug | string | Yes | The URL-safe slug for the feed | +| Type | string | Yes | The feed type (e.g. `BuiltIn`, `Docker`) | +| Uri | string | No | The configured endpoint for the feed | + :::div{.hint} See the [steps and skipping examples](/docs/platform-hub/policies/examples#check-that-a-step-isnt-skipped-in-a-deployment) for more patterns.