Open pritidesai opened 7 years ago
@pritidesai , why need to support the $CLOUDANT_INSTANCE key as env, is it related to the dependency management or package binding issue?
The key $CLOUDANT_INSTANCE
is being used in multiple components including an actions and a trigger, so would like to avoid hard coding same value throughout the manifest file, for example:
package:
name: data-processing
namespace: _
dependencies:
# binding cloudant package named $CLOUDANT_INSTANCE
$CLOUDANT_INSTANCE:
location: /whisk.system/cloudant
inputs:
username: $CLOUDANT_USERNAME
password: $CLOUDANT_PASSWORD
host: "$CLOUDANT_USERNAME.cloudant.com"
url: "https://$CLOUDANT_USERNAME:$CLOUDANT_PASSWORD@$CLOUDANT_USERNAME.cloudant.com"
dbname: $CLOUDANT_DATABASE
actions:
# Action named "write-to-cloudant"
# Creating action that is manually invoked to write to the database
write-to-cloudant:
location: actions/write-to-cloudant.js
inputs:
CLOUDANT_USERNAME: $CLOUDANT_USERNAME
CLOUDANT_PASSWORD: $CLOUDANT_PASSWORD
CLOUDANT_DATABASE: $CLOUDANT_DATABASE
# Action named "write-from-cloudant"
# Creating action to respond to database insertions
write-from-cloudant:
location: actions/write-from-cloudant.js
sequences:
# Sequence named "write-from-cloudant-sequence"
# Creating sequence that ties database read to handling action
write-from-cloudant-sequence:
actions: $CLOUDANT_INSTANCE/read, write-from-cloudant
triggers:
# Trigger named "image-uploaded"
# Creating trigger to fire events when data is inserted
image-uploaded:
source: $CLOUDANT_INSTANCE/changes
inputs:
dbname: $CLOUDANT_DATABASE
rules:
# Rule named "echo-images"
# Creating rule that maps database change trigger to sequence
echo-images:
trigger: image-uploaded
action: data-processing/write-from-cloudant-sequence
@krook @paulcastro
@pritidesai , I think it's good idea, but you know as our yaml parsers are predefined structures, so I don't know if there is a better way to support this flexible environments parsing in yaml, do you know some libraries support this?
@pritidesai If we move forward on this, we need another issue to update the specification itself.
We just verified that we do have support for env. variables in #249 and they can be referenced by using ($) dollar notation like
$CLOUDANT_USERNAME
and$CLOUDANT_PASSWORD
in the following example:But we do not support env. variables when they are referenced by the YAML keys for example,
$CLOUDANT_INSTANCE
in the above sample. We do have such use case as part of openwhisk-data-processing-cloudant repo.@lionelvillard @mrutkows @paulcastro @krook