cloudfoundry / cli

The official command line client for Cloud Foundry
https://docs.cloudfoundry.org/cf-cli
Apache License 2.0
1.75k stars 928 forks source link

Do not template/translate literal values in environment variable output #3002

Closed Samze closed 2 weeks ago

Samze commented 2 weeks ago

Description of the Change

Do not attempt to template/translate text when outputting environment variables returned by CF. Print them as literals.

Fixes #2821

Example with this change - note the user provided service:

 ./out/cf env icu2
Getting env variables for app icu2 in org org-1 / space space-1 as admin...
System-Provided:
VCAP_SERVICES: {}

VCAP_APPLICATION: {
  "application_id": "d8c053f9-4092-4579-a17a-b5509427e02b",
  "application_name": "icu2",
  "application_uris": [
    "icu2.apps.axle-2021601.cf-app.com"
  ],
  "cf_api": "https://api.sys.axle-2021601.cf-app.com",
  "limits": {
    "fds": 16384
  },
  "name": "icu2",
  "organization_id": "10112d35-539f-44b1-9051-cc6b1f2abddb",
  "organization_name": "org-1",
  "space_id": "6fcc249a-e62e-4000-9fec-6dfeb267b5a1",
  "space_name": "space-1",
  "uris": [
    "icu2.apps.axle-2021601.cf-app.com"
  ],
  "users": null
}

User-Provided:
TEST2: blah{{
TEST4: blah

No running env variables have been set

No staging env variables have been set

Why Is This PR Valuable?

Any env var (e.g. user provided, service binding) that contains go templating character will cause issues, e.g. `{{ }}``.


Note: will port to v7/main once tests are green and this is approved.