You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by mr...@apache.org on 2017/08/29 21:24:03 UTC
[incubator-openwhisk-wskdeploy] branch master updated: Make the
config file able to work for .wskprops (#408)
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/incubator-openwhisk-wskdeploy.git
The following commit(s) were added to refs/heads/master by this push:
new 0ea0810 Make the config file able to work for .wskprops (#408)
0ea0810 is described below
commit 0ea0810e5e4940780138bae602a9dd45308f4474
Author: Vincent <sh...@us.ibm.com>
AuthorDate: Tue Aug 29 17:24:01 2017 -0400
Make the config file able to work for .wskprops (#408)
---
Godeps/Godeps.json | 4 +-
cmd/root.go | 42 +++-----
cmd/root_test.go | 3 +-
deployers/whiskclient.go | 9 +-
tests/src/integration/dependency/manifest.yaml | 1 -
tests/src/integration/flagstests/manifest.yml | 2 +-
tests/src/integration/runtimetests/manifest.yaml | 97 ++++++++++++++++++
tests/src/integration/runtimetests/manifest.yml | 111 ---------------------
.../src/integration/runtimetests/runtimes_test.go | 11 +-
9 files changed, 130 insertions(+), 150 deletions(-)
diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json
index e3b6537..c0bf7bd 100644
--- a/Godeps/Godeps.json
+++ b/Godeps/Godeps.json
@@ -105,11 +105,11 @@
},
{
"ImportPath": "github.com/apache/incubator-openwhisk-client-go/whisk",
- "Rev": "c69110e47c8bcd56f25fbfd179c139b7555449d1"
+ "Rev": "6572868460e856f5658a57fb64f98236b73aaee0"
},
{
"ImportPath": "github.com/apache/incubator-openwhisk-client-go/wski18n",
- "Rev": "c69110e47c8bcd56f25fbfd179c139b7555449d1"
+ "Rev": "6572868460e856f5658a57fb64f98236b73aaee0"
},
{
"ImportPath": "github.com/pelletier/go-buffruneio",
diff --git a/cmd/root.go b/cmd/root.go
index 2ea7d2c..b2d0f01 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -26,13 +26,12 @@ import (
"github.com/apache/incubator-openwhisk-wskdeploy/deployers"
"github.com/apache/incubator-openwhisk-wskdeploy/utils"
"github.com/spf13/cobra"
- "github.com/spf13/viper"
"log"
"os"
- "path"
- "path/filepath"
"regexp"
"strings"
+ "path"
+ "path/filepath"
)
var RootCmd = &cobra.Command{
@@ -114,7 +113,7 @@ func init() {
// Cobra supports Persistent Flags, which, if defined here,
// will be global for your application.
- RootCmd.PersistentFlags().StringVar(&utils.Flags.CfgFile, "config", "", "config file (default is $HOME/.wskdeploy.yaml)")
+ RootCmd.PersistentFlags().StringVar(&utils.Flags.CfgFile, "config", "", "config file (default is $HOME/.wskprops)")
// Cobra also supports local flags, which will only run
// when this action is called directly.
RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
@@ -132,19 +131,18 @@ func init() {
// initConfig reads in config file and ENV variables if set.
func initConfig() {
+ userHome := utils.GetHomeDirectory()
+ defaultPath := path.Join(userHome, whisk.DEFAULT_LOCAL_CONFIG)
if utils.Flags.CfgFile != "" {
- // enable ability to specify config file via flag
- viper.SetConfigFile(utils.Flags.CfgFile)
- }
-
- viper.SetConfigName(".wskdeploy") // name of config file (without extension)
- viper.AddConfigPath("$HOME") // adding home directory as first search path
- viper.AutomaticEnv() // read in environment variables that match
-
- // If a config file is found, read it in.
- if err := viper.ReadInConfig(); err == nil {
- fmt.Println("Using config file:", viper.ConfigFileUsed())
- }
+ // Read the file as a wskprops file, to check if it is valid.
+ _, err := whisk.ReadProps(utils.Flags.CfgFile)
+ if err != nil {
+ utils.Flags.CfgFile = defaultPath
+ log.Println("Invalid config file detected, so by bdefault it is set to " + utils.Flags.CfgFile)
+ }
+ } else {
+ utils.Flags.CfgFile = defaultPath
+ }
}
func Deploy() error {
@@ -192,12 +190,7 @@ func Deploy() error {
// master record of any dependency that has been downloaded
deployer.DependencyMaster = make(map[string]utils.DependencyRecord)
- propPath := ""
- if !utils.Flags.WithinOpenWhisk {
- userHome := utils.GetHomeDirectory()
- propPath = path.Join(userHome, ".wskprops")
- }
- whiskClient, clientConfig := deployers.NewWhiskClient(propPath, utils.Flags.DeploymentPath, utils.Flags.ManifestPath, deployer.IsInteractive)
+ whiskClient, clientConfig := deployers.NewWhiskClient(utils.Flags.CfgFile, utils.Flags.DeploymentPath, utils.Flags.ManifestPath, deployer.IsInteractive)
deployer.Client = whiskClient
deployer.ClientConfig = clientConfig
@@ -260,10 +253,7 @@ func Undeploy() error {
deployer.IsInteractive = utils.Flags.UseInteractive
deployer.IsDefault = utils.Flags.UseDefaults
- userHome := utils.GetHomeDirectory()
- propPath := path.Join(userHome, ".wskprops")
-
- whiskClient, clientConfig := deployers.NewWhiskClient(propPath, utils.Flags.DeploymentPath, utils.Flags.ManifestPath, deployer.IsInteractive)
+ whiskClient, clientConfig := deployers.NewWhiskClient(utils.Flags.CfgFile, utils.Flags.DeploymentPath, utils.Flags.ManifestPath, deployer.IsInteractive)
deployer.Client = whiskClient
deployer.ClientConfig = clientConfig
diff --git a/cmd/root_test.go b/cmd/root_test.go
index 3bb9ad0..2a360c5 100644
--- a/cmd/root_test.go
+++ b/cmd/root_test.go
@@ -26,6 +26,7 @@ import (
"github.com/stretchr/testify/assert"
"strings"
"testing"
+ "os"
)
var rootcalled bool
@@ -86,7 +87,7 @@ func initializeParameters() {
expected_auth_flags.Auth = "fake_auth"
expected_auth_flags.ApiVersion = "fake_api_version"
- expected_input.CfgFile = "fake_config_file"
+ expected_input.CfgFile = os.Getenv("GOPATH") + "/src/github.com/apache/incubator-openwhisk-wskdeploy/tests/dat/wskprops"
expected_input.Verbose = true
expected_input.UseDefaults = true
expected_input.UseInteractive = true
diff --git a/deployers/whiskclient.go b/deployers/whiskclient.go
index 33fd9cd..675f9be 100644
--- a/deployers/whiskclient.go
+++ b/deployers/whiskclient.go
@@ -29,6 +29,7 @@ import (
"github.com/apache/incubator-openwhisk-wskdeploy/parsers"
"github.com/apache/incubator-openwhisk-wskdeploy/utils"
"errors"
+ "log"
)
const (
@@ -108,6 +109,7 @@ func NewWhiskClient(proppath string, deploymentPath string, manifestPath string,
pi := whisk.PropertiesImp {
OsPackage: whisk.OSPackageImp{},
}
+
wskprops, _ := GetWskPropFromWskprops(pi, proppath)
credential = GetPropertyValue(credential, wskprops.AuthKey, WSKPROPS)
namespace = GetPropertyValue(namespace, wskprops.Namespace, WSKPROPS)
@@ -171,13 +173,14 @@ func NewWhiskClient(proppath string, deploymentPath string, manifestPath string,
utils.Check(err)
}
- fmt.Println("The URL is " + baseURL.String() + ", selected from " + apiHost.Source)
- fmt.Println("The auth key is set, selected from " + credential.Source)
- fmt.Println("The namespace is " + namespace.Value + ", selected from " + namespace.Source)
+ log.Println("The URL is " + baseURL.String() + ", selected from " + apiHost.Source)
+ log.Println("The auth key is set, selected from " + credential.Source)
+ log.Println("The namespace is " + namespace.Value + ", selected from " + namespace.Source)
clientConfig = &whisk.Config{
AuthToken: credential.Value, //Authtoken
Namespace: namespace.Value, //Namespace
BaseURL: baseURL,
+ Host: apiHost.Value,
Version: "v1",
Insecure: true, // true if you want to ignore certificate signing
diff --git a/tests/src/integration/dependency/manifest.yaml b/tests/src/integration/dependency/manifest.yaml
index 3c64f13..f76390d 100644
--- a/tests/src/integration/dependency/manifest.yaml
+++ b/tests/src/integration/dependency/manifest.yaml
@@ -1,6 +1,5 @@
package:
name: TestGitHubDependency
- namespace: guest
dependencies:
openwhisk-app:
location: github.com/pritidesai/openwhisk-app
diff --git a/tests/src/integration/flagstests/manifest.yml b/tests/src/integration/flagstests/manifest.yml
index 5080c6e..5970bba 100644
--- a/tests/src/integration/flagstests/manifest.yml
+++ b/tests/src/integration/flagstests/manifest.yml
@@ -1,5 +1,5 @@
package:
- name: helloworld
+ name: helloworldFlags
version: 1.0
license: Apache-2.0
actions:
diff --git a/tests/src/integration/runtimetests/manifest.yaml b/tests/src/integration/runtimetests/manifest.yaml
new file mode 100644
index 0000000..8948af5
--- /dev/null
+++ b/tests/src/integration/runtimetests/manifest.yaml
@@ -0,0 +1,97 @@
+package:
+ name: TestExplicitRuntimes
+ version: 1.0
+ license: Apache-2.0
+ actions:
+ greeting:
+ web-export: true
+ version: 1.0
+ function: src/greeting.js
+ runtime: nodejs:6
+ inputs:
+ name: string
+ place: string
+ outputs:
+ payload: string
+ greetingphp:
+ web-export: true
+ version: 1.0
+ function: src/hello.php
+ runtime: php:7.1
+ inputs:
+ name: string
+ place: string
+ outputs:
+ payload: string
+ greetingpython:
+ web-export: true
+ version: 1.0
+ function: src/hello.py
+ runtime: python
+ inputs:
+ name: string
+ place: string
+ outputs:
+ payload: string
+ greetingpython:
+ web-export: true
+ version: 1.0
+ function: src/hello.py
+ runtime: python:2
+ inputs:
+ name: string
+ place: string
+ outputs:
+ payload: string
+ greetingpython:
+ web-export: true
+ version: 1.0
+ function: src/hello.py
+ runtime: python:3
+ inputs:
+ name: string
+ place: string
+ outputs:
+ payload: string
+ greetingswift:
+ web-export: true
+ version: 1.0
+ function: src/hello.swift
+ runtime: swift:3.1.1
+ inputs:
+ name: string
+ place: string
+ outputs:
+ payload: string
+ greetingswift:
+ web-export: true
+ version: 1.0
+ function: src/hello.swift
+ runtime: swift
+ inputs:
+ name: string
+ place: string
+ outputs:
+ payload: string
+ greetingswift:
+ web-export: true
+ version: 1.0
+ function: src/hello.swift
+ runtime: swift:3
+ inputs:
+ name: string
+ place: string
+ outputs:
+ payload: string
+ helloworldjava:
+ function: src/hello.jar
+ runtime: java
+ main: Hello
+ triggers:
+ locationUpdateRuntime:
+ rules:
+ myRuleRuntime:
+ trigger: locationUpdateRuntime
+ #the action name and the action file greeting.js should consistent.
+ #currently the implementation deside the action name consistent with action file name?
+ action: greeting
diff --git a/tests/src/integration/runtimetests/manifest.yml b/tests/src/integration/runtimetests/manifest.yml
deleted file mode 100644
index 10d0d22..0000000
--- a/tests/src/integration/runtimetests/manifest.yml
+++ /dev/null
@@ -1,111 +0,0 @@
-package:
- name: helloworld
- version: 1.0
- license: Apache-2.0
- actions:
- greeting:
- web-export: true
- version: 1.0
- function: src/greeting.js
- runtime: nodejs:6
- inputs:
- name: string
- place: string
- outputs:
- payload: string
- actions:
- greetingphp:
- web-export: true
- version: 1.0
- function: src/hello.php
- runtime: php:7.1
- inputs:
- name: string
- place: string
- outputs:
- payload: string
- actions:
- greetingpython:
- web-export: true
- version: 1.0
- function: src/hello.py
- runtime: python
- inputs:
- name: string
- place: string
- outputs:
- payload: string
- actions:
- greetingpython:
- web-export: true
- version: 1.0
- function: src/hello.py
- runtime: python:2
- inputs:
- name: string
- place: string
- outputs:
- payload: string
- actions:
- greetingpython:
- web-export: true
- version: 1.0
- function: src/hello.py
- runtime: python:3
- inputs:
- name: string
- place: string
- outputs:
- payload: string
- actions:
- greetingswift:
- web-export: true
- version: 1.0
- function: src/hello.swift
- runtime: swift:3.1.1
- inputs:
- name: string
- place: string
- outputs:
- payload: string
- actions:
- greetingswift:
- web-export: true
- version: 1.0
- function: src/hello.swift
- runtime: swift
- inputs:
- name: string
- place: string
- outputs:
- payload: string
- actions:
- greetingswift:
- web-export: true
- version: 1.0
- function: src/hello.swift
- runtime: swift:3
- inputs:
- name: string
- place: string
- outputs:
- payload: string
- actions:
- helloworldjava:
- function: src/hello.jar
- runtime: java
- main: Hello
- actions:
- helloworldinvalid:
- function: src/hello.jar
- runtime: invalid
- main: Hello
- triggers:
- locationUpdate:
- rules:
- myRule:
- trigger: locationUpdate
- #the action name and the action file greeting.js should consistent.
- #currently the implementation deside the action name consistent with action file name?
- action: greeting
-
diff --git a/tests/src/integration/runtimetests/runtimes_test.go b/tests/src/integration/runtimetests/runtimes_test.go
index f5228ba..f436768 100644
--- a/tests/src/integration/runtimetests/runtimes_test.go
+++ b/tests/src/integration/runtimetests/runtimes_test.go
@@ -28,11 +28,12 @@ import (
var wskprops = common.GetWskprops()
-func TestSupportProjectPath(t *testing.T) {
- os.Setenv("__OW_API_HOST", wskprops.APIHost)
+func TestExplicitRuntimes(t *testing.T) {
wskdeploy := common.NewWskdeploy()
- manifestPath := os.Getenv("GOPATH") + "/src/github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/runtimetests"
- _, err := wskdeploy.DeployManifestPathOnly(manifestPath)
- assert.Equal(t, nil, err, "Failed to deploy based on the manifest path")
+ projectPath := os.Getenv("GOPATH") + "/src/github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/runtimetests"
+ _, err := wskdeploy.DeployProjectPathOnly(projectPath)
+ assert.Equal(t, nil, err, "Failed to deploy based on the project path")
+ _, err = wskdeploy.UndeployProjectPathOnly(projectPath)
+ assert.Equal(t, nil, err, "Failed to undeploy based on the project path")
}
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].