This is an automated email from the ASF dual-hosted git repository.
chetanm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new 74be0d77 Generate whisk.conf as default for wskadmin-next. (#3817)
74be0d77 is described below
commit 74be0d7788b9220cd7631495dd48c4bea01636e1
Author: Tzu-Chiao Yeh <[email protected]>
AuthorDate: Thu Jun 28 13:59:10 2018 +0800
Generate whisk.conf as default for wskadmin-next. (#3817)
Simplifies usage of `wskadmin-next` cli command by using a generated
`whisk.conf` from OpenWhisk home directory (similar to whisk.properties usage).
With this for default setup one can simply use
wskadmin-next user create userA
Without explicitly specifying the config file location
---
.gitignore | 1 +
ansible/tasks/writeWhiskProperties.yml | 5 ++++
ansible/templates/whisk.conf.j2 | 17 ++++++++++++++
tools/admin/README-NEXT.md | 27 +++++++++++-----------
.../admin/src/main/scala/whisk/core/cli/Main.scala | 9 ++++++--
5 files changed, 43 insertions(+), 16 deletions(-)
diff --git a/.gitignore b/.gitignore
index 44a18f8..426c273 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
# Whisk
nginx.conf
whisk.properties
+whisk.conf
default.props
/tests/src/test/resources/application.conf
diff --git a/ansible/tasks/writeWhiskProperties.yml
b/ansible/tasks/writeWhiskProperties.yml
index 1bbec34..516306b 100644
--- a/ansible/tasks/writeWhiskProperties.yml
+++ b/ansible/tasks/writeWhiskProperties.yml
@@ -13,3 +13,8 @@
template:
src: "{{ openwhisk_home }}/tests/src/test/resources/application.conf.j2"
dest: "{{ openwhisk_home }}/tests/src/test/resources/application.conf"
+
+- name: write whisk.conf template for wskadmin to openwhisk_home
+ template:
+ src: whisk.conf.j2
+ dest: "{{ openwhisk_home }}/whisk.conf"
diff --git a/ansible/templates/whisk.conf.j2 b/ansible/templates/whisk.conf.j2
new file mode 100644
index 0000000..58f0ea0
--- /dev/null
+++ b/ansible/templates/whisk.conf.j2
@@ -0,0 +1,17 @@
+include classpath("application.conf")
+
+whisk {
+ couchdb {
+ protocol = "{{ db_protocol }}"
+ host = "{{ db_host }}"
+ port = "{{ db_port }}"
+ username = "{{ db_username }}"
+ password = "{{ db_password }}"
+ provider = "{{ db_provider }}"
+ databases {
+ WhiskAuth = "{{ db.whisk.auth }}"
+ WhiskEntity = "{{ db.whisk.actions }}"
+ WhiskActivation = "{{ db.whisk.activations }}"
+ }
+ }
+}
diff --git a/tools/admin/README-NEXT.md b/tools/admin/README-NEXT.md
index 6d74e52..30de6c3 100644
--- a/tools/admin/README-NEXT.md
+++ b/tools/admin/README-NEXT.md
@@ -35,8 +35,7 @@ This creates a jar at
`tools/admin/build/libs/openwhisk-admin-tools-1.0.0-SNAPSH
### Setup
-Build task creates an executable at `bin/wskadmin-next`. This script requires
config related to `ArtifactStore`
-for accessing database. For example to access user details from default
CouchDB setup create a file `application-cli.conf`.
+Build task creates an executable at `bin/wskadmin-next`. By default, the
config related to `ArtifactStore` for accessing database will read the
`$OPENWHISK_HOME/whisk.conf`, which was generated by ansible `properties`
deployment. Alternatively, the required config can be also passed by an
overwritten config file. For example to access user details from default
CouchDB setup create a file `application-cli.conf`.
include classpath("application.conf")
@@ -70,40 +69,40 @@ and list all keys that have access to a particular
namespace.
Some examples:
```bash
# create a new user
-$ wskadmin-next -c application-cli.conf user create userA
+$ wskadmin-next user create userA
<prints key>
# add user to a specific namespace
-$ wskadmin-next -c application-cli.conf user create userA -ns space1
+$ wskadmin-next user create userA -ns space1
<prints new key specific to userA and space1>
# add second user to same space
-$ wskadmin-next -c application-cli.conf user create userB -ns space1
+$ wskadmin-next user create userB -ns space1
<prints new key specific to userB and space1>
# list all users sharing a space
-$ wskadmin-next -c application-cli.conf user list space1 -a
+$ wskadmin-next user list space1 -a
<key for userA> userA
<key for userB> userB
# remove user access to a namespace
-$ wskadmin-next -c application-cli.conf user delete userB -ns space1
+$ wskadmin-next user delete userB -ns space1
Namespace deleted
# get key for userA default namespaces
-$ wskadmin-next -c application-cli.conf user get userA
+$ wskadmin-next user get userA
<prints key specific to userA default namespace>
# block a user
-$ wskadmin-next -c application-cli.conf user block userA
+$ wskadmin-next user block userA
"userA" blocked successfully
# unblock a user
-$ wskadmin-next -c application-cli.conf user unblock userA
+$ wskadmin-next user unblock userA
"userA" unblocked successfully
# delete user
-$ wskadmin-next -c application-cli.conf user delete userB
+$ wskadmin-next user delete userB
Subject deleted
```
@@ -111,16 +110,16 @@ The `wskadmin-next limits` commands allow you set action
and trigger throttles p
```bash
# see if custom limits are set for a namespace
-$ wskadmin-next -c application-cli.conf limits get space1
+$ wskadmin-next limits get space1
No limits found, default system limits apply
# set limits
-$ wskadmin-next -c application-cli.conf limits set space1
--invocationsPerMinute 1
+$ wskadmin-next limits set space1 --invocationsPerMinute 1
Limits successfully set for "space1"
```
Note that limits apply to a namespace and will survive even if all users that
share a namespace are deleted. You must manually delete them.
```bash
-$ wskadmin-next -c application-cli.conf limits delete space1
+$ wskadmin-next limits delete space1
Limits deleted
```
diff --git a/tools/admin/src/main/scala/whisk/core/cli/Main.scala
b/tools/admin/src/main/scala/whisk/core/cli/Main.scala
index 58d6e4d..dbce510 100644
--- a/tools/admin/src/main/scala/whisk/core/cli/Main.scala
+++ b/tools/admin/src/main/scala/whisk/core/cli/Main.scala
@@ -54,7 +54,7 @@ class Conf(arguments: Seq[String]) extends
ScallopConf(arguments) {
}
}
val verbose = tally()
- val configFile = opt[File](descr = "application.conf path")(fileConverter)
+ val configFile = opt[File](descr = "application.conf which overwrites the
default whisk.conf")(fileConverter)
val timeout =
opt[Duration](descr = "time to wait for asynchronous task to finish",
default = Some(30.seconds))(durationConverter)
printedName = Main.printedName
@@ -132,7 +132,12 @@ object Main {
}
private def initConfig(conf: Conf): Unit = {
- conf.configFile.foreach(f => System.setProperty("config.file",
f.getAbsolutePath))
+ val file = conf.configFile.getOrElse {
+ new File("../whisk.conf")
+ }
+ if (file.exists()) {
+ System.setProperty("config.file", file.getAbsolutePath)
+ }
}
private def initLogging(conf: Conf): Unit = {