Skip to content

Commit 847a240

Browse files
committed
chore: add a script to simplify setting up local testing
1 parent fe485bd commit 847a240

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"author": "snyk.io",
1111
"main": "dist/index.js",
1212
"scripts": {
13+
"local": "./scripts/local-testing.sh",
1314
"pretest": "./scripts/docker/build-image.sh",
1415
"test": "npm run lint && npm run build && npm run test:unit:tap && npm run test:unit:jest && npm run test:integration:kind:helm",
1516
"test:unit:tap": "NODE_ENV=test tap test/unit/*.test.ts test/unit/**/*.test.ts --timeout=300",

scripts/local-testing.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#! /bin/bash
2+
3+
get_latest_release() {
4+
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
5+
grep '"tag_name":' | # Get tag line
6+
sed -E 's/.*"([^"]+)".*/\1/' | # Pluck JSON value
7+
sed 's/v//' # Remove "v" prefix
8+
}
9+
10+
LATEST_TAG=$(get_latest_release snyk/kubernetes-monitor)
11+
IP=$(ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk 'NR==1{print $2}')
12+
13+
if [ "$INTEGRATION_ID" == "" ]; then
14+
echo "Enter your integration ID: "
15+
read INTEGRATION_ID
16+
fi
17+
18+
kind delete cluster
19+
kind create cluster
20+
kubectl create namespace snyk-monitor
21+
kubectl create secret generic snyk-monitor -n snyk-monitor --from-literal=dockercfg.json={} --from-literal=integrationId=${INTEGRATION_ID}
22+
helm upgrade --install snyk-monitor ./snyk-monitor --namespace snyk-monitor --set clusterName="kind localhost" --set image.tag=${LATEST_TAG} --set integrationApi=http://${IP}:9000
23+
24+
printf "\r\n\r\nYou can now check if the pod is running using:\r\n\tkubectl get pod -n snyk-monitor\r\n"

0 commit comments

Comments
 (0)