Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support parsing of environment variables other than strings. #425

Merged

Conversation

robertjsullivan
Copy link
Contributor

Currently the go-cfclient throws an error when attempting to retrieve env vars for an app that are not of type string.

For example, given the env vars:

○ → cf curl /v3/apps/a275abd1-8f53-4a63-b980-d81cee1cf133/environment_variables
{
   "var": {
      "SCS_CREDHUB_ENABLED": true,
      "JBP_CONFIG_OPEN_JDK_JRE": "{jre: {version: 17.+}}",
       ...
   },
   "links": {
      "self": {
         "href": "https://< sanitized >/v3/apps/a275abd1-8f53-4a63-b980-d81cee1cf133/environment_variables"
      },
      "app": {
         "href": "https://< sanitized >/v3/apps/a275abd1-8f53-4a63-b980-d81cee1cf133"
      }
   }
}

We observe the following failure:
time=2024-07-15T20:43:48.368890666Z caller=logger.go:73 level=error error="failed to get environment for app a275abd1-8f53-4a63-b980-d81cee1cf133: error decoding /v3/apps/a275abd1-8f53-4a63-b980-d81cee1cf133/env get response JSON before '': json: cannot unmarshal bool into Go struct field AppEnvironment.environment_variables of type string"

We added support for bool, float64 and int types. More could easily be added given our implementation but we weren't sure what other types could actually occur. Let us know if you have any questions or would like additional changes.

Copy link

linux-foundation-easycla bot commented Jul 16, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: robertjsullivan / name: Robert Sullivan (7cf4fa1)

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
Signed-off-by: Alexey Zavitaev <alexey.zavitaev@broadcom.com>
@robertjsullivan robertjsullivan force-pushed the support-additional-env-var-types branch from 8150e63 to 7cf4fa1 Compare July 16, 2024 20:45
@sneal
Copy link
Contributor

sneal commented Jul 18, 2024

LGTM, thanks for the PR!

From the CF API docs it's not exactly clear what can be returned in these env vars, but it does seem obvious from yourr example it's not always a string.

@sneal sneal merged commit 66cca9d into cloudfoundry:main Jul 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants