Integrating wskdeploy into wsk CLI (#394)
* introducing project management using wskdeploy
* introducing project management using wskdeploy
* integrating wskdeploy into wsk CLI
* go fmt
* fixing typo
* updating deps
* adding . after newline, introducing IDs
* adding Ids into messages
diff --git a/build.gradle b/build.gradle
index eca828e..f4d418c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -44,20 +44,21 @@
golang {
// BEGIN - Imported from Godeps
build(['name':'github.com/cloudfoundry/jibber_jabber', 'version':'bcc4c8345a21301bf47c032ff42dd1aae2fe3027', 'transitive':false])
- build(['name':'github.com/fatih/color', 'version':'87d4004f2ab62d0d255e0a38f1680aa534549fe3', 'transitive':false])
+ build(['name':'github.com/fatih/color', 'version':'570b54cabe6b8eb0bc2dfce68d964677d63b5260', 'transitive':false])
build(['name':'github.com/google/go-querystring/query', 'version':'9235644dd9e52eeae6fa48efd539fdc351a0af53', 'transitive':false])
build(['name':'github.com/hokaccha/go-prettyjson', 'version':'f75235bd99dad4e98ff360db8372d5c0ef1d054a', 'transitive':false])
build(['name':'github.com/inconshreveable/mousetrap', 'version':'76626ae9c91c4f2a10f34cad8ce83ea42c93bb75', 'transitive':false])
build(['name':'github.com/mattn/go-colorable', 'version':'d228849504861217f796da67fae4f6e347643f15', 'transitive':false])
- build(['name':'github.com/mattn/go-isatty', 'version':'66b8e73f3f5cda9f96b69efd03dd3d7fc4a5cdb8', 'transitive':false])
+ build(['name':'github.com/mattn/go-isatty', 'version':'a5cdd64afdee435007ee3e9f6ed4684af949d568', 'transitive':false])
build(['name':'github.com/mitchellh/go-homedir', 'version':'1111e456ffea841564ac0fa5f69c26ef44dafec9', 'transitive':false])
- build(['name':'github.com/nicksnyder/go-i18n/i18n/...', 'version':'37e5c2de3e03e4b82693e3fcb4a6aa2cc4eb07e3', 'transitive':false])
+ build(['name':'github.com/nicksnyder/go-i18n/i18n/...', 'version':'991e81cc94f6c54209edb3192cb98e3995ad71c1', 'transitive':false])
build(['name':'github.com/spf13/cobra', 'version':'1238ba19d24b0b9ceee2094e1cb31947d45c3e86', 'transitive':false])
build(['name':'github.com/spf13/pflag', 'version':'367864438f1b1a3c7db4da06a2f55b144e6784e0', 'transitive':false])
build(['name':'golang.org/x/sys/unix', 'version':'7f918dd405547ecb864d14a8ecbbfe205b5f930f', 'transitive':false])
- build(['name':'gopkg.in/yaml.v2', 'version':'cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b', 'transitive':false])
+ build(['name':'gopkg.in/yaml.v2', 'version':'eb3733d160e74a9c7e442f435eb3bea458e1d19f', 'transitive':false])
build(['name':'github.com/ghodss/yaml', 'version':'0ca9ea5df5451ffdf184b4428c902747c2c11cd7', 'transitive':false])
build(['name':'github.com/apache/incubator-openwhisk-client-go/whisk','version':'c7013c9f456f35be34b3bf166535aaa03b834331','transitive':false])
+ build(['name':'github.com/apache/incubator-openwhisk-wskdeploy','version':'3bcc605a7f969f5b7f76f5990caa0ef562e3404a','transitive':false])
// END - Imported from Godeps
test name:'github.com/stretchr/testify', version:'b91bfb9ebec76498946beb6af7c0230c7cc7ba6c', transitive:false //, tag: 'v1.2.0'
test name:'github.com/spf13/viper', version:'aafc9e6bc7b7bb53ddaa75a5ef49a17d6e654be5', transitive:false
diff --git a/commands/messages.go b/commands/messages.go
index 91b4f24..e04a14c 100644
--- a/commands/messages.go
+++ b/commands/messages.go
@@ -24,4 +24,8 @@
*/
const (
FEED_CONFIGURATION_FAILURE = "FEED_CONFIGURATION_FAILURE"
+ CMD_DESC_LONG_DEPLOY = "CMD_DESC_LONG_DEPLOY"
+ CMD_DESC_LONG_SYNC = "CMD_DESC_LONG_SYNC"
+ CMD_DESC_LONG_UNDEPLOY = "CMD_DESC_LONG_UNDEPLOY"
+ CMD_DESC_LONG_EXPORT = "CMD_DESC_LONG_EXPORT"
)
diff --git a/commands/project.go b/commands/project.go
new file mode 100644
index 0000000..c109e3f
--- /dev/null
+++ b/commands/project.go
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package commands
+
+import (
+ "github.com/apache/incubator-openwhisk-cli/wski18n"
+ "github.com/apache/incubator-openwhisk-wskdeploy/cmd"
+ "github.com/apache/incubator-openwhisk-wskdeploy/utils"
+ wskdeploy_wski18n "github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
+ "github.com/spf13/cobra"
+)
+
+var projectCmd = &cobra.Command{
+ Use: "project",
+ Short: "The OpenWhisk Project Management Tool",
+}
+
+var projectDeployCmd = &cobra.Command{
+ Use: "deploy",
+ Short: wski18n.T(wskdeploy_wski18n.ID_CMD_DESC_SHORT_ROOT),
+ Long: wski18n.T(CMD_DESC_LONG_DEPLOY),
+ SilenceUsage: true,
+ SilenceErrors: true,
+ RunE: func(cobraCMD *cobra.Command, args []string) error {
+ return cmd.Deploy(cobraCMD)
+ },
+}
+
+var projectUnDeployCmd = &cobra.Command{
+ Use: "undeploy",
+ Short: wski18n.T(wskdeploy_wski18n.ID_CMD_DESC_SHORT_UNDEPLOY),
+ Long: wski18n.T(CMD_DESC_LONG_UNDEPLOY),
+ SilenceUsage: true,
+ SilenceErrors: true,
+ RunE: func(cobraCMD *cobra.Command, args []string) error {
+ return cmd.Undeploy(cobraCMD)
+ },
+}
+
+var projectSyncCmd = &cobra.Command{
+ Use: "sync",
+ Short: wski18n.T(wskdeploy_wski18n.ID_CMD_DESC_SHORT_SYNC),
+ Long: wski18n.T(CMD_DESC_LONG_SYNC),
+ SilenceUsage: true,
+ SilenceErrors: true,
+ RunE: func(cobraCMD *cobra.Command, args []string) error {
+ utils.Flags.Sync = true
+ return cmd.Deploy(cobraCMD)
+ },
+}
+
+var projectExportCmd = &cobra.Command{
+ Use: "export",
+ Short: wski18n.T(wskdeploy_wski18n.ID_CMD_DESC_SHORT_EXPORT),
+ Long: wski18n.T(CMD_DESC_LONG_EXPORT),
+ SilenceUsage: true,
+ SilenceErrors: true,
+ RunE: func(cobraCMD *cobra.Command, args []string) error {
+ return cmd.ExportCmdImp(cobraCMD, args)
+ },
+}
+
+func init() {
+ projectCmd.PersistentFlags().StringVar(&utils.Flags.CfgFile, cmd.FLAG_CONFIG, "", wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_CONFIG))
+ projectCmd.PersistentFlags().StringVarP(&utils.Flags.ManifestPath, cmd.FLAG_MANIFEST, "", "", wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_MANIFEST))
+ projectCmd.PersistentFlags().StringVarP(&utils.Flags.ProjectPath, cmd.FLAG_PROJECT, "", ".", wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_PROJECT))
+ projectCmd.PersistentFlags().StringVarP(&utils.Flags.DeploymentPath, cmd.FLAG_DEPLOYMENT, "", "", wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_DEPLOYMENT))
+ projectCmd.PersistentFlags().BoolVarP(&utils.Flags.Strict, cmd.FLAG_STRICT, "", false, wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_STRICT))
+ projectCmd.PersistentFlags().BoolVarP(&utils.Flags.Preview, cmd.FLAG_PREVIEW, "", false, wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_PREVIEW))
+ projectCmd.PersistentFlags().StringSliceVarP(&utils.Flags.Param, cmd.FLAG_PARAM, "", []string{}, wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_PARAM))
+ projectCmd.PersistentFlags().StringVarP(&utils.Flags.ParamFile, cmd.FLAG_PARAMFILE, "", "", wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_PARAM_FILE))
+ projectCmd.PersistentFlags().StringVarP(&utils.Flags.ApiHost, cmd.FLAG_API_HOST, "", "", wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_API_HOST))
+ projectCmd.PersistentFlags().StringVarP(&utils.Flags.Namespace, cmd.FLAG_NAMESPACE, cmd.FLAG_NAMESPACE_SHORT, "", wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_NAMESPACE))
+ projectCmd.PersistentFlags().StringVarP(&utils.Flags.Auth, cmd.FLAG_AUTH, cmd.FLAG_AUTH_SHORT, "", wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_AUTH_KEY))
+ projectCmd.PersistentFlags().BoolVarP(&utils.Flags.Verbose, cmd.FLAG_VERBOSE, cmd.FLAG_VERBOSE_SHORT, false, wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_VERBOSE))
+ projectCmd.PersistentFlags().StringVarP(&utils.Flags.Key, cmd.FLAG_KEY, cmd.FLAG_KEY_SHORT, "", wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_KEY_FILE))
+ projectCmd.PersistentFlags().StringVarP(&utils.Flags.Cert, cmd.FLAG_CERT, cmd.FLAG_CERT_SHORT, "", wski18n.T(wskdeploy_wski18n.ID_CMD_FLAG_CERT_FILE))
+
+ projectCmd.AddCommand(projectDeployCmd)
+ projectCmd.AddCommand(projectUnDeployCmd)
+ projectCmd.AddCommand(projectSyncCmd)
+ projectCmd.AddCommand(projectExportCmd)
+}
diff --git a/commands/wsk.go b/commands/wsk.go
index 963f437..28bf6d3 100644
--- a/commands/wsk.go
+++ b/commands/wsk.go
@@ -57,6 +57,7 @@
namespaceCmd,
listCmd,
apiCmd,
+ projectCmd,
)
WskCmd.PersistentFlags().BoolVarP(&Flags.Global.Verbose, "verbose", "v", false, wski18n.T("verbose output"))
diff --git a/wski18n/resources/en_US.all.json b/wski18n/resources/en_US.all.json
index a837d5e..a0e81b1 100644
--- a/wski18n/resources/en_US.all.json
+++ b/wski18n/resources/en_US.all.json
@@ -1586,5 +1586,21 @@
{
"id": "A response type of 'http' is required when using path parameters.",
"translation": "A response type of 'http' is required when using path parameters."
+ },
+ {
+ "id": "CMD_DESC_LONG_DEPLOY",
+ "translation": "To begin working with deploy, run the 'wsk project deploy' command:\n\n\t$ wsk project deploy\n\nThis will deploy OpenWhisk assets specified in manifest.yaml or manifest.yml.\nIf the working directory doesn't contain a manifest file, wsk project deploy prints this help message.\n\nThe most common ways of using wsk project deploy to deploy and/or undeploy OpenWhisk assets are:\n\n$ wsk project deploy\n$ wsk project deploy --manifest path/to/manifest.yaml\n$ wsk project deploy --manifest path/to/manifest.yaml --deployment path/to/deployment.yaml\n$ wsk project undeploy\n$ wsk project undeploy --manifest path/to/manifest.yaml\n$ wsk project undeploy --manifest path/to/manifest.yaml --deployment path/to/deployment.yaml\n\nAunthentication:\nwsk project deploy reads credentials from $HOME/.wskprops by default.\nOverwrite default config file on CLI:\n $ wsk project deploy --config <config file> --manifest path/to/manifest.yaml\nOr specify all three on CLI:\n $ wsk project deploy --apihost HOST --auth KEY --namespace NAMESPACE --manifest path/to/manifest.yaml"
+ },
+ {
+ "id": "CMD_DESC_LONG_UNDEPLOY",
+ "translation": "Undeploy removes OpenWhisk assets which were deployed from the manifest and deployment YAML.\n\nTo begin deleting OpenWhisk assets from the manifest file, run:\n$ wsk project undeploy\n$ wsk project undeploy --manifest path/to/manifest.yaml\n$ wsk project undeploy --manifest path/to/manifest.yaml --deployment path/to/deployment.yaml\n$ wsk project undeploy --projectname PROJECT (only works for deployments in sync mode)"
+ },
+ {
+ "id": "CMD_DESC_LONG_SYNC",
+ "translation": "A tool to sync deployment and undeployment of OpenWhisk packages using a manifest and optional deployment files using YAML.\n\nDifferent ways of running sync:\n$ wsk project sync\n$ wsk project sync --manifest path/to/manifest.yaml\n$ wsk project sync --manifest path/to/manifest.yaml --deployment path/to/manifest.yaml\n$ wsk project sync --manifest path/to/manifest.yaml --projectname PROJECT"
+ },
+ {
+ "id": "CMD_DESC_LONG_EXPORT",
+ "translation": "Exports managed project assets from OpenWhisk to manifest and function files.\n\nThe most common way to run export:\n$ wsk project export --projectname PROJECT --manifest path/to/exported-manifest.yaml"
}
]