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/openwhisk-wskdeploy.git
The following commit(s) were added to refs/heads/master by this push:
new 0e57fb3 Dummy token issue (#1081)
0e57fb3 is described below
commit 0e57fb3ec10c9cb8271a597df1a79c89f5e5294f
Author: Will Plusnick <[email protected]>
AuthorDate: Thu Dec 5 15:21:12 2019 -0600
Dummy token issue (#1081)
* Allow travisci to be used as a ci/cd pipeline
* Restructure travisci dummy token so that travis can be used as
a ci/cd pipeline
* Add documentation for credentials filling precedence
* Add documentation to describe default credential values
---
deployers/whiskclient.go | 17 +++++++++++------
docs/wskdeploy_faq.md | 9 +++++++++
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/deployers/whiskclient.go b/deployers/whiskclient.go
index 4d980b4..741ec81 100644
--- a/deployers/whiskclient.go
+++ b/deployers/whiskclient.go
@@ -55,6 +55,9 @@ type PropertyValue struct {
Source string
}
+// Note buyer beware this function returns the existing value, and only if
there is not
+// an existing value does it set it to newValue. We should perhaps rename this
function
+// as it implies that it is a getter, when this is not strictly true
var GetPropertyValue = func(prop PropertyValue, newValue string, source
string) PropertyValue {
if len(prop.Value) == 0 && len(newValue) > 0 {
prop.Value = newValue
@@ -201,12 +204,6 @@ func NewWhiskConfig(proppath string, deploymentPath
string, manifestPath string)
// reset credential, apiHost, namespace, etc to avoid any conflicts as
they initialized globally
resetWhiskConfig()
- // initialize APIGW_ACCESS_TOKEN to "DUMMY TOKEN" for Travis builds
- if strings.ToLower(os.Getenv("TRAVIS")) == "true" {
- apigwAccessToken.Value = "DUMMY TOKEN"
- apigwAccessToken.Source = SOURCE_DEFAULT_VALUE
- }
-
// read from command line
readFromCLI()
@@ -230,6 +227,14 @@ func NewWhiskConfig(proppath string, deploymentPath
string, manifestPath string)
// TODO() whisk.properties should be deprecated
readFromWhiskProperty(pi)
+ // As a last resort initialize APIGW_ACCESS_TOKEN to "DUMMY TOKEN" for
Travis builds
+ // The reason DUMMY TOKEN is not always true for Travis builds is that
they may want
+ // to use Travis as a CD vehicle in which case we need to respect the
other values
+ // that may be set before.
+ if strings.ToLower(os.Getenv("TRAVIS")) == "true" {
+ apigwAccessToken = GetPropertyValue(apigwAccessToken, "DUMMY
TOKEN", SOURCE_DEFAULT_VALUE)
+ }
+
// set namespace to default namespace if not yet found
if len(apiHost.Value) != 0 && len(credential.Value) != 0 &&
len(namespace.Value) == 0 {
namespace.Value = whisk.DEFAULT_NAMESPACE
diff --git a/docs/wskdeploy_faq.md b/docs/wskdeploy_faq.md
index a6d478c..ef7017d 100644
--- a/docs/wskdeploy_faq.md
+++ b/docs/wskdeploy_faq.md
@@ -27,3 +27,12 @@
- The ```wskdeploy``` utility will cease deploying as soon as it receives an
error from the target platform and display what error information it receives
to you.
- then it will attempt to undeploy any entities that it attempted to deploy.
+
+### What is the order of precedence for OpenWhisk credentials?
+
+- The ```wskdeploy``` utility finds the credentials (apihost, namespace, and
auth) as well as the APIGW_ACCESS_TOKEN in the folowing precedence from highest
to lowest:
+ - ```wskdeploy``` command line (i.e. ```wskdeploy --apihost --namespace
--auth```)
+ - The deployment file
+ - The manifest file
+ - The .wskprops file
+- So when filling out the credentials and the APIGW_ACCESS_TOKEN, it first
looks to the command line. Anything not found on the command line is attempted
to be filled by the deployment file. Next it searches for all the unfilled
values in the manifest file, and finally any unfilled values are looked for in
the .wskprops file. After failing to find a value in the places mentioned
above, namespace will default to "_". In the case of a TravisCI environment,
APIGW_ACCESS_TOKEN will be set to [...]