Skip to content
Snippets Groups Projects
Commit f9053fd6 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

2021-04-13 v1.1 add support for custom config

parent c943c9ba
Branches
No related tags found
No related merge requests found
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
# API CLIENT :: GET A CI FILE FROM PACKAGE SERVER # API CLIENT :: GET A CI FILE FROM PACKAGE SERVER
# #
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2021-03-31 v0.0 <axel.hahn@iml.unibe.ch> init # 2021-03-31 v1.0 <axel.hahn@iml.unibe.ch> init
# 2021-04-13 v1.1 <axel.hahn@iml.unibe.ch> add support for custom config
# ====================================================================== # ======================================================================
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
line="----------------------------------------------------------------------" line="----------------------------------------------------------------------"
bDebug=0 bDebug=0
customconfig=
. $0.cfg . $0.cfg
...@@ -33,6 +35,7 @@ SYNTAX: ...@@ -33,6 +35,7 @@ SYNTAX:
OPTIONS: OPTIONS:
-c CFGFILE load custom config file after defaults in $self.cfg
-d enable debug infos -d enable debug infos
-e PHASE phase; overrides env variable IMLCI_PHASE -e PHASE phase; overrides env variable IMLCI_PHASE
-f FILE filename to get (without path); overrides env variable IMLCI_FILE -f FILE filename to get (without path); overrides env variable IMLCI_FILE
...@@ -43,7 +46,9 @@ OPTIONS: ...@@ -43,7 +46,9 @@ OPTIONS:
-u URL URL of iml ci server without trailing /; overrides env variable IMLCI_URL -u URL URL of iml ci server without trailing /; overrides env variable IMLCI_URL
VALUES: VALUES:
CFGFILE custom config file. It is useful to handle files of different
projects on a server.
PHASE is a phase of the ci server; one of preview|stage|live PHASE is a phase of the ci server; one of preview|stage|live
FILE is a filename without path that was created by ci server. FILE is a filename without path that was created by ci server.
OUTFILE Output file. It can countain a path. If none is given the filename OUTFILE Output file. It can countain a path. If none is given the filename
...@@ -54,6 +59,7 @@ VALUES: ...@@ -54,6 +59,7 @@ VALUES:
ITEM type what to list; one of phases|projects|files ITEM type what to list; one of phases|projects|files
To list projects a phase must be set. To list projects a phase must be set.
To list files a phase and a project must be set. To list files a phase and a project must be set.
DEFAULTS: DEFAULTS:
You don't need to set all values by command line. Use a config to set defaults You don't need to set all values by command line. Use a config to set defaults
...@@ -166,8 +172,9 @@ if [ $# -lt 1 ]; then ...@@ -166,8 +172,9 @@ if [ $# -lt 1 ]; then
fi fi
while getopts "de:f:l:o:p:s:u:" option; do while getopts "c:de:f:l:o:p:s:u:" option; do
case ${option} in case ${option} in
c) customconfig="$OPTARG" ;;
d) bDebug=1 ;; d) bDebug=1 ;;
e) export IMLCI_PHASE=$OPTARG ;; e) export IMLCI_PHASE=$OPTARG ;;
f) export IMLCI_FILE=$OPTARG ;; f) export IMLCI_FILE=$OPTARG ;;
...@@ -203,20 +210,35 @@ while getopts "de:f:l:o:p:s:u:" option; do ...@@ -203,20 +210,35 @@ while getopts "de:f:l:o:p:s:u:" option; do
esac esac
done done
if [ ! -z "$customconfig" ]; then
if [ -r "$customconfig" ]; then
. "$customconfig" || exit 2
else
echo "ERROR: unable to read custom config [$customconfig]."
exit 2
fi
fi
test -z ${IMLCI_OUTFILE} && IMLCI_OUTFILE=$IMLCI_FILE test -z ${IMLCI_OUTFILE} && IMLCI_OUTFILE=$IMLCI_FILE
if [ $bDebug = 1 ]; then if [ $bDebug = 1 ]; then
pre=">>>>>> "
echo $line echo $line
echo echo
echo DEBUG INFOS echo DEBUG INFOS
echo echo
echo ----- defaults in $0.cfg echo "${pre} defaults in $0.cfg"
cat $0.cfg 2>/dev/null cat $0.cfg 2>/dev/null
echo echo
echo '----- Params (override default values)' if [ ! -z "$customconfig" ]; then
echo "${pre} custom config $customconfig"
cat "$customconfig"
echo
fi
echo "${pre} Params (override default values)"
echo $* echo $*
echo echo
echo ----- effective values echo "${pre} effective values"
echo "IMLCI_URL = $IMLCI_URL" echo "IMLCI_URL = $IMLCI_URL"
echo "IMLCI_PKG_SECRET = $IMLCI_PKG_SECRET" echo "IMLCI_PKG_SECRET = $IMLCI_PKG_SECRET"
echo "IMLCI_PROJECT = $IMLCI_PROJECT" echo "IMLCI_PROJECT = $IMLCI_PROJECT"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment