You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2017/10/04 18:18:49 UTC
[incubator-openwhisk-catalog] branch master updated: Parameterize
hardcoded host variable (#240)
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-catalog.git
The following commit(s) were added to refs/heads/master by this push:
new 6e1a8fe Parameterize hardcoded host variable (#240)
6e1a8fe is described below
commit 6e1a8fe55f7e47a39b8d5d9663b4e5cc6708768c
Author: Narine C <na...@gmail.com>
AuthorDate: Wed Oct 4 13:18:47 2017 -0500
Parameterize hardcoded host variable (#240)
---
packages/installWeather.sh | 2 +-
packages/weather/README.md | 1 +
packages/weather/forecast.js | 3 ++-
.../test/scala/packages/weather/WeatherTests.scala | 19 +++++++++++++++++++
4 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/packages/installWeather.sh b/packages/installWeather.sh
index def9de8..313cb82 100755
--- a/packages/installWeather.sh
+++ b/packages/installWeather.sh
@@ -21,7 +21,7 @@ waitForAll
install "$PACKAGE_HOME/weather/forecast.js" \
weather/forecast \
-a description 'IBM Weather Insights 10-day forecast' \
- -a parameters '[ {"name":"latitude", "required":true}, {"name":"longitude", "required":true},{"name":"language", "required":false},{"name":"units", "required":false}, {"name":"timePeriod", "required":false}, {"name":"username", "required":true, "bindTime":true},{"name":"password", "required":true,"type":"password", "bindTime":true} ]' \
+ -a parameters '[ {"name":"latitude", "required":true}, {"name":"longitude", "required":true},{"name":"language", "required":false},{"name":"units", "required":false}, {"name":"timePeriod", "required":false}, {"name":"username", "required":true, "bindTime":true},{"name":"password", "required":true,"type":"password", "bindTime":true}, {"name":"host", "required":false} ]' \
-a sampleInput '{"latitude":"34.063", "longitude":"-84.217", "username":"XXX","password":"XXX"}' \
-a sampleOutput '{"forecasts":[ {"dow":"Monday", "min_temp":30, "max_temp":38, "narrative":"Cloudy"} ]}'
diff --git a/packages/weather/README.md b/packages/weather/README.md
index 1123f48..3df2601 100644
--- a/packages/weather/README.md
+++ b/packages/weather/README.md
@@ -61,6 +61,7 @@ The `/whisk.system/weather/forecast` action returns a weather forecast for a loc
- `48hour` - Returns an hourly 2-day forecast
- `current` - Returns the current weather conditions
- `timeseries` - Returns both the current observations and up to 24 hours of past observations, from the current date and time.
+- `host`: Host for The Weather Company Data for IBM Bluemix
The following is an example of creating a package binding and then getting a 10-day forecast.
diff --git a/packages/weather/forecast.js b/packages/weather/forecast.js
index 19dd2d2..61e5ada 100755
--- a/packages/weather/forecast.js
+++ b/packages/weather/forecast.js
@@ -24,7 +24,8 @@ function main(params) {
var language = params.language || 'en-US';
var units = params.units || 'm';
var timePeriod = params.timePeriod || '10day';
- var url = 'https://twcservice.mybluemix.net/api/weather/v1/geocode/' + lat + '/' + lon;
+ var host = params.host || 'twcservice.mybluemix.net';
+ var url = 'https://' + host + '/api/weather/v1/geocode/' + lat + '/' + lon;
var qs = {language: language, units: units};
switch(timePeriod) {
diff --git a/tests/src/test/scala/packages/weather/WeatherTests.scala b/tests/src/test/scala/packages/weather/WeatherTests.scala
index 010e2e5..ce9fe84 100644
--- a/tests/src/test/scala/packages/weather/WeatherTests.scala
+++ b/tests/src/test/scala/packages/weather/WeatherTests.scala
@@ -34,6 +34,7 @@ class WeatherTests
val credentials = TestUtils.getVCAPcredentials("weatherinsights")
val username = credentials.get("username").toJson
val password = credentials.get("password").toJson
+ val host = credentials.get("host").toJson
behavior of "Weather Package"
@@ -64,4 +65,22 @@ class WeatherTests
_.response.result.get.toString should include("observation")
}
}
+
+ it should """Use "host" property""" in withAssetCleaner(wskprops) {
+ (wp, assetHelper) =>
+ val name = "forecastTest"
+
+ assetHelper.withCleaner(wsk.pkg, name) {
+ (pkg, name) =>
+ pkg.bind("/whisk.system/weather", name,
+ Map("username" -> username,
+ "password" -> password,
+ "host" -> host))
+ }
+ println("Invoking the action")
+ withActivation(wsk.activation, wsk.action.invoke(s"${name}/forecast")) {
+ activation =>
+ activation.response.success shouldBe true
+ }
+ }
}
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].