Before contributing, we need to understand the Concourse resource workflow.
A concourse resource is composed by three components:
in
out
check
This three programs must be executable, you can use bash, python or binary the important thing is to be able to understand the input params and to output the correct information. This doc will help you to understand the params expected for each component.
cycloid-resource
will mainly run the out
program, since it's a put
in the pipeline definition, the worfklow is the following:
- put:
- put will call the
./out
program - validation is done using the CLI and source params
- once the
./out
exits, we fallback on an implicitget
so we call the./in
program - once the
./in
exits, we call thecheck
program
If you want to test, you need:
- cy in your
$PATH
- access to cycloid console through the API
- a terraform plan JSON output (
terraform plan -out=./plan; terraform show -json ./plan > plan.json
)
You first need to define a source
JSON:
{
"source": {
"feature": "terracost",
"env": "your-env",
"project": "your-project",
"org": "your-org",
"api_key": "secret",
"api_url": "https://api.staging.cycloid.io"
},
"params": {
"tfplan_path": "/path/to/terraform/plan.json"
}
}
Then you can perform an infrapolicy validation:
$ // build_id is provided by concourse in build environment
$ export BUILD_ID=1234
$ make
$ ./resource/out . < source.json
{"version":{"build_id":"1234","criticals":"0","warnings":"0","advisories":"0"},"metadata":null}