This is an automated email from the ASF dual-hosted git repository.
jonzeolla pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/metron-bro-plugin-kafka.git
The following commit(s) were added to refs/heads/master by this push:
new 43c9166 METRON-2045 Pass a version argument to the bro plugin docker
scripts (JonZeolla) closes apache/metron-bro-plugin-kafka#35
43c9166 is described below
commit 43c9166787649e4ac2ab295a1baba94d54903651
Author: JonZeolla
AuthorDate: Mon Apr 29 08:24:12 2019 -0400
METRON-2045 Pass a version argument to the bro plugin docker scripts
(JonZeolla) closes apache/metron-bro-plugin-kafka#35
---
docker/README.md | 12 +++--
docker/in_docker_scripts/build_bro_plugin.sh | 59 ++-
docker/run_end_to_end.sh | 30 +---
docker/scripts/docker_execute_build_bro_plugin.sh | 23 +++--
docker/scripts/docker_execute_shell.sh| 2 +-
5 files changed, 110 insertions(+), 16 deletions(-)
diff --git a/docker/README.md b/docker/README.md
index bde7b5e..eac2919 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -50,7 +50,7 @@ testing scripts to be added to a pull request, and
subsequently to a test suite.
└── wait_for_zk.sh
```
-- `build_bro_plugin.sh`: Runs `bro-pkg` to build and install the plugin.
+- `build_bro_plugin.sh`: Runs `bro-pkg` to build and install the provided
version of the plugin.
- `configure_bro_plugin.sh`: Configures the plugin for the kafka container,
and routes all traffic types.
- `process_data_file.sh`: Runs `bro -r` on the passed file
- `wait-for-it.sh`: Waits for a port to be open, so we know something is
available.
@@ -294,7 +294,11 @@ Other scripts may then be used to do your testing, for
example running:
# `run_end_to_end.sh`
## Parameters
```bash
---skip-docker-build[OPTIONAL] Skip build of bro docker machine.
---data-path[OPTIONAL] The pcap data path. Default: ./data
---kafka-topic [OPTIONAL] The kafka topic name to use.
Default: bro
+--skip-docker-build [OPTIONAL] Skip build of bro docker machine.
+--data-path [OPTIONAL] The pcap data path. Default: ./data
+--kafka-topic [OPTIONAL] The kafka topic name to use.
Default: bro
+--plugin-version[OPTIONAL] The plugin version. Default: the
current branch name
```
+
+> NOTE: The provided `--plugin-version` is passed to the [`bro-pkg
install`](https://docs.zeek.org/projects/package-manager/en/stable/bro-pkg.html#install-command)
command within the container, which allows you to specify a version tag,
branch name, or commit hash. However, that tag, branch, or commit *must* be
available in the currently checked out plugin repository.
+
diff --git a/docker/in_docker_scripts/build_bro_plugin.sh
b/docker/in_docker_scripts/build_bro_plugin.sh
index 46277bd..064fe91 100755
--- a/docker/in_docker_scripts/build_bro_plugin.sh
+++ b/docker/in_docker_scripts/build_bro_plugin.sh
@@ -18,16 +18,73 @@
#
shopt -s nocasematch
+shopt -s globstar nullglob
+shopt -s nocasematch
+set -u # nounset
+set -e # errexit
+set -E # errtrap
+set -o pipefail
#
# Runs bro-pkg to build and install the plugin
#
+function help {
+ echo " "
+ echo "usage: ${0}"
+ echo "--plugin-version[REQUIRED] The plugin version."
+ echo "-h/--help Usage information."
+ echo " "
+ echo " "
+}
+
+PLUGIN_VERSION=
+
+# Handle command line options
+for i in "$@"; do
+ case $i in
+ #
+ # PLUGIN_VERSION
+ #
+ # --plugin-version
+ #
+--plugin-version=*)
+ PLUGIN_VERSION="${i#*=}"
+ shift # past argument=value
+;;
+
+ #
+ # -h/--help
+ #
+-h | --help)
+ help
+ exit 0
+ shift # past argument with no value
+;;
+
+ #
+ # Unknown option
+ #
+*)
+ UNKNOWN_OPTION="${i#*=}"
+ echo "Error: unknown option: $UNKNOWN_OPTION"
+ help
+;;
+ esac
+done
+
+if [[ -z "${PLUGIN_VERSION}" ]]; then
+ echo "PLUGIN_VERSION must be passed"
+ exit 1
+fi
+
+echo "PLUGIN_VERSION = ${PLUGIN_VERSION}"
+
cd /root || exit 1
echo ""
-bro-pkg install code --force
+bro-pkg install code --version "${PLUGIN_VERSION}" --force
rc=$?; if [[ ${rc} != 0 ]]; then
echo "ERROR running bro-pkg install ${rc}"
exit ${rc}
diff --git a/docker/run_end_to_end.sh b/docker/run_end_to_end.sh
index 4c61560..3ec0145 100755
--- a/docker/run_end_to_end.sh
+++ b/docker/run_end_to_end.sh
@@ -29,6 +29,7 @@ function help {
echo "--skip-docker-build [OPTIONAL] Skip build of bro
docker machine."
echo "--data-path [OPTIONAL] The pcap data path.
Default: ./data"
echo "--kafka-topic [OPTIONAL] The kafka topic to
consume from. Default: bro"
+ echo "--plugin-version[OPTIONAL]