|
| 1 | += Example container image for Decodable CLI |
| 2 | + |
| 3 | +The https://docs.decodable.co/cli.html[Decodable CLI] enables you configure, view, and control resources on your Decodable account. |
| 4 | + |
| 5 | +== Build |
| 6 | + |
| 7 | +[source,bash] |
| 8 | +---- |
| 9 | +cd cli-docker |
| 10 | +docker build -t decodable-cli . |
| 11 | +---- |
| 12 | + |
| 13 | +== Usage |
| 14 | + |
| 15 | +You need two configuration values: |
| 16 | + |
| 17 | +* Your Decodable **account name** |
| 18 | +* The **refresh token** for your account. You can obtain this by running the Docker image with the `print-refresh-token` argument: |
| 19 | ++ |
| 20 | +[source,bash] |
| 21 | +---- |
| 22 | +docker run --rm -it \ |
| 23 | + -e DECODABLE_ACCOUNT_NAME=<your account id> \ |
| 24 | + decodable-cli:latest \ |
| 25 | + print-refresh-token |
| 26 | +---- |
| 27 | ++ |
| 28 | +You'll be prompted to open a URL in your web browser which will take you through the Decodable authentication process. |
| 29 | +After entering the supplied values you'll get a refresh token. |
| 30 | ++ |
| 31 | +WARNING: Anyone with refresh token can access your Decodable account. |
| 32 | +Treat your refresh token as you would any other sensitive information such as passwords. |
| 33 | +If you invoke the Docker container as illustrated below note that the refresh token will remain on your command line history and thus be vulnerable to local access. |
| 34 | + |
| 35 | +=== Invocation |
| 36 | + |
| 37 | +[source,bash] |
| 38 | +---- |
| 39 | +docker run --rm \ |
| 40 | + -e DECODABLE_ACCOUNT_NAME=<your account id> \ |
| 41 | + -e DECODABLE_REFRESH_TOKEN=<your refresh token> \ |
| 42 | + decodable-cli:latest \ |
| 43 | + <decodable CLI command line arguments> |
| 44 | +---- |
| 45 | + |
| 46 | +For example: |
| 47 | + |
| 48 | +* Get CLI version |
| 49 | ++ |
| 50 | +[source,bash] |
| 51 | +---- |
| 52 | +docker run --rm \ |
| 53 | + -e DECODABLE_ACCOUNT_NAME=<your account id> \ |
| 54 | + -e DECODABLE_REFRESH_TOKEN=<your refresh token> \ |
| 55 | + decodable-cli:latest \ |
| 56 | + --version |
| 57 | +---- |
| 58 | + |
| 59 | +Show status of all resources |
| 60 | ++ |
| 61 | +[source,bash] |
| 62 | +---- |
| 63 | +docker run --rm \ |
| 64 | + -e DECODABLE_ACCOUNT_NAME=<your account id> \ |
| 65 | + -e DECODABLE_REFRESH_TOKEN=<your refresh token> \ |
| 66 | + decodable-cli:latest \ |
| 67 | + query --no-spec |
| 68 | +---- |
| 69 | + |
| 70 | +* Create and populate a secret "postgres-prod" |
| 71 | ++ |
| 72 | +[source,bash] |
| 73 | +---- |
| 74 | +# Create the resource definition |
| 75 | +# Ref: https://docs.decodable.co/declarative/definitions.html#secret |
| 76 | +cat <<EOF > postgres-prod.yaml |
| 77 | +--- |
| 78 | +kind: secret |
| 79 | +metadata: |
| 80 | + name: postgres-prod |
| 81 | + description: 🤫 The password for the Production Postgres server |
| 82 | +spec_version: v1 |
| 83 | +spec: |
| 84 | + value_file: ./pg_pw.txt |
| 85 | +EOF |
| 86 | +
|
| 87 | +# Write the password to a file, which is read when |
| 88 | +# the resource is created |
| 89 | +cat <<EOF > pg_pw.txt |
| 90 | +hunter2 |
| 91 | +EOF |
| 92 | +
|
| 93 | +# Invoke the Decodable `apply` command |
| 94 | +# Ref: https://docs.decodable.co/declarative/apply.html#_how_to_use_the_apply_command |
| 95 | +docker run --rm \ |
| 96 | + -e DECODABLE_ACCOUNT_NAME=<your account id> \ |
| 97 | + -e DECODABLE_REFRESH_TOKEN=<your refresh token> \ |
| 98 | + -v $PWD:/data \ |
| 99 | + decodable-cli:latest \ |
| 100 | + apply /data/postgres-prod.yaml |
| 101 | +---- |
0 commit comments