This is an automated email from the ASF dual-hosted git repository.
houshengbo 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 823ea87 Fixing undeployment with yml
823ea87 is described below
commit 823ea87182faf5524af4a96770a9388ec32c263b
Author: Priti Desai <[email protected]>
AuthorDate: Thu Aug 31 09:38:25 2017 -0700
Fixing undeployment with yml
---
cmd/root.go | 45 ++++++++++++++++++++++++++-------------------
deployers/whiskclient.go | 19 +++++++++----------
2 files changed, 35 insertions(+), 29 deletions(-)
diff --git a/cmd/root.go b/cmd/root.go
index 97e10c3..e12fb46 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -156,19 +156,19 @@ func Deploy() error {
if _, err := os.Stat(path.Join(projectPath,
utils.ManifestFileNameYaml)); err == nil {
utils.Flags.ManifestPath = path.Join(projectPath,
utils.ManifestFileNameYaml)
log.Printf("Using %s for deployment \n",
utils.Flags.ManifestPath)
- } else if _, err := os.Stat(path.Join(projectPath,
utils.ManifestFileNameYaml)); err == nil {
+ } else if _, err := os.Stat(path.Join(projectPath,
utils.ManifestFileNameYml)); err == nil {
utils.Flags.ManifestPath = path.Join(projectPath,
utils.ManifestFileNameYml)
log.Printf("Using %s for deployment",
utils.Flags.ManifestPath)
} else {
log.Printf("Manifest file not found at path %s",
projectPath)
- return errors.New("missing manifest.yaml file")
+ return errors.New("missing
"+utils.ManifestFileNameYaml+"/" +utils.ManifestFileNameYml+" file")
}
}
if utils.Flags.DeploymentPath == "" {
- if _, err := os.Stat(path.Join(projectPath,
"deployment.yaml")); err == nil {
+ if _, err := os.Stat(path.Join(projectPath,
utils.DeploymentFileNameYaml)); err == nil {
utils.Flags.DeploymentPath = path.Join(projectPath,
utils.DeploymentFileNameYaml)
- } else if _, err := os.Stat(path.Join(projectPath,
"deployment.yml")); err == nil {
+ } else if _, err := os.Stat(path.Join(projectPath,
utils.DeploymentFileNameYml)); err == nil {
utils.Flags.DeploymentPath = path.Join(projectPath,
utils.DeploymentFileNameYml)
}
}
@@ -211,12 +211,11 @@ func Deploy() error {
} else {
if utils.Flags.WithinOpenWhisk {
- utils.PrintOpenWhiskError(wski18n.T("missing
manifest.yaml file"))
- return errors.New("missing manifest.yaml file")
+ utils.PrintOpenWhiskError(wski18n.T("missing
"+utils.ManifestFileNameYaml+"/" +utils.ManifestFileNameYml+" file"))
} else {
- log.Println("missing manifest.yaml file")
- return errors.New("missing manifest.yaml file")
+ log.Println("missing "+utils.ManifestFileNameYaml+"/"
+utils.ManifestFileNameYml+" file")
}
+ return errors.New("missing "+utils.ManifestFileNameYaml+"/"
+utils.ManifestFileNameYml+" file")
}
}
@@ -225,22 +224,30 @@ func Undeploy() error {
// TODO: Work your own magic here
whisk.SetVerbose(utils.Flags.Verbose)
+ projectPath, err := filepath.Abs(utils.Flags.ProjectPath)
+ utils.Check(err)
+
if utils.Flags.ManifestPath == "" {
- if ok, _ := regexp.Match(utils.ManifestFileNameYml,
[]byte(utils.Flags.ManifestPath)); ok {
- utils.Flags.ManifestPath =
path.Join(utils.Flags.ProjectPath, utils.ManifestFileNameYml)
+ if _, err := os.Stat(path.Join(projectPath,
utils.ManifestFileNameYaml)); err == nil {
+ utils.Flags.ManifestPath = path.Join(projectPath,
utils.ManifestFileNameYaml)
+ log.Printf("Using %s for undeployment \n",
utils.Flags.ManifestPath)
+ } else if _, err := os.Stat(path.Join(projectPath,
utils.ManifestFileNameYml)); err == nil {
+ utils.Flags.ManifestPath = path.Join(projectPath,
utils.ManifestFileNameYml)
+ log.Printf("Using %s for undeployment",
utils.Flags.ManifestPath)
} else {
- utils.Flags.ManifestPath =
path.Join(utils.Flags.ProjectPath, utils.ManifestFileNameYaml)
+ log.Printf("Manifest file not found at path %s",
projectPath)
+ return errors.New("missing
"+utils.ManifestFileNameYaml+"/" +utils.ManifestFileNameYml+" file")
}
-
}
if utils.Flags.DeploymentPath == "" {
- if ok, _ := regexp.Match(utils.DeploymentFileNameYml,
[]byte(utils.Flags.ManifestPath)); ok {
- utils.Flags.DeploymentPath =
path.Join(utils.Flags.ProjectPath, utils.DeploymentFileNameYml)
- } else {
- utils.Flags.DeploymentPath =
path.Join(utils.Flags.ProjectPath, utils.DeploymentFileNameYaml)
+ if _, err := os.Stat(path.Join(projectPath,
utils.DeploymentFileNameYaml)); err == nil {
+ utils.Flags.DeploymentPath = path.Join(projectPath,
utils.DeploymentFileNameYaml)
+ log.Printf("Using %s for undeployment \n",
utils.Flags.DeploymentPath)
+ } else if _, err := os.Stat(path.Join(projectPath,
utils.DeploymentFileNameYml)); err == nil {
+ utils.Flags.DeploymentPath = path.Join(projectPath,
utils.DeploymentFileNameYml)
+ log.Printf("Using %s for undeployment \n",
utils.Flags.DeploymentPath)
}
-
}
if utils.FileExists(utils.Flags.ManifestPath) {
@@ -267,7 +274,7 @@ func Undeploy() error {
}
} else {
- log.Println("missing manifest.yaml file")
- return errors.New("missing manifest.yaml file")
+ log.Println("missing "+utils.ManifestFileNameYaml+"/"
+utils.ManifestFileNameYml+" file")
+ return errors.New("missing "+utils.ManifestFileNameYaml+"/"
+utils.ManifestFileNameYml+" file")
}
}
diff --git a/deployers/whiskclient.go b/deployers/whiskclient.go
index 675f9be..7bd7d08 100644
--- a/deployers/whiskclient.go
+++ b/deployers/whiskclient.go
@@ -28,13 +28,12 @@ import (
"github.com/apache/incubator-openwhisk-client-go/whisk"
"github.com/apache/incubator-openwhisk-wskdeploy/parsers"
"github.com/apache/incubator-openwhisk-wskdeploy/utils"
- "errors"
- "log"
+ "errors"
+ "log"
+ "path"
)
const (
- DEPLOYMENTFILE = "deployment.yml"
- MANIDESTFILE = "manifest.yml"
COMMANDLINE = "wskdeploy command line"
DEFAULTVALUE = "default value"
WSKPROPS = ".wskprops"
@@ -81,20 +80,20 @@ func NewWhiskClient(proppath string, deploymentPath string,
manifestPath string,
mm := parsers.NewYAMLParser()
deployment := mm.ParseDeployment(deploymentPath)
credential.Value = deployment.Application.Credential
- credential.Source = DEPLOYMENTFILE
+ credential.Source = path.Base(deploymentPath)
namespace.Value = deployment.Application.Namespace
- namespace.Source = DEPLOYMENTFILE
+ namespace.Source = path.Base(deploymentPath)
apiHost.Value = deployment.Application.ApiHost
- apiHost.Source = DEPLOYMENTFILE
+ apiHost.Source = path.Base(deploymentPath)
}
if len(credential.Value) == 0 || len(namespace.Value) == 0 ||
len(apiHost.Value) == 0 {
if utils.FileExists(manifestPath) {
mm := parsers.NewYAMLParser()
manifest := mm.ParseManifest(manifestPath)
- credential = GetPropertyValue(credential,
manifest.Package.Credential, MANIDESTFILE)
- namespace = GetPropertyValue(namespace,
manifest.Package.Namespace, MANIDESTFILE)
- apiHost = GetPropertyValue(apiHost, manifest.Package.ApiHost,
MANIDESTFILE)
+ credential = GetPropertyValue(credential,
manifest.Package.Credential, path.Base(manifestPath))
+ namespace = GetPropertyValue(namespace,
manifest.Package.Namespace, path.Base(manifestPath))
+ apiHost = GetPropertyValue(apiHost, manifest.Package.ApiHost,
path.Base(manifestPath))
}
}
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].