Skip to content

Commit

Permalink
Adds custom task argument documentation to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bomoko committed Apr 7, 2022
1 parent 96d7915 commit 6869c89
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
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.
62 changes: 61 additions & 1 deletion docs/using-lagoon-advanced/custom-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,33 @@ Schematically, the call looks like this
mutation addAdvancedTask {
addAdvancedTaskDefinition(input:{
name: string,
confirmationText: string,
type: [COMMAND|IMAGE],
[project|environment]: int,
description: string,
service: string,
command: string
command: string,
advancedTaskDefinitionArguments: [
{
name: "ENVIROMENT_VARIABLE_NAME",
displayName: "Friendly Name For Variable",
type: [STRING | ENVIRONMENT_SOURCE_NAME]
}
]
}) {
... on AdvancedTaskDefinitionImage {
id
name
description
service
image
confirmationText
advancedTaskDefinitionArguments {
type
range
name
displayName
}
...
}
... on AdvancedTaskDefinitionCommand {
Expand All @@ -54,6 +69,12 @@ mutation addAdvancedTask {
description
service
command
advancedTaskDefinitionArguments {
type
range
name
displayName
}
...
}
}
Expand All @@ -68,6 +89,45 @@ The `[project|environment]` set of fields will attach the task to either the `pr

We put the service we'd like to target with our task in the `service` field, and `command` is the actual command that we'd like to run.

### Arguments passed to tasks

In order to give more flexibility to the users invoking the tasks via the Lagoon UI, we support defining task arguments. These arguments are displayed as text boxes or drop downs and are required for the task to be invoked.

Here is an example of how we might set up two arguments.

```
advancedTaskDefinitionArguments: [
{
name: "ENV_VAR_NAME_SOURCE",
displayName: "Environment source",
type: ENVIRONMENT_SOURCE_NAME
},
{
name: "ENV_VAR_NAME_STRING",
displayName: "Echo value",
type: STRING
}
]
})
```

This fragment shows both types of arguments the system currently supports.
The first, `ENV_VAR_NAME_SOURCE` is an example of type `ENVIRONMENT_SOURCE_NAME`, which will present the user of the UI a dropdown of the different environments inside of a project.
The second `ENV_VAR_NAME_STRING` is of type `STRING` and will present the user with a textbox to fill in.

The values that the user selects will be available as environment variables in the `COMMAND` type tasks when the task is run.


![Task Arguments](./custom-task-arguments.png)


### Confirmation

When the `confirmationText` field has text, it will be displayed with a confirmation modal in the UI before the user is able to run the task.

![Task Confirmation](./custom-task-confirm.png)

## Invoking the task

With the task now defined, the task should now show up in the tasks dropdown in the Lagoon UI.
Expand Down

0 comments on commit 6869c89

Please sign in to comment.