cloudfoundry / cloudfoundry/cloud_controller_ng
Task-specific environment variables
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 207
- Forks
- 373
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 56
Description
Issue
I want to be able to set task-specific environment variables when starting a task on an application:
POST /v3/apps/<GUID>/tasks
{
"command": "/bin/bash migrate.sh abc",
"environment_variables": {
"CONTEXT": "{\"key_1\":\"value_1\"...}"
}
}
Context
I'm working on an application that uses CF tasks to perform database changes (migrations). This application is also tenant-aware and has a separate database schema for each of its tenants. We therefore create a CF task for each tenant and pass the tenant ID as an argument to the migration script. For example:
cf run-task my-app "/bin/bash migrate.sh abc"
cf run-task my-app "/bin/bash migrate.sh def"
Where abc and def are tenant IDs. In addition to these tenant IDs, this script requires a relatively big JSON object that I, unfortunately, cannot describe here, but the important part is that it can vary depending on the tenant. We want to avoid passing this JSON object as an argument to the script since the command of a task is limited in size to 4097 characters. Our preference would be to set it as an environment variable, but since its value varies, we can't set it on the application itself. Ideally, we want to be able to do something like:
cf run-task my-app "/bin/bash migrate.sh abc" -e CONTEXT="<JSON>"
cf run-task my-app "/bin/bash migrate.sh def" -e CONTEXT="<DIFFERENT_JSON>"
I hope I gave you enough background. If you have any questions, I'll be happy to try and answer them.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the POST /v3/apps//tasks endpoint and trace how the cf run-task request creates a task. Add support for per-task environment_variables whose values can differ between tasks, and verify that both the API payload and the command-line -e form result in the requested task environment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100