forked from developmentseed/eoapi-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheoapi-cli
More file actions
executable file
·202 lines (163 loc) · 4.33 KB
/
eoapi-cli
File metadata and controls
executable file
·202 lines (163 loc) · 4.33 KB
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
#!/usr/bin/env bash
# eoAPI CLI - Main Entry Point
# This script provides a unified interface to all eoAPI management commands
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPTS_DIR="${SCRIPT_DIR}/scripts"
source "${SCRIPTS_DIR}/lib/common.sh"
readonly VERSION="0.1.0"
readonly COMMANDS=(
"cluster"
"deployment"
"test"
"load"
"ingest"
"docs"
)
show_help() {
cat <<EOF
eoAPI CLI v${VERSION}
Unified command-line interface for managing eoAPI deployments on Kubernetes
USAGE:
eoapi-cli [OPTIONS] <COMMAND> [ARGS]
OPTIONS:
-h, --help Show this help message
-v, --version Show version information
--debug Enable debug output
COMMANDS:
cluster Manage local Kubernetes clusters for development
deployment Deploy and manage eoAPI instances
test Run tests (helm, integration, autoscaling)
load Run load testing scenarios
ingest Load sample data into eoAPI services
docs Generate and serve documentation
Use 'eoapi-cli <COMMAND> --help' for more information about a specific command.
EXAMPLES:
# Set up a local development cluster
eoapi-cli cluster start
# Deploy eoAPI to the cluster
eoapi-cli deployment install
# Run all tests
eoapi-cli test all
# Run integration tests only
eoapi-cli test integration
# Run load tests
eoapi-cli load all
# Run autoscaling load tests only
eoapi-cli load autoscaling
# Ingest sample data
eoapi-cli ingest sample-data
# Serve documentation locally
eoapi-cli docs serve
For more information, visit: https://github.com/developmentseed/eoapi-k8s
EOF
}
show_version() {
echo "eoAPI CLI v${VERSION}"
echo "Copyright (c) Development Seed"
}
validate_command() {
local cmd="$1"
for valid_cmd in "${COMMANDS[@]}"; do
if [[ "$cmd" == "$valid_cmd" ]]; then
return 0
fi
done
return 1
}
get_command_script() {
local cmd="$1"
case "$cmd" in
cluster)
echo "${SCRIPTS_DIR}/cluster.sh"
;;
deployment)
echo "${SCRIPTS_DIR}/deployment.sh"
;;
test)
echo "${SCRIPTS_DIR}/test.sh"
;;
load)
echo "${SCRIPTS_DIR}/load.sh"
;;
ingest)
echo "${SCRIPTS_DIR}/ingest.sh"
;;
docs)
echo "${SCRIPTS_DIR}/docs.sh"
;;
*)
return 1
;;
esac
}
execute_command() {
local cmd="$1"
shift
local script_path
script_path=$(get_command_script "$cmd")
if [[ ! -f "$script_path" ]]; then
log_error "Command script not found: $script_path"
log_info "The '$cmd' command may not be implemented yet."
exit 1
fi
if [[ ! -x "$script_path" ]]; then
log_warn "Making script executable: $script_path"
chmod +x "$script_path"
fi
# Execute the command script with remaining arguments
exec "$script_path" "$@"
}
main() {
# Handle no arguments
if [[ $# -eq 0 ]]; then
show_help
exit 0
fi
# Parse global options
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
show_help
exit 0
;;
-v|--version)
show_version
exit 0
;;
--debug)
export DEBUG_MODE=true
shift
;;
-*)
log_error "Unknown option: $1"
echo "Run 'eoapi-cli --help' for usage information"
exit 1
;;
*)
# This should be the command
break
;;
esac
done
if [[ $# -eq 0 ]]; then
log_error "No command specified"
echo "Run 'eoapi-cli --help' for usage information"
exit 1
fi
local command="$1"
shift
if ! validate_command "$command"; then
log_error "Invalid command: $command"
echo ""
echo "Available commands:"
for cmd in "${COMMANDS[@]}"; do
echo " - $cmd"
done
echo ""
echo "Run 'eoapi-cli --help' for usage information"
exit 1
fi
execute_command "$command" "$@"
}
main "$@"