-
Notifications
You must be signed in to change notification settings - Fork 39
/
getDids.sh
128 lines (109 loc) · 4.48 KB
/
getDids.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
export MSYS_NO_PATHCONV=1
SCRIPT_HOME="$( cd "$( dirname "$0" )" && pwd )"
# =================================================================================================================
# Usage:
# -----------------------------------------------------------------------------------------------------------------
usage() {
cat <<-EOF
Tool to for getting did information from a cluster. This tool is specific to
projects using Hyperledger Indy and Aries.
Usage: ${0} command [options]
Commands:
dids [-f <filter>] [-d <cluster>] [--no-ledger-scan] [--hyperlink] [--no-clean]
- Get a list of dids for all the projects in a cluster.
Options:
-f <filter>: The keyword to filter the list on. For example SOVRIN_STAGINGNET to return only results from Sovrin StagingNet,
or a99fd4-prod to return only results from the a99fd4-prod namespace in OCP.
-d <cluster>: Defines the target cluster
--no-ledger-scan: Do not scan ledgers for the DID. This can be used to save some time if the informaiton about the DID from
the ledgers is not needed.
--hyperlink: Generate a hyperlink for the agent name. Turns the agent name into a clickable link when viewing the csv in excel.
Does not format well for console output.
--no-clean: Skip the cleanup of the von-network environment. Useful if you are planning mutiple runs.
Examples:
${0} dids
${0} dids -f SOVRIN
${0} dids -d api-silver-devops-gov-bc-ca:6443 -f SOVRIN
EOF
}
# =================================================================================================================
# Process the local command line arguments and pass everything else along.
# - The 'getopts' options string must start with ':' for this to work.
# -----------------------------------------------------------------------------------------------------------------
while [ ${OPTIND} -le $# ]; do
if getopts :-: FLAG; then
# echo ${FLAG}
# echo ${OPTARG}
case ${FLAG} in
# List of local options:
# Pass any switches ...
- ) switches+=" --${OPTARG}" ;;
# Pass unrecognized options ...
\?) pass+=" -${OPTARG}" ;;
esac
else
# Pass unrecognized arguments ...
pass+=" ${!OPTIND}"
let OPTIND++
fi
done
# Pass the unrecognized arguments along for further processing ...
shift $((OPTIND-1))
set -- "$@" $(echo -e "${pass}" | sed -e 's/^[[:space:]]*//')
# =================================================================================================================
# -----------------------------------------------------------------------------------------------------------------
# Define hook scripts:
# - These must be defined before the main settings script 'settings.sh' is loaded.
# -----------------------------------------------------------------------------------------------------------------
onRequiredOptionsExist() {
(
# No required options ...
return 0
)
}
onUsesCommandLineArguments() {
(
# This script is expecting command line arguments to be passed ...
return 0
)
}
# -----------------------------------------------------------------------------------------------------------------
# Initialization:
# -----------------------------------------------------------------------------------------------------------------
# Load the project settings and functions ...
_includeFile="ocFunctions.inc"
_getDidsInc="getDids.inc"
_settingsFile="settings.sh"
if [ ! -z $(type -p ${_includeFile}) ]; then
_includeFilePath=$(type -p ${_includeFile})
export OCTOOLSBIN=$(dirname ${_includeFilePath})
if [ -f ${OCTOOLSBIN}/${_settingsFile} ]; then
. ${OCTOOLSBIN}/${_settingsFile}
fi
if [ -f ${OCTOOLSBIN}/${_includeFile} ]; then
. ${OCTOOLSBIN}/${_includeFile}
fi
if [ -f ${OCTOOLSBIN}/${_getDidsInc} ]; then
. ${OCTOOLSBIN}/${_getDidsInc}
fi
else
_red='\033[0;31m'
_yellow='\033[1;33m'
_nc='\033[0m' # No Color
echo -e \\n"${_red}${_includeFile} could not be found on the path.${_nc}"
echo -e "${_yellow}Please ensure the openshift-developer-tools are installed on and registered on your path.${_nc}"
echo -e "${_yellow}https://github.com/BCDevOps/openshift-developer-tools${_nc}"
fi
# ==============================================================================
_cmd=$(toLower ${1-dids})
shift
case "${_cmd}" in
dids)
getDids ${@} ${switches}
;;
*)
echoWarning "Unrecognized command; ${_cmd}"
globalUsage
;;
esac