Skip to content

JSON string substitution with env variable is inserting double quote.  #10987

@purushothamgk

Description

@purushothamgk

Hi ,
I have set the json in the env variable SA_ACCOUNT_KEY_JSON

   spec:
    # GCP Spec section described below
    service_account_key_json:  '${SA_ACCOUNT_KEY_JSON}'

Getting the below error :
Error: failed to sync v1 source gcp: failed to sync source gcp (v8.5.0): failed to fetch resources from stream: rpc error: code = Unknown desc = failed to sync resources: failed to create execution client for source plugin gcp: invalid json at service_account_key_json: invalid character 't' after top-level value

It looks like after the insertion single quote is not maintained, instead "" is getting added due to this it has become invalid.
After the substitution of env variable:

spec:
    service_account_key_json: **"{**
  "type": "service_account",
  "project_id": "purucloud",
  "private_key_id": "a74c7fd1d670a98038672f",
  "private_key": "-----BEGIN PRIVATE KEY-----\nw0BAQEFAASCBKgwggSkAgEAAoIBAQC/\n-----END PRIVATE KEY-----\n",
  "client_email": "compute@developer.gserviceaccount.com",
  "client_id": "100184116219207284942",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/392136656291-compute%40developer.gserviceaccount.com",
  "universe_domain": "googleapis.com"
**}"**
tables:
  - gcp_sql_instances
  - gcp_compute_networks

Further investigation found , "" is getting added in the method stripYamlComments,
b = bytes.ReplaceAll(b, []byte(k)), []byte(fmt.Sprintf("${%s}", v)))

I tried moving the stripYamlComments after the expandEnv then it retained.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions