magento-cloud-docker icon indicating copy to clipboard operation
magento-cloud-docker copied to clipboard

Adding JQ command to PHP CLI image

Open IgorVitol opened this issue 2 years ago • 0 comments

Description

Magento/Adobe Commerce Cloud ENVs are using "base64 + json encoded" ENV variables for storing credentials & configuration. Like:

  • MAGENTO_CLOUD_RELATIONSHIPS

You would need to read this ENV variable in case when it is required to build a cross-env "bash" script which would be tested/used locally as well (like DB operations, etc).

The easiest way to properly read json data in "bash" without injecting PHP would be using "jq", like: MYSQL_USER="$(echo $MAGENTO_CLOUD_RELATIONSHIPS | base64 -d | jq -r '.database[0].username')"

All the Magento Cloud ENVs (Integration/Staging/PROD) has "jq" installed by default, but it doesn't exists locally, forcing us to install it locally (via apt-get) each time when the script should be executed.

Manual testing scenarios

  1. Execute next command from within PHP CLI container (eg "deploy" one) echo $MAGENTO_CLOUD_RELATIONSHIPS | base64 -d | jq -r '.database[0].username'

image

Release notes

Added "jq" CLI tool to easily read json-encoded ENV variables in PHP CLI containers.

Contribution checklist

  • [x] Pull request has a meaningful description of its purpose
  • [ ] Pull request introduces user-facing changes and includes meaningful release notes and documentation
  • [x] All commits are accompanied by meaningful commit messages

IgorVitol avatar Apr 13 '23 13:04 IgorVitol