-
Notifications
You must be signed in to change notification settings - Fork 23
/
Makefile
63 lines (49 loc) · 2.44 KB
/
Makefile
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
#!make
KIND_VERSION ?= 0.8.1
# note: k8s version pinned since KIND image availability lags k8s releases
KUBERNETES_VERSION ?= v1.19.0
BATS_VERSION ?= 1.2.1
package-osm-chart:
helm dependency update osm-arc
install-prerequisites:
# Setup kind if TEST_KIND is set to true
if [ $(TEST_KIND) ]; then make setup-kind ; fi
# Install kubectl if not installed
kubectl version --short | grep -q $(KUBERNETES_VERSION) || (curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/linux/amd64/kubectl -o ${HOME}/bin/kubectl && chmod +x ${HOME}/bin/kubectl)
# Install helm if not installed
helm version --short | grep -q v3 || (curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash)
# Install bats if not installed
bats --version | grep -q $(BATS_VERSION) || (sudo apt-get -o Acquire::Retries=30 update && sudo apt-get -o Acquire::Retries=30 install -y bats)
.PHONY: setup-kind
setup-kind:
# Download and install kind if not installed
kind --version | grep -q $(KIND_VERSION) || (curl -L https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-linux-amd64 --output ${HOME}/bin/kind && chmod +x ${HOME}/bin/kind)
# Create kind cluster
kind delete cluster || true
kind create cluster --image kindest/node:$(KUBERNETES_VERSION)
e2e-bootstrap:
# Create namespaces to test openservicemesh.io/ignore label
# Create azure-arc ns only if it doesn't exist (eg: for non-arc clusters)
kubectl get ns | grep -q azure-arc || kubectl create namespace azure-arc
kubectl create namespace arc-osm-system
e2e-helm-deploy:
helm dependency update ./charts/osm-arc
helm install osm ./charts/osm-arc --namespace arc-osm-system --dependency-update
test-e2e:
bats -t test/bats/test.bats
e2e-cleanup:
helm uninstall osm -n arc-osm-system
kubectl delete namespace arc-osm-system
if [ $(TEST_KIND) ]; then kind delete cluster; fi
install-trivy:
wget https://github.com/aquasecurity/trivy/releases/download/v0.18.0/trivy_0.18.0_Linux-64bit.tar.gz
tar zxvf trivy_0.18.0_Linux-64bit.tar.gz
trivy-scan-image:
# Show all vulnerabilities in logs
./trivy "$(IMAGE_NAME):$(IMAGE_TAG)"
# Exit if medium, high, or critical vulnerability for OS vulnerabilities
./trivy --exit-code 1 --ignore-unfixed --vuln-type os --severity MEDIUM,HIGH,CRITICAL "$(IMAGE_NAME):$(IMAGE_TAG)" || exit 1
# Install shellcheck with: "sudo apt install shellcheck"
.PHONY: shellcheck
shellcheck:
shellcheck -x $(shell find . -name '*.sh')