func NewWhiskConfig()

in deployers/whiskclient.go [203:269]


func NewWhiskConfig(proppath string, deploymentPath string, manifestPath string) (*whisk.Config, error) {
	// reset credential, apiHost, namespace, etc to avoid any conflicts as they initialized globally
	resetWhiskConfig()

	// read from command line
	readFromCLI()

	// TODO() i18n
	// Print all flags / values if verbose
	//wskprint.PrintlnOpenWhiskVerbose(utils.Flags.Verbose, wski18n.CONFIGURATION+":\n"+utils.Flags.Format())

	// now, read them from deployment file if not found on command line
	readFromDeploymentFile(deploymentPath)

	// read credentials from manifest file as didn't find them on command line and in deployment file
	readFromManifestFile(manifestPath)

	// Third, we need to look up the variables in .wskprops file.
	pi := whisk.PropertiesImp{
		OsPackage: whisk.OSPackageImp{},
	}

	readFromWskprops(pi, proppath)

	// 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
		namespace.Source = SOURCE_DEFAULT_VALUE
	}

	mode := true
	if len(cert.Value) != 0 && len(key.Value) != 0 {
		mode = false
	}

	clientConfig = &whisk.Config{
		AuthToken: credential.Value, //Authtoken
		Namespace: namespace.Value,  //Namespace
		Host:      apiHost.Value,
		Version:   "v1", // TODO() should not be hardcoded, should warn user of default
		//Version:           Apiversion
		Cert:              cert.Value,
		Key:               key.Value,
		Insecure:          mode, // true if you want to ignore certificate signing
		ApigwAccessToken:  apigwAccessToken.Value,
		ApigwTenantId:     apigwTenantId.Value,
		AdditionalHeaders: additionalHeaders,
	}

	// Print all flags / values if verbose
	wskprint.PrintlnOpenWhiskVerbose(utils.Flags.Verbose, wski18n.CLI_FLAGS+":\n"+utils.Flags.Format())

	// validate we have credential, apihost and namespace
	err := validateClientConfig(credential, apiHost, namespace)
	return clientConfig, err
}