You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by mr...@apache.org on 2018/02/13 20:06:48 UTC

[incubator-openwhisk-wskdeploy] branch master updated: adding env. variable support in trigger feed (#732)

This is an automated email from the ASF dual-hosted git repository.

mrutkowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-wskdeploy.git


The following commit(s) were added to refs/heads/master by this push:
     new 4bf0fbc  adding env. variable support in trigger feed (#732)
4bf0fbc is described below

commit 4bf0fbcf524d60a909ebbd8e35e7a104107be340
Author: Priti Desai <pd...@us.ibm.com>
AuthorDate: Tue Feb 13 12:06:46 2018 -0800

    adding env. variable support in trigger feed (#732)
    
    * adding env. variable support in trigger feed
    
    * addin unit tests
    
    * fixing typo in unit test
    
    * adding comment
---
 parsers/manifest_parser.go                    | 4 ++++
 parsers/manifest_parser_test.go               | 9 ++++++++-
 tests/dat/manifest_data_compose_triggers.yaml | 5 +++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/parsers/manifest_parser.go b/parsers/manifest_parser.go
index 88a3b03..b18118e 100644
--- a/parsers/manifest_parser.go
+++ b/parsers/manifest_parser.go
@@ -774,6 +774,10 @@ func (dm *YAMLParser) ComposeTriggers(filePath string, pkg Package, ma whisk.Key
 			trigger.Feed = trigger.Source
 		}
 
+		// replacing env. variables here in the trigger feed name
+		// to support trigger feed with $READ_FROM_ENV_TRIGGER_FEED
+		trigger.Feed = wskenv.GetEnvVar(trigger.Feed).(string)
+
 		keyValArr := make(whisk.KeyValueArr, 0)
 		if trigger.Feed != "" {
 			var keyVal whisk.KeyValue
diff --git a/parsers/manifest_parser_test.go b/parsers/manifest_parser_test.go
index af906d1..1ac7b87 100644
--- a/parsers/manifest_parser_test.go
+++ b/parsers/manifest_parser_test.go
@@ -1280,6 +1280,9 @@ func TestComposeSequences(t *testing.T) {
 }
 
 func TestComposeTriggers(t *testing.T) {
+	// set env variables needed for the trigger feed
+	os.Setenv("KAFKA_INSTANCE", "kafka-broker")
+	os.Setenv("SRC_TOPIC", "topic")
 	// read and parse manifest.yaml file located under ../tests folder
 	manifestFile := "../tests/dat/manifest_data_compose_triggers.yaml"
 	p := NewYAMLParser()
@@ -1293,7 +1296,7 @@ func TestComposeTriggers(t *testing.T) {
 		assert.Fail(t, "Failed to compose trigger")
 	}
 
-	assert.Equal(t, 2, len(triggerList), "Failed to get trigger list")
+	assert.Equal(t, 3, len(triggerList), "Failed to get trigger list")
 	for _, trigger := range triggerList {
 		switch trigger.Name {
 		case "trigger1":
@@ -1302,6 +1305,10 @@ func TestComposeTriggers(t *testing.T) {
 			assert.Equal(t, "feed", trigger.Annotations[0].Key, "Failed to set trigger annotation")
 			assert.Equal(t, "myfeed", trigger.Annotations[0].Value, "Failed to set trigger annotation")
 			assert.Equal(t, 2, len(trigger.Parameters), "Failed to set trigger parameters")
+		case "message-trigger":
+			assert.Equal(t, 2, len(trigger.Parameters), "Failed to set trigger parameters")
+			assert.Equal(t, "feed", trigger.Annotations[0].Key, "Failed to set trigger annotation")
+			assert.Equal(t, "Bluemix_kafka-broker_Credentials-1/messageHubFeed", trigger.Annotations[0].Value, "Failed to set trigger annotation")
 		}
 	}
 }
diff --git a/tests/dat/manifest_data_compose_triggers.yaml b/tests/dat/manifest_data_compose_triggers.yaml
index 9be02de..8fe02e3 100644
--- a/tests/dat/manifest_data_compose_triggers.yaml
+++ b/tests/dat/manifest_data_compose_triggers.yaml
@@ -26,3 +26,8 @@ package:
       inputs:
         name: myname
         place: myplace
+    message-trigger:
+      feed: Bluemix_${KAFKA_INSTANCE}_Credentials-1/messageHubFeed
+      inputs:
+        isJSONData: true
+        topic: $SRC_TOPIC

-- 
To stop receiving notification emails like this one, please contact
mrutkowski@apache.org.