github.com/criteo/command-launcher@v0.0.0-20230407142452-fb616f546e98/gh-pages/content/en/docs/overview/resources.md (about) 1 --- 2 title: "Manage resources" 3 description: "Access informations that collected from command launcher" 4 lead: "Access informations that collected from command launcher" 5 date: 2022-10-02T19:21:34+02:00 6 lastmod: 2022-10-02T19:21:34+02:00 7 draft: false 8 images: [] 9 menu: 10 docs: 11 parent: "overview" 12 identifier: "resources-9305bb9c59eb0255e5e68e7e938d505f" 13 weight: 250 14 toc: true 15 --- 16 17 ## What is resources 18 19 Resources are the information collected by command launcher. One good example is the user name and password from the built-in `login` command. 20 21 Some of these information require user consent to access them, a command needs to explicitly request the access to these resources through the `requestedResources` property in the manifest. 22 23 Others are automatically passed to the command. 24 25 Command Launcher passes resources to managed command through environment variables. The naming convention is: COLA_[RESOURCE_NAME]. If you compiled command launcher to a different name, command launcher will pass an additional environment variable `[APP_NAME]_[RESOURCE_NAME]` to the managed command as well. 26 27 For example, the following snippet of manifest requests the resource `USERNAME` and `AUTH_TOKEN`. 28 29 ```yaml 30 pkgName: infra-management 31 version: 1.0.0 32 cmds: 33 - name: create-pod 34 ... 35 requestedResources: [ "USERNAME", "AUTH_TOKEN" ] 36 37 ``` 38 39 ## User consent 40 41 Command launcher will pass the resources to the command on runtime through environment variables: `COLA_[RESOURCE_NAME]`, **ONLY IF** user has agreed to do so. This is done through a user consent process, with a prompt message for the first-time run of the command: 42 43 ```text 44 Command 'create-pod' requests access to the following resources: 45 - USERNAME 46 - AUTH_TOKEN 47 48 authorize the access? [yN] 49 ``` 50 51 The user consent will last for a specific period of time define in `user_consent_life` configuration. 52 53 ## Access resources in your command 54 55 Once user grant the access to the requested resources, command launcher will pass the resources to the command in runtime through environment variable with naming convention: `COLA_[RESOURCE_NAME]`. Here is an example of bash script: 56 57 ```bash 58 #!/bin/bash 59 60 USERNAME=${COLA_USERNAME} 61 AUTH_TOKEN=${COLA_AUTH_TOKEN} 62 ``` 63 64 ## Available resources 65 66 | Resource Name | Require User Consent | Description | 67 |---------------|----------------------|---------------------------------------------------------| 68 | USERNAME | Yes | the username collected from `login` command | 69 | PASSWORD | Yes | the password collected from `login` command | 70 | AUTH_TOKEN | Yes | the authentication token collected from `login` command | 71 | LOG_LEVEL | Yes | the log level of command launcher | 72 | DEBUG_FLAGS | Yes | the debug flags defined in command launcher's config | 73 | PACKAGE_DIR | No | the absolute path to the package directory |