You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by wi...@apache.org on 2020/08/21 08:00:19 UTC
[incubator-streampipes-installer] branch dev updated:
[STREAMPIPES-196] renamed template to env
This is an automated email from the ASF dual-hosted git repository.
wiener pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-installer.git
The following commit(s) were added to refs/heads/dev by this push:
new d25569f [STREAMPIPES-196] renamed template to env
d25569f is described below
commit d25569f307fa3c7e55770ddfb1cfcec95110ff3d
Author: Patrick Wiener <wi...@fzi.de>
AuthorDate: Fri Aug 21 09:52:49 2020 +0200
[STREAMPIPES-196] renamed template to env
---
cli/README.md | 40 +++++++++---------
cli/bin/commands/{template => env} | 87 ++++++++++++++++++++++----------------
cli/bin/commands/pull | 2 +-
cli/streampipes | 8 ++--
4 files changed, 77 insertions(+), 60 deletions(-)
diff --git a/cli/README.md b/cli/README.md
index 2e5113b..ca1be39 100644
--- a/cli/README.md
+++ b/cli/README.md
@@ -26,21 +26,17 @@ The StreamPipes command-line interface (CLI) is focused on developers in order t
**Current version:** 0.67.0-SNAPSHOT
<!-- END do not edit -->
-#### TL;DR
-<!-- ![](demo/streampipes-min.gif) -->
-<!-- <img src="demo/streampipes-min.gif" style="display: block;
- margin-left: auto;
- margin-right: auto;" width="100%"> -->
-
+## TL;DR
```bash
-$ streampipes template -l
-[INFO] Currently available StreamPipes environment templates
+streampipes env --list
+[INFO] Available StreamPipes environment templates:
pipeline-element
...
-$ streampipes template -s pipeline-element
-$ streampipes up -d
+streampipes env --set pipeline-element
+streampipes up -d
```
+> **NOTE**: use `./streampipes` if you haven't add it to the PATH and sourced it (see section "Run `streampipes` from anywhere?").
## Prerequisite
The CLI is basically a wrapper around multiple `docker` and `docker-compose` commands plus some additional sugar.
@@ -69,34 +65,35 @@ Options:
Commands:
clean Remove StreamPipes data volumes, dangling images and network
down Stop and remove StreamPipes containers
+ env Inspect and select StreamPipes environments
info Get information
logs Get container logs for specific container
ps List all StreamPipes container for running environment
pull Download latest images from Dockerhub
restart Restart StreamPipes environment
- template Select StreamPipes environment template
up Create and start StreamPipes container environment
Run 'streampipes COMMAND --help' for more info on a command.
```
## Usage: Along dev life-cycle
-**List** available environment templates
+
+**List** available environment templates.
```bash
-streampipes template --list
+streampipes env --list
```
-**Inspect** services in a given template to know what kind of services will be started as part this environment
+**Inspect** services in an available environment to know what kind of services it is composed of.
```bash
-streampipes template --inspect pipeline-element
+streampipes env --inspect pipeline-element
```
-**Set** environment template, e.g. `pipeline-element` if you want to write a new pipeline element
+**Set** environment, e.g. `pipeline-element`, if you want to write a new pipeline element.
```bash
-streampipes template --set pipeline-element
+streampipes env --set pipeline-element
```
-**Start** environment ( default: `dev` mode).
+**Start** environment ( default: `dev` mode). Here the service definition in the selected environment is used to start the multi-container landscape.
> **NOTE**: `dev` mode is enabled by default since we rely on open ports to core service such as `consul`, `couchdb`, `kafka` etc. to reach from the IDE when developing. If you don't want to map ports (except the UI port), then use the `--no-ports` flag.
```bash
@@ -127,7 +124,12 @@ streampipes down
streampipes up -d kafka consul
```
-**Get logs** of specific service
+**Get current environment** (if previously set using `streampipes env --set <environment>`).
+```bash
+streampipes env
+```
+
+**Get logs** of specific service and use optional `--follow` flag to stay attached to the logs.
```bash
streampipes logs --follow backend
```
diff --git a/cli/bin/commands/template b/cli/bin/commands/env
similarity index 50%
rename from cli/bin/commands/template
rename to cli/bin/commands/env
index 9bda0b2..4182937 100755
--- a/cli/bin/commands/template
+++ b/cli/bin/commands/env
@@ -18,32 +18,32 @@ set -e
STREAMPIPES_TEMPLATE_PATH=$STREAMPIPES_WORKDIR/bin/templates/environments
-cli_help_template() {
+cli_help_env() {
cat <<EOF
-Select StreamPipes environment template
+View current environment or inspect and select StreamPipes environment.
-Usage: streampipes template [OPTIONS]
+Usage: streampipes env [OPTIONS]
Example:
-# list all available environment templates
-streampipes template --list
+# list all available environments
+streampipes env --list
-# inspect services in environment template
-streampipes template --inspect backend
+# inspect services in environments
+streampipes env --inspect backend
-# set specific template, here 'backend'
-streampipes template --set backend
+# set specific environment, here 'backend'
+streampipes env --set backend
Options:
- -i, --inspect Inspect services in environment template
- -l, --list List all available environment templates
- -s, --set Set environment templates
+ -i, --inspect Inspect services in environment
+ -l, --list List all available environments
+ -s, --set Set environment
EOF
exit 1
}
-[ "$1" == '--help' ] || [ "$1" == '-h' ] || [ -z "$1" ] && cli_help_template
+[ "$1" == '--help' ] || [ "$1" == '-h' ] && cli_help_env
if [ "$#" -gt 3 ]; then
fatal "Illegal number of arguments, see 'streampipes ${0##*/} --help'"
@@ -53,67 +53,82 @@ while [[ "$#" -gt 0 ]]; do
case $1 in
-i|--inspect)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
- inspect_template="$2"
+ inspect_environment="$2"
shift 2
else
- fatal "Template for $1 is missing" >&2
+ fatal "Environment for $1 is missing" >&2
fi
;;
- -l|--list) list_templates=true; shift ;;
+ -l|--list) list_environments=true; shift ;;
-s|--set)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
- set_template="$2"
+ set_environment="$2"
shift 2
else
- fatal "Template for $1 is missing" >&2
+ fatal "Environment for $1 is missing" >&2
fi
;;
*) fatal "Unsupported command $1, see 'streampipes ${0##*/} --help'" >&2 ;;
esac
done
-check_template(){
+show_curr_environment(){
+ if [ ! -f "$STREAMPIPES_WORKDIR/.environment" ]; then
+ fatal "No environment set. See 'streampipes ${0##*/} --help'"
+ else
+ get_curr_environment
+ info "Current environment: $curr_environment"
+ fi
+}
+
+check_environment(){
template=$STREAMPIPES_TEMPLATE_PATH/$1
if [ ! -f "$template" ]; then
- fatal "Template not found '$1'. see 'streampipes ${0##*/} --list'"
+ fatal "Environment not found '$1'. see 'streampipes ${0##*/} --list'"
fi
}
-list_templates(){
- info "StreamPipes environment templates"
+list_environments(){
+ info "Available StreamPipes environment templates:"
for entry in "$STREAMPIPES_TEMPLATE_PATH"/*
do
echo "${entry##*/}"
done
}
-set_template(){
- check_template $set_template
- info "Set environment to template '$set_template'"
- cp $STREAMPIPES_TEMPLATE_PATH/$set_template $STREAMPIPES_WORKDIR/.environment
+set_environment(){
+ check_environment $set_environment
+ info "Set environment to '$set_environment'"
+ cp $STREAMPIPES_TEMPLATE_PATH/$set_environment $STREAMPIPES_WORKDIR/.environment
set_lf_line_encoding $STREAMPIPES_WORKDIR/.environment
}
-inspect_template(){
- check_template $inspect_template
+inspect_environment(){
+ check_environment $inspect_environment
search_str="[environment:"
- info "Inspect services in template '$inspect_template'"
+ info "Inspect services in environment '$inspect_environment'"
while IFS='' read -r line || [[ -n "$line" ]]; do
if [[ "$line" != *"$search_str"* ]]; then
echo $line
fi
- done < "$STREAMPIPES_TEMPLATE_PATH/$inspect_template"
+ done < "$STREAMPIPES_TEMPLATE_PATH/$inspect_environment"
}
-if [ "$list_templates" = true ]; then
- list_templates
+
+if [ "$list_environments" = true ]; then
+ list_environments
+fi
+
+if [ -n "$inspect_environment" ]; then
+ inspect_environment
fi
-if [ -n "$inspect_template" ]; then
- inspect_template
+if [ -n "$set_environment" ]; then
+ set_environment
fi
-if [ -n "$set_template" ]; then
- set_template
+if [[ -z "$1" && "$list_environments" != true && ! -n "$inspect_environment" \
+ && ! -n "$set_environment" ]]; then
+ show_curr_environment
fi
diff --git a/cli/bin/commands/pull b/cli/bin/commands/pull
index 720aaa6..b160362 100755
--- a/cli/bin/commands/pull
+++ b/cli/bin/commands/pull
@@ -34,5 +34,5 @@ fi
concatenate_compose_files
get_curr_environment
-info "Pull latest docker images of environment: '$curr_environment'"
+info "Pull latest docker images for environment: '$curr_environment'"
run "$docker_compose_files pull"
diff --git a/cli/streampipes b/cli/streampipes
index c1b1584..bfa9b24 100755
--- a/cli/streampipes
+++ b/cli/streampipes
@@ -31,12 +31,12 @@ Options:
Commands:
clean Remove StreamPipes data volumes, dangling images and network
down Stop and remove StreamPipes containers
+ env Inspect and select StreamPipes environments
info Get information
logs Get container logs for specific container
ps List all StreamPipes container for running environment
pull Download latest images from Dockerhub
restart Restart StreamPipes environment
- template Select StreamPipes environment template
up Create and start StreamPipes container environment
Run '$cli_name COMMAND --help' for more info on a command.
@@ -52,6 +52,9 @@ case "$1" in
down)
"$STREAMPIPES_WORKDIR/bin/commands/down" "${@:2}"
;;
+ env)
+ "$STREAMPIPES_WORKDIR/bin/commands/env" "${@:2}"
+ ;;
info)
"$STREAMPIPES_WORKDIR/bin/commands/info" "$2"
;;
@@ -70,9 +73,6 @@ case "$1" in
restart)
"$STREAMPIPES_WORKDIR/bin/commands/restart" "${@:2}"
;;
- template)
- "$STREAMPIPES_WORKDIR/bin/commands/template" "${@:2}"
- ;;
up)
"$STREAMPIPES_WORKDIR/bin/commands/up" "${@:2}"
;;