Skip to content

Commit

Permalink
Merge pull request #111 from flanksource/feat/playbook-doc-updates
Browse files Browse the repository at this point in the history
docs: playbook examples
  • Loading branch information
moshloop authored Dec 18, 2023
2 parents f9bf8a1 + 67b7b82 commit 371e351
Show file tree
Hide file tree
Showing 32 changed files with 457 additions and 132 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mission-control/docs/images/playbook-runs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mission-control/docs/images/playbooks-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions mission-control/docs/playbooks/actions/exec.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ spec:
script: kubectl scale --replicas={{.params.replicas}} --namespace={{.config.tags.namespace}} deployment {{.config.name}}
```
| Field | Description | Scheme | Required |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | -------- |
| `script` | Script can be an inline script or a path to a script that needs to be executed. Executed via Powershell on windows and via bash on Darwin and Linux. | _string_ | `true` |
| `connections` | Connections for some CLIs | [`ExecConnection`](#exec-connection) | |
| `artifacts` | Specify what artifacts generated by the exec action needs to be saved | [`[]Artifact`](#artifacts) | |
| `env` | Specify environment variables that are available to exec processes | [`[]types.EnvVar`](https://pkg.go.dev/github.com/flanksource/duty/types#EnvVar) | |
| `checkout` | Checkout details the git repository that should be mounted to the process | [`[]GitCheckout`](#git-checkout) | |
| Field | Description | Scheme | Required | Templatable |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | -------- | ----------- |
| `script` | Script can be an inline script or a path to a script that needs to be executed. Executed via Powershell on windows and via bash on Darwin and Linux. | _string_ | `true` | `true` |
| `connections` | Connections for some CLIs | [`ExecConnection`](#exec-connection) | | |
| `artifacts` | Specify what artifacts generated by the exec action needs to be saved | [`[]Artifact`](#artifacts) | | |
| `env` | Specify environment variables that are available to exec processes | [`[]types.EnvVar`](https://pkg.go.dev/github.com/flanksource/duty/types#EnvVar) | | |
| `checkout` | Checkout details the git repository that should be mounted to the process | [`[]GitCheckout`](#git-checkout) | | |

### Exec Connection

Expand Down
79 changes: 31 additions & 48 deletions mission-control/docs/playbooks/actions/gitops.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,86 +52,69 @@ spec:
On Github and Azure Devops, it's possible to create Pull Requests as well.
:::
| Field | Description | Scheme | Required |
| --------- | ------------------------------------------------------------- | ---------------------------------------- | -------- |
| `repo` | Repository details | [`RepositoryDetail`](#repository-detail) | `true` |
| `commit` | Commit details | [`Commit`](#commit-detail) | `true` |
| `pr` | Pull Request details _(Valid only for GitHub & Azure Devops)_ | [`PullRequest`](#pull-request) | |
| `patches` | List of patches to apply | [`[]Patch`](#patch) | |
| `files` | List of files to create | [`[]File`](#file) | |
| Field | Description | Scheme | Required | Templatable |
| --------- | ------------------------------------------------------------- | ---------------------------------------- | -------- | ----------- |
| `repo` | Repository details | [`RepositoryDetail`](#repository-detail) | `true` | `true` |
| `commit` | Commit details | [`Commit`](#commit-detail) | `true` | `true` |
| `pr` | Pull Request details _(Valid only for GitHub & Azure Devops)_ | [`PullRequest`](#pull-request) | | `true` |
| `patches` | List of patches to apply | [`[]Patch`](#patch) | | `true` |
| `files` | List of files to create | [`[]File`](#file) | | `true` |

:::note
At least a patch or files config is required.
:::

### Repository Detail

| Field | Description | Scheme | Required | Templated |
| ------------ | --------------------------------------------------------------------- | -------- | -------- | --------- |
| `connection` | Connection name to use the credentials for the git repo | `string` | | |
| `url` | URL of the git repository | `string` | | |
| `base` | Branch to clone. _(Defaults to "main")_ | `string` | | `true` |
| `branch` | The new branch to create. _(Defaults to base branch specified above)_ | `string` | | `true` |
| Field | Description | Scheme | Required | Templatable |
| ------------ | --------------------------------------------------------------------- | -------- | -------- | ----------- |
| `connection` | Connection name to use the credentials for the git repo | `string` | | |
| `url` | URL of the git repository | `string` | | |
| `base` | Branch to clone. _(Defaults to "main")_ | `string` | | `true` |
| `branch` | The new branch to create. _(Defaults to base branch specified above)_ | `string` | | `true` |

:::note
Either the `connection` or the `url` is required
:::

### Commit Detail

| Field | Description | Scheme | Required | Templated |
| --------- | -------------- | -------- | -------- | --------- |
| `author` | Author name | `string` | `true` | `true` |
| `email` | Author email | `string` | `true` | |
| `message` | Commit message | `string` | `true` | |
| Field | Description | Scheme | Required | Templatable |
| --------- | -------------- | -------- | -------- | ----------- |
| `author` | Author name | `string` | `true` | `true` |
| `email` | Author email | `string` | `true` | |
| `message` | Commit message | `string` | `true` | |

### Pull Request

| Field | Description | Scheme | Required | Templated |
| ------- | ------------------------- | ---------- | -------- | --------- |
| `title` | Title of the Pull request | `string` | `true` | `true` |
| `tags` | Tags to add to the PR | `[]string` | | `true` |
| Field | Description | Scheme | Required | Templatable |
| ------- | ------------------------- | ---------- | -------- | ----------- |
| `title` | Title of the Pull request | `string` | `true` | `true` |
| `tags` | Tags to add to the PR | `[]string` | | `true` |

### Patch

Patches modify existing files on the git repo. You can either use `yq` to modify yaml files or `jq` to modify json files.

| Field | Description | Scheme | Required | Templated |
| ------ | ------------- | -------- | -------- | --------- |
| `path` | Path to patch | `string` | `true` | `true` |
| `yq` | yq query | `string` | `false` | `true` |
| `jq` | jq query | `string` | `false` | `true` |
| Field | Description | Scheme | Required | Templatable |
| ------ | ------------- | -------- | -------- | ----------- |
| `path` | Path to patch | `string` | `true` | `true` |
| `yq` | yq query | `string` | `false` | `true` |
| `jq` | jq query | `string` | `false` | `true` |

### File

Files create or delete existing files on the git repo.

| Field | Description | Scheme | Required | Templated |
| --------- | ------------------------------------------------------------------------- | -------- | -------- | --------- |
| `path` | Path to file | `string` | `true` | `true` |
| `content` | Content of the file. Use the `$delete` keyword to delete an existing file | `string` | `true` | `true` |
| Field | Description | Scheme | Required | Templatable |
| --------- | ------------------------------------------------------------------------- | -------- | -------- | ----------- |
| `path` | Path to file | `string` | `true` | `true` |
| `content` | Content of the file. Use the `$delete` keyword to delete an existing file | `string` | `true` | `true` |

## Templating

The following fields are templatable

- `commit.message`
- `files.content`
- `files.path`
- `patches.jq`
- `patches.path`
- `patches.yq`
- `pr.tags`
- `pr.title`
- `repo.base`
- `repo.branch`

The template receives a environment variable that contain details about the corresponding config, check or component and the parameter(if applicable).

:::info
See the [reference](.md) to see what fields are templatable
:::

| Field | Description | Schema |
| ----------- | ---------------------------------------- | -------------------------------------------- |
| `config` | Config passed to the playbook | [`ConfigItem`](../references/config_item.md) |
Expand Down
18 changes: 9 additions & 9 deletions mission-control/docs/playbooks/actions/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ spec:
value: secret123
```
| Field | Description | Scheme | Required |
| -------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | -------- |
| Field | Description | Scheme | Required | Templatable |
| -------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | -------- | ----------- |
| `connection` | Connection name. e.g. connection://http/google | `string` | |
| `url` | Url to make the request to | `string` | |
| `username` | Username to authenticate with | [`types.EnvVar`](https://pkg.go.dev/github.com/flanksource/duty/types#EnvVar) | |
Expand All @@ -46,7 +46,7 @@ spec:
| `ntlm` | NTLM when set to true will perform authentication using NTLM v1 protocol | `bool` | |
| `ntlmv2` | NTLM when set to true will perform authentication using NTLM v2 protocol | `bool` | |
| `headers` | Header fields to be used in the request | [`[]types.EnvVar`](https://pkg.go.dev/github.com/flanksource/duty/types#EnvVar) | |
| `body` | Request Body Contents | `string` | |
| `body` | Request Body Contents | `string` | | `true` |
| `templateBody` | When set to true the request body is templated _(default: `false`)_. [Read more ...](../concepts/templating.md) | `bool` | |

:::note
Expand All @@ -57,9 +57,9 @@ Either the `connection` or the `url` is required.

The body of the HTTP request is templatable. The script template receives a environment variable that contain details about the corresponding config, check or component and the parameter(if applicable).

| Field | Description | Schema |
| ----------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `config` | Config passed to the playbook | [`ConfigItem`](../references/config_item.md) |
| `component` | Component passed to the playbook | [`Component`](../references/component.md) |
| `check` | Canary Check passed to the playbook | [`Check`](../references/check.md) |
| `params` | User provided parameters to the playbook | `map[string]string` |
| Field | Description | Schema |
| ----------- | ---------------------------------------- | -------------------------------------------- |
| `config` | Config passed to the playbook | [`ConfigItem`](../references/config_item.md) |
| `component` | Component passed to the playbook | [`Component`](../references/component.md) |
| `check` | Canary Check passed to the playbook | [`Check`](../references/check.md) |
| `params` | User provided parameters to the playbook | `map[string]string` |
28 changes: 14 additions & 14 deletions mission-control/docs/playbooks/actions/notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ spec:
message: 'Name: "{{.component.name}}"'
```
| Field | Description | Scheme | Required |
| ------------ | --------------------------------------------------------- | ------------------- | -------- |
| `url` | Shoutrrr URL [Read more](../../notifications/overview.md) | `string` | |
| `connection` | Connection to use to send the notification | `string` | |
| `title` | Title of the notification | `string` | `true` |
| `message` | Message is the body of the notification | `string` | `true` |
| `properties` | Properties for shoutrrr | `map[string]string` |
| Field | Description | Scheme | Required | Templatable |
| ------------ | --------------------------------------------------------- | ------------------- | -------- | ----------- |
| `url` | Shoutrrr URL [Read more](../../notifications/overview.md) | `string` | | |
| `connection` | Connection to use to send the notification | `string` | | |
| `title` | Title of the notification | `string` | `true` | `true` |
| `message` | Message is the body of the notification | `string` | `true` | `true` |
| `properties` | Properties for shoutrrr | `map[string]string` | | |

:::note
Either the `connection` or the `url` is required.
:::

## Templating

The `title` and the `message` fields can be templated. The script template receives a environment variable that contain details about the corresponding config, check or component and the parameter(if applicable).
The template receives a environment variable that contain details about the corresponding config, check or component and the parameter(if applicable).

| Field | Description | Schema |
| ----------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `config` | Config passed to the playbook | [`ConfigItem`](../references/config_item.md) |
| `component` | Component passed to the playbook | [`Component`](../references/component.md) |
| `check` | Canary Check passed to the playbook | [`Check`](../references/check.md) |
| `params` | User provided parameters to the playbook | `map[string]string` |
| Field | Description | Schema |
| ----------- | ---------------------------------------- | -------------------------------------------- |
| `config` | Config passed to the playbook | [`ConfigItem`](../references/config_item.md) |
| `component` | Component passed to the playbook | [`Component`](../references/component.md) |
| `check` | Canary Check passed to the playbook | [`Check`](../references/check.md) |
| `params` | User provided parameters to the playbook | `map[string]string` |
Loading

0 comments on commit 371e351

Please sign in to comment.