Skip to content

Commit e88fb02

Browse files
octo-ryanhallhcrhallcorey-underdown
authored
Update Packages array policy schema documentation (#3152)
* Add example usage for SkippedSteps and Packages array in policy schema documentation * Fix linting error --------- Co-authored-by: Ryan Hall <infrastructure.engineer@gmail.com> Co-authored-by: Corey Underdown <corey.underdown@octopus.com>
1 parent 3592978 commit e88fb02

1 file changed

Lines changed: 39 additions & 18 deletions

File tree

  • src/pages/docs/platform-hub/policies

src/pages/docs/platform-hub/policies/schema.md

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,24 @@ These two fields work together. A step that's skipped still appears in `Steps`,
148148
| SlugOrId | string | Yes | The slug or ID of the step or process template |
149149
| Version | string | No | The pinned version, if one is set |
150150

151+
**Example usage:**
152+
153+
```ruby
154+
# Check that no steps are skipped
155+
result := {"allowed": true} if {
156+
count(input.SkippedSteps) == 0
157+
}
158+
159+
# Check a specific step template is present and not skipped
160+
result := {"allowed": true} if {
161+
some step in input.Steps
162+
step.Source.Type == "Step Template"
163+
step.Source.SlugOrId == "<ActionTemplate-ID>"
164+
not step.Id in input.SkippedSteps
165+
step.Enabled == true
166+
}
167+
```
168+
151169
#### Packages array
152170

153171
| Property | Type | Always Present | Description |
@@ -158,34 +176,37 @@ These two fields work together. A step that's skipped still appears in `Steps`,
158176
| GitRef | string | No | The Git reference for the package. Sourced from linked Build Information |
159177
| [Feed](#feed-object) | object | No | Details of the feed the package is sourced from |
160178

161-
#### Feed object
162-
163-
| Property | Type | Always Present | Description |
164-
| :--- | :--- | :--- | :--- |
165-
| Id | string | Yes | The unique identifier for the feed |
166-
| Name | string | Yes | Display name of the feed |
167-
| Slug | string | Yes | The URL-safe slug for the feed |
168-
| Type | string | Yes | The feed type (e.g. `BuiltIn`, `Docker`) |
169-
| Uri | string | No | The configured endpoint for the feed |
170-
171179
**Example usage:**
172180

173181
```ruby
174-
# Check that no steps are skipped
182+
package packages_from_main_branch
183+
184+
default result := {"allowed": false, "action": "warn"}
185+
186+
all_packages := [pkg | some step in input.Steps; some pkg in step.Packages]
187+
175188
result := {"allowed": true} if {
176-
count(input.SkippedSteps) == 0
189+
count(all_packages) == 0
177190
}
178191

179-
# Check a specific step template is present and not skipped
180192
result := {"allowed": true} if {
181-
some step in input.Steps
182-
step.Source.Type == "Step Template"
183-
step.Source.SlugOrId == "<ActionTemplate-ID>"
184-
not step.Id in input.SkippedSteps
185-
step.Enabled == true
193+
count(all_packages) > 0
194+
every pkg in all_packages {
195+
pkg.GitRef == "refs/heads/main"
196+
}
186197
}
187198
```
188199

200+
#### Feed object
201+
202+
| Property | Type | Always Present | Description |
203+
| :--- | :--- | :--- | :--- |
204+
| Id | string | Yes | The unique identifier for the feed |
205+
| Name | string | Yes | Display name of the feed |
206+
| Slug | string | Yes | The URL-safe slug for the feed |
207+
| Type | string | Yes | The feed type (e.g. `BuiltIn`, `Docker`) |
208+
| Uri | string | No | The configured endpoint for the feed |
209+
189210
:::div{.hint}
190211

191212
See the [steps and skipping examples](/docs/platform-hub/policies/examples#check-that-a-step-isnt-skipped-in-a-deployment) for more patterns.

0 commit comments

Comments
 (0)