-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathadvisor-scan.sh
More file actions
executable file
·76 lines (60 loc) · 2.08 KB
/
advisor-scan.sh
File metadata and controls
executable file
·76 lines (60 loc) · 2.08 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
#!/usr/bin/env bash
# Copyright Alcide IO Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
alcide_download_advisor(){
echo "Downloading Alcide Advisor"
if [[ "$OSTYPE" == "linux-gnu" ]]; then
# Linux
local os="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
local os="darwin"
else
echo "Unsupported OS, Currently Alcide Advisor is supported on Linux or MacOS only"
exit
fi
curl -o kube-advisor https://alcide.blob.core.windows.net/generic/stable/$os/advisor
chmod +x kube-advisor
}
main() {
args=()
if [[ -n "${INPUT_FAIL_ON_CRITICAL:-}" ]]; then
args+=(--run-mode=pipeline)
fi
if [[ -n "${INPUT_OUTPUT_FILE:-}" ]]; then
args+=(--outfile "${INPUT_OUTPUT_FILE}")
fi
if [[ -n "${INPUT_INCLUDE_NAMESPACES:-}" ]]; then
args+=(--namespace-include "${INPUT_INCLUDE_NAMESPACES}")
fi
if [[ -n "${INPUT_EXCLUDE_NAMESPACES:-}" ]]; then
args+=(--namespace-exclude "${INPUT_EXCLUDE_NAMESPACES}")
fi
if [[ -n "${INPUT_POLICY_PROFILE:-}" ]]; then
args+=(--policy-profile "${INPUT_POLICY_PROFILE}")
fi
if [[ -n "${INPUT_POLICY_PROFILE_ID:-}" ]]; then
args+=(--profile-id "${INPUT_POLICY_PROFILE_ID}")
args+=(--alcide-api-key "${INPUT_ALCIDE_APIKEY}")
args+=(--alcide-api-server "${INPUT_ALCIDE_APISERVER}")
fi
# Download fresh scanner
alcide_download_advisor
# Scan the cluster
./kube-advisor --eula-sign validate cluster "${args[@]}"
}
main