apache / openwhisk-wskdeploy

Apache OpenWhisk utility for deploying and managing OpenWhisk projects and packages
https://openwhisk.apache.org/
Apache License 2.0
77 stars 74 forks source link

Unable to use ENV VARS in input JSON #705

Closed ScottChapman closed 6 years ago

ScottChapman commented 6 years ago

I tried the following without success:

inputs:
   type: json
   MyKey: {
     username: ${username},
     password: ${password}
   }
ScottChapman commented 6 years ago

We would likely need this for implementing a IBM Cloud Functions Template for Watson Workspace.

Watson Workspace is a Slack-like app IBM sells and we have lots of internal and external paying customers that are looking for solutions for developing and deploying their apps.

This mechanism is needed to support that effort.

mrutkows commented 6 years ago

@ScottChapman this would be a new feature we would to design... to capture some thoughts...

we could take the approach that JSON is a first-class format/citizen in the Serverless space and work to get interpolation done quickly, but should make it an option it might not be good to assume it is a default behavior perhaps the app developer wants the $() encoding left alone for their own use (edited) and it may not be granular at the document / manifest level either may need to add a keyword to the data type like “interpolate” which gives us permission to change the actual JSON data (or other data formats going forward) thoughts?

ScottChapman commented 6 years ago

I think that seems reasonable. Make it so.

lionelvillard commented 6 years ago

Looking at k8s and helm, templating is based on go templates ({{ .username }}). Maybe we could have the same for wskdeploy?

ScottChapman commented 6 years ago

I think the issue isn't what syntax is used for injecting env vars, the issue is that right now the text associated with a JSON object is taken as a literal and not interpreted.

SO interpreting the text would be a new feature, and would need to preserve existing behavior.

(I suspect)

ScottChapman commented 6 years ago

Any target for this? I am getting close to having a template ready for deployment, and need to be able to specify some variables for it.

mrutkows commented 6 years ago

I think we should clearly get an indicator from the user/author to permit us to alter the value of an input parameter.

inputs:
   type: json
   interpolate: true # default false
   MyKey: {
     username: ${username},
     password: ${password}
   }
mrutkows commented 6 years ago

Lionel suggests an in-line indicator (e.g., '\' backslash or a second '$'); look to Terraform perhaps for an example of what they are doing.

lionelvillard commented 6 years ago

Terraform is using $$ to escape interpolation: https://www.terraform.io/docs/configuration/interpolation.html Go template (used by kubernetes) does not provide a way to escape interpolation because the delimiter literal can be the interpolation result ({{"{{"}})