forked from sustainableis/step-kubectl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·176 lines (141 loc) · 4.53 KB
/
run.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
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
#!/bin/sh
main() {
display_version
if [ -z "$WERCKER_KUBECTL_COMMAND" ]; then
fail "wercker-kubectl: command argument cannot be empty"
fi
local cmd="$WERCKER_KUBECTL_COMMAND"
# Global args
local global_args
local raw_global_args="$WERCKER_KUBECTL_RAW_GLOBAL_ARGS"
# token
if [ -n "$WERCKER_KUBECTL_TOKEN" ]; then
global_args="$global_args --token=\"$WERCKER_KUBECTL_TOKEN\""
fi
# username
if [ -n "$WERCKER_KUBECTL_USERNAME" ]; then
global_args="$global_args --username=\"$WERCKER_KUBECTL_USERNAME\""
fi
# password
if [ -n "$WERCKER_KUBECTL_PASSWORD" ]; then
global_args="$global_args --password=\"$WERCKER_KUBECTL_PASSWORD\""
fi
# server
if [ -n "$WERCKER_KUBECTL_SERVER" ]; then
global_args="$global_args --server=\"$WERCKER_KUBECTL_SERVER\""
fi
# insecure-skip-tls-verify
if [ -n "$WERCKER_KUBECTL_INSECURE_SKIP_TLS_VERIFY" ]; then
global_args="$global_args --insecure-skip-tls-verify=\"$WERCKER_KUBECTL_INSECURE_SKIP_TLS_VERIFY\""
fi
# certificate-authority
if [ -n "$WERCKER_KUBECTL_CERTIFICATE_AUTHORITY" ]; then
global_args="$global_args --certificate-authority=\"$WERCKER_KUBECTL_CERTIFICATE_AUTHORITY\""
fi
# client-certificate
if [ -n "$WERCKER_KUBECTL_CLIENT_CERTIFICATE" ]; then
global_args="$global_args --client-certificate=\"$WERCKER_KUBECTL_CLIENT_CERTIFICATE\""
fi
# client-key
if [ -n "$WERCKER_KUBECTL_CLIENT_KEY" ]; then
global_args="$global_args --client-key=\"$WERCKER_KUBECTL_CLIENT_KEY\""
fi
# Command specific flags
local args
local raw_args="$WERCKER_KUBECTL_RAW_ARGS"
# file
if [ -n "$WERCKER_KUBECTL_FILE" ]; then
args="$args --file=\"$WERCKER_KUBECTL_FILE\""
fi
# output
if [ -n "$WERCKER_KUBECTL_OUTPUT" ]; then
args="$args --output=\"$WERCKER_KUBECTL_OUTPUT\""
fi
# template
if [ -n "$WERCKER_KUBECTL_TEMPLATE" ]; then
args="$args --template=\"$WERCKER_KUBECTL_TEMPLATE\""
fi
# patch
if [ -n "$WERCKER_KUBECTL_PATCH" ]; then
args="$args --patch=\"$WERCKER_KUBECTL_PATCH\""
fi
# interactive
if [ -n "$WERCKER_KUBECTL_INTERACTIVE" ]; then
args="$args --interactive=\"$WERCKER_KUBECTL_INTERACTIVE\""
fi
# image
if [ -n "$WERCKER_KUBECTL_IMAGE" ]; then
args="$args --image=\"$WERCKER_KUBECTL_IMAGE\""
fi
# timeout
if [ -n "$WERCKER_KUBECTL_TIMEOUT" ]; then
args="$args --timeout=\"$WERCKER_KUBECTL_TIMEOUT\""
fi
# update-period
if [ -n "$WERCKER_KUBECTL_UPDATE_PERIOD" ]; then
args="$args --update-period=\"$WERCKER_KUBECTL_UPDATE_PERIOD\""
fi
# deployment-label-key
if [ -n "$WERCKER_KUBECTL_DEPLOYMENT_LABEL_KEY" ]; then
args="$args --deployment-label-key=\"$WERCKER_KUBECTL_DEPLOYMENT_LABEL_KEY\""
fi
# poll-interval
if [ -n "$WERCKER_KUBECTL_POLL_INTERVAL" ]; then
args="$args --poll-interval=\"$WERCKER_KUBECTL_POLL_INTERVAL\""
fi
# rollback
if [ -n "$WERCKER_KUBECTL_ROLLBACK" ]; then
args="$args --rollback=\"$WERCKER_KUBECTL_ROLLBACK\""
fi
# replicas
if [ -n "$WERCKER_KUBECTL_REPLICAS" ]; then
args="$args --replicas=\"$WERCKER_KUBECTL_REPLICAS\""
fi
# current-replicas
if [ -n "$WERCKER_KUBECTL_CURRENT_REPLICAS" ]; then
args="$args --current-replicas=\"$WERCKER_KUBECTL_CURRENT_REPLICAS\""
fi
# resource-version
if [ -n "$WERCKER_KUBECTL_RESOURCE_VERSION" ]; then
args="$args --resource-version=\"$WERCKER_KUBECTL_RESOURCE_VERSION\""
fi
# pod
if [ -n "$WERCKER_KUBECTL_POD" ]; then
args="$args --pod=\"$WERCKER_KUBECTL_POD\""
fi
# stdin
if [ -n "$WERCKER_KUBECTL_STDIN" ]; then
args="$args --stdin=\"$WERCKER_KUBECTL_STDIN\""
fi
# tty
if [ -n "$WERCKER_KUBECTL_TTY" ]; then
args="$args --tty=\"$WERCKER_KUBECTL_TTY\""
fi
# grace-period
if [ -n "$WERCKER_KUBECTL_GRACE_PERIOD" ]; then
args="$args --grace-period=\"$WERCKER_KUBECTL_GRACE_PERIOD\""
fi
# selector
if [ -n "$WERCKER_KUBECTL_SELECTOR" ]; then
args="$args --selector=\"$WERCKER_KUBECTL_SELECTOR\""
fi
# all
if [ -n "$WERCKER_KUBECTL_ALL" ]; then
args="$args --all=\"$WERCKER_KUBECTL_ALL\""
fi
# overwrite
if [ -n "$WERCKER_KUBECTL_OVERWRITE" ]; then
args="$args --overwrite=\"$WERCKER_KUBECTL_OVERWRITE\""
fi
info "Running kubctl command"
if [ "$WERCKER_KUBECTL_DEBUG" = "true" ]; then
info "kubectl $global_args $raw_global_args $cmd $args $raw_args"
fi
eval "$WERCKER_STEP_ROOT"/kubectl "$global_args" "$raw_global_args" "$cmd" "$args" "$raw_args"
}
display_version() {
info "Running kubectl version:"
"$WERCKER_STEP_ROOT"/kubectl version --client
echo ""
}
main;