-
Notifications
You must be signed in to change notification settings - Fork 0
/
env-bak
executable file
·218 lines (194 loc) · 6.84 KB
/
env-bak
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/usr/bin/env bash
function prompt_create_exchange_db() {
# inputExchangeName="Custom"
# echo "Exchange Name:"
# read -r inputExchangeName
# while true; do
# echo "The exchange is decentralized in a blockchain?"
# read -r inputExchangeCentralized
# case $inputExchangeCentralized in
# [Yy]* ) echo "You choose yes."; break;;
# [Nn]* ) echo "You choose no.";;
# * ) echo "Please answer yes or no.";;
# esac
# done
# echo "$inputExchangeCentralized"
# while true; do
# echo "The exchange is a bridge?"
# read -r inputExchangeBridge
# case $inputExchangeBridge in
# [Yy]* ) echo "You choose yes."; break;;
# [Nn]* ) echo "You choose no.";;
# * ) echo "Please answer yes or no.";;
# esac
# done
# echo "$inputExchangeBridge"
# minikube -p "${MINIKUBE_PROFILE}" kubectl -- \
# exec deployment/postgres -- \
# psql -v ON_ERROR_STOP=on -U postgres \
# -c "INSERT INTO exchange (
# exchange_id,
# name,
# centralized,
# bridge,
# contract,
# blockchain,
# rest_api,
# ws_api,
# pairs_api,
# watchdog_delay,
# scraper_active
# ) VALUES(
# gen_random_uuid(),
# 'Custom',
# true,
# false,
# '',
# '',
# '',
# 'wss://ws-feed.pro.coinbase.com',
# 'https://api.pro.coinbase.com/products',
# 300,
# true
# )
# ;" >/dev/null 2>&1 \
# && echo "Success" \
# || echo "Error, a exchange with the name $inputExchangeName already exists." >&2
# set +e
# psqlExitCode=$?
# if [ $psqlExitCode -ne 0 ]; then
# echo "Error, a exchange with the name $inputExchangeName already exists."
# else
# echo "Success"
# fi
echo wip
}
function install(){
# docker login "${data_docker_registry}" --username="${data_docker_username}" --password="${data_docker_password}"
# minikube -p "${minikube_profile}" kubectl -- \
# create secret generic regcred-read \
# --from-file=.dockerconfigjson="${HOME}/.docker/config.json" \
# --type=kubernetes.io/dockerconfigjson
echo WIP
}
function start() {
# TODO: Installing DIA Helm chart
minikube -p "${MINIKUBE_PROFILE}" kubectl get namespace | grep -q "^dia " || kubectl create namespace "dia"
helm repo update
helm upgrade "dia-release" --namespace "dia-system" --create-namespace --install \
--set "exchangescrapers.namespaces={default,dia}" "./deployments/helm/dia"
}
function monitor-start() {
minikube -p "${MINIKUBE_PROFILE}" kubectl -- create namespace dia-monitoring
minikube -p "${MINIKUBE_PROFILE}" kubectl -- create namespace logging
# Install grafana dashboards
# TODO: provisioning datasources and dashboards
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm upgrade --namespace=dia-monitoring --install grafana grafana/grafana
minikube -p "${MINIKUBE_PROFILE}" kubectl -- \
expose --namespace=dia-monitoring service grafana --type=NodePort --target-port=3000 --name=grafana-np
minikube -p "${MINIKUBE_PROFILE}" kubectl -- \
get secret --namespace=dia-monitoring grafana \
-o jsonpath="{.data.admin-password}" | base64 --decode ; echo
minikube -p "${MINIKUBE_PROFILE}" service grafana-np --url
# TODO: Installing Loki daemon
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm upgrade --namespace=logging --install loki grafana/loki
}
function monitor-stop() {
# Stop and un-install grafana
minikube -p "${MINIKUBE_PROFILE}" kubectl -- delete svc --namespace=dia-monitoring grafana-np || true
helm delete grafana || true
# Stop and un-install Loki
minikube -p "${MINIKUBE_PROFILE}" kubectl -- delete svc --namespace=dia-monitoring loki || true
helm delete loki || true
# Clean Helm repos
helm repo remove grafana || true
helm repo update
# Delete remaining resources
minikube -p "${MINIKUBE_PROFILE}" kubectl -- delete namespace dia-monitoring || true
minikube -p "${MINIKUBE_PROFILE}" kubectl -- delete namespace logging || true
}
function usage() {
echo "HELP"
}
function main() {
local full_mode=false
local single_mode=false
local verbose_mode=false
local paths=()
local args=
args=$(
getopt -o hnsvp: \
--long parameter:,disk-space:,nodetached,full,single,verbose,help \
-n 'env' -- "$@"
)
local version_detected=$(git describe --tags --abbrev=0)
# shellcheck disable=SC2181
if [ $? != 0 ]; then
usage 1>&2
return 1
fi
set -euo pipefail
eval set -- "$args"
while true; do
case "$1" in
--verbose | -v)
verbose_mode=true
shift ;;
--single)
single_mode=true
shift ;;
--full | -f)
full_mode=true
shift ;;
--help | -h ) usage; return 0 ;;
-- ) shift; break ;;
* ) break ;;
esac
done
# expand paths after parsing
paths=("$@")
echo "${#paths[@]}"
echo "${paths[@]}"
echo "${paths:-.}"
echo "${paths[0]}"
echo "${paths[1]}"
if ! hash helm 2> /dev/null; then echo "Helm not found" >&2; return 1; fi
if ! hash jq 2> /dev/null; then echo "jq not found" >&2; return 1; fi
if ! hash yq 2> /dev/null; then echo "yq not found" >&2; return 1; fi
if ! hash golangci-lint 2> /dev/null; then echo "golangci-lint not found" >&2; return 1; fi
MINIKUBE_CERT_MOUNT=~/.minikube
KUBECONFIG=~/.kube/config
# code-lint)
# if [ "${#paths[@]}" -eq 1 ]; then
# if ! hash golangci-lint 2> /dev/null; then echo "golangci-lint not found" >&2; return 1; fi
# echo "Running linter ..."
# golangci-lint run --config=./.golangci.yml --out-format=tab
# else
# echo "Unknown command" >&2
# exit 1
# fi
# ;;
# code-test)
# if [ "${#paths[@]}" -eq 1 ]; then
# echo "Running tests ..."
# gotestsum --format pkgname
# else
# echo "Unknown command" >&2
# exit 1
# fi
# ;;
# code-build)
# if [ "${#paths[@]}" -eq 1 ]; then
# echo "Building codebase ..."
# go build -v ./...
# else
# echo "Unknown command" >&2
# exit 1
# fi
# ;;
}
main @