Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dummy token issue #1081

Merged
merged 2 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions deployers/whiskclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions docs/wskdeploy_faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 "DUMMY TOKEN" if it is not already set via one of the mechanisms described previously.