Right now environment & file variable replacement in yaml config files do a simple string replacement, which can lead to hard-to-debug issues. For example, if the contents of a file contains JSON, the following config:
spec:
project_id: "cq-playground"
dataset_id: "cloudquery"
service_account_key_json: ${file:key.json}
will throw an error about unexpected keys in the JSON. That's because the JSON gets interpreted as an additional yaml object. The workaround is to place the variable in single quotes:
spec:
project_id: "cq-playground"
dataset_id: "cloudquery"
service_account_key_json: '${file:key.json}'
Similarly, if you were to use double quotes instead of single quotes there, you'd also get a hard-to-debug error:
spec:
project_id: "cq-playground"
dataset_id: "cloudquery"
service_account_key_json: "${file:key.json}"
That's because the JSON file contents may include double quotes, which won't get escaped. So you'll get service_account_key_json: "{"name":"value"}" which is invalid yaml syntax.
Or if the file contains newlines, you can also run into similar issues. I don't think this is how variables are intended to be used, and we should escape their contents. I'm not sure what the right way will be to do this; we'd still want number fields to be interpreted as numbers, so we can't (for example) add quotes around interpolated variables.
I'm just writing this issue now so I don't forget about it, but won't go into too much detail now.
Right now environment & file variable replacement in yaml config files do a simple string replacement, which can lead to hard-to-debug issues. For example, if the contents of a file contains JSON, the following config:
will throw an error about unexpected keys in the JSON. That's because the JSON gets interpreted as an additional yaml object. The workaround is to place the variable in single quotes:
Similarly, if you were to use double quotes instead of single quotes there, you'd also get a hard-to-debug error:
That's because the JSON file contents may include double quotes, which won't get escaped. So you'll get
service_account_key_json: "{"name":"value"}"which is invalid yaml syntax.Or if the file contains newlines, you can also run into similar issues. I don't think this is how variables are intended to be used, and we should escape their contents. I'm not sure what the right way will be to do this; we'd still want number fields to be interpreted as numbers, so we can't (for example) add quotes around interpolated variables.
I'm just writing this issue now so I don't forget about it, but won't go into too much detail now.