You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/08/28 20:14:19 UTC

[GitHub] csantanapr closed pull request #162: use runtime env var __OW_API_KEY for the api key

csantanapr closed pull request #162: use runtime env var __OW_API_KEY for the api key
URL: https://github.com/apache/incubator-openwhisk-package-alarms/pull/162
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/action/alarmWebAction.js b/action/alarmWebAction.js
index 8209783..b5dd664 100644
--- a/action/alarmWebAction.js
+++ b/action/alarmWebAction.js
@@ -5,6 +5,7 @@ const CronJob = require('cron').CronJob;
 const moment = require('moment');
 const common = require('./lib/common');
 const Database = require('./lib/Database');
+const config = require('./lib/config');
 
 function main(params) {
 
@@ -19,10 +20,7 @@ function main(params) {
         namespace: triggerParts.namespace,
         additionalData: common.constructObject(params.additionalData),
     };
-    var triggerID = `${triggerData.namespace}/${triggerData.name}`;
-    if (triggerData.apikey) {
-        triggerID = `${triggerData.apikey}/${triggerID}`;
-    }
+    var triggerID = config.constructTriggerID(triggerData);
 
     var workers = params.workers instanceof Array ? params.workers : [];
     var deleteAfterFireArray = ['false', 'true', 'rules'];
diff --git a/action/lib/common.js b/action/lib/common.js
index 9f98fbe..b24e5dd 100644
--- a/action/lib/common.js
+++ b/action/lib/common.js
@@ -50,6 +50,7 @@ function createWebParams(rawParams) {
     delete webparams.apihost;
 
     webparams.triggerName = triggerName;
+    webparams.authKey = process.env.__OW_API_KEY;
     config.addAdditionalData(webparams);
 
     return webparams;
diff --git a/action/lib/config.js b/action/lib/config.js
index 0b58bed..cae4dbf 100644
--- a/action/lib/config.js
+++ b/action/lib/config.js
@@ -5,6 +5,14 @@ function getOpenWhiskConfig(triggerData) {
     return {ignore_certs: true, namespace: triggerData.namespace, api_key: triggerData.apikey};
 }
 
+function constructTriggerID(triggerData) {
+    var triggerID = `${triggerData.namespace}/${triggerData.name}`;
+    if (triggerData.apikey) {
+        triggerID = `${triggerData.apikey}/${triggerID}`;
+    }
+    return triggerID;
+}
+
 function addAdditionalData(params) {
     //insert code here to store additional trigger data in the database
     //for example, params.additionalData = {dateCreated: Date.now()};
@@ -12,5 +20,6 @@ function addAdditionalData(params) {
 
 module.exports = {
     'addAdditionalData': addAdditionalData,
-    'getOpenWhiskConfig': getOpenWhiskConfig
+    'getOpenWhiskConfig': getOpenWhiskConfig,
+    'constructTriggerID': constructTriggerID
 };


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services