Skip to content

Commit 706e469

Browse files
authored
docs: custom actions contributor guide (argoproj#25461)
Signed-off-by: reggie-k <regina.voloshin@codefresh.io>
1 parent 3ad7da5 commit 706e469

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/operator-manual/resource_actions.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,43 @@ See the [Deployment actions discovery script](https://github.com/argoproj/argo-c
235235
```
236236

237237
The [resource scale actions](../user-guide/scale_application_resources.md) documentation shows how this function behaves in the UI.
238+
239+
## Contributing a Custom Resource Action
240+
241+
A resource action can be bundled into Argo CD. Custom resource action scripts are located in the `resource_customizations` directory of [https://github.com/argoproj/argo-cd](https://github.com/argoproj/argo-cd). Each contributed custom action needs to have a Lua script for discovery and a Lua script for the actual action logic. It also needs to have testdata and expected K8s resource manifests, which represent the outcome of performing the action.
242+
243+
The following directory structure must be respected:
244+
245+
```
246+
argo-cd
247+
|-- resource_customizations
248+
| |-- your.crd.group.io # CRD group
249+
| | |-- MyKind # Resource kind
250+
| | | |-- actions # Actions folder
251+
| | | | |-- action_test.yaml # Test inputs and expected results
252+
| | | | |-- testdata # Folder with sample K8s manifest yaml files, for testing the outcome of performing the custom actions
253+
| | | | |-- discovery.lua # Conditions upon which the custom action would be visible in the UI
254+
| | | | |-- <action_name> # Folder for each custom action, named as the custom action
255+
| | | | | |-- action.lua # Custom action logic Lua script
256+
```
257+
It is required to provide both discovery tests and action tests for your custom action.
258+
259+
Example of a [complete custom action](https://github.com/argoproj/argo-cd/tree/master/resource_customizations/argoproj.io/AnalysisRun/actions) called `terminate` for AnalysisRun.
260+
261+
262+
Example of `action_test.yaml` file content with `discoveryTests` and `actionTests`:
263+
``` yaml
264+
discoveryTests:
265+
- inputPath: testdata/runningAnalysisRun.yaml
266+
result:
267+
- name: terminate
268+
disabled: false
269+
- inputPath: testdata/failedAnalysisRun.yaml
270+
result:
271+
- name: terminate
272+
disabled: true
273+
actionTests:
274+
- action: terminate
275+
inputPath: testdata/runningAnalysisRun.yaml
276+
expectedOutputPath: testdata/runningAnalysisRun_terminated.yaml
277+
```

0 commit comments

Comments
 (0)