Skip to content

Commit 02303d3

Browse files
authored
Add shellcheck github action; fix init-env (#109)
1 parent 6b40aa2 commit 02303d3

32 files changed

+151
-137
lines changed

.github/workflows/local-test-infra.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ defaults:
55
shell: bash
66

77
jobs:
8+
shellcheck:
9+
name: Shellcheck
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Run ShellCheck
14+
uses: ludeeus/action-shellcheck@master
15+
with:
16+
scandir: './scripts'
17+
severity: error
818
test-local-test-infra:
919
name: 'Test the `local-test-infra` configuration on k8s cluster'
1020
runs-on: ubuntu-20.04

.github/workflows/pre-main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,13 @@ jobs:
2828
level: warning
2929
braces:
3030
level: warning
31+
shellcheck:
32+
name: Shellcheck
33+
runs-on: ubuntu-20.04
34+
steps:
35+
- uses: actions/checkout@v2
36+
- name: Run ShellCheck
37+
uses: ludeeus/action-shellcheck@master
38+
with:
39+
scandir: './scripts'
40+
severity: error

scripts/clean-all.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
# Initialization
44
SCRIPT_DIR=$(dirname "$0")
5-
source $SCRIPT_DIR/init-env.sh
5+
source "$SCRIPT_DIR"/init-env.sh
66

77
# Delete debug pods
8-
./$SCRIPT_DIR/delete-debug-ds.sh
8+
./"$SCRIPT_DIR"/delete-debug-ds.sh
99

1010
# Delete namespace
11-
oc delete namespace ${TNF_EXAMPLE_CNF_NAMESPACE}
11+
oc delete namespace "${TNF_EXAMPLE_CNF_NAMESPACE}"
1212

1313
# Delete test CRDs
14-
$SCRIPT_DIR/delete-test-crds.sh
14+
"$SCRIPT_DIR"/delete-test-crds.sh

scripts/clean.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
# Initialization
44
SCRIPT_DIR=$(dirname "$0")
5-
source $SCRIPT_DIR/init-env.sh
5+
source "$SCRIPT_DIR"/init-env.sh
66

77
# Delete tnf, partner and operator and litmus
8-
./$SCRIPT_DIR/delete-partner-pods.sh
9-
./$SCRIPT_DIR/delete-test-pods.sh
10-
./$SCRIPT_DIR/delete-hpa.sh
11-
./$SCRIPT_DIR/delete-test-crds.sh
12-
./$SCRIPT_DIR/delete-debug-ds.sh
13-
./$SCRIPT_DIR/delete-statefulset-pods.sh
14-
./$SCRIPT_DIR/delete-community-operator.sh
15-
./$SCRIPT_DIR/delete-litmus-operator.sh
8+
./"$SCRIPT_DIR"/delete-partner-pods.sh
9+
./"$SCRIPT_DIR"/delete-test-pods.sh
10+
./"$SCRIPT_DIR"/delete-hpa.sh
11+
./"$SCRIPT_DIR"/delete-test-crds.sh
12+
./"$SCRIPT_DIR"/delete-debug-ds.sh
13+
./"$SCRIPT_DIR"/delete-statefulset-pods.sh
14+
./"$SCRIPT_DIR"/delete-community-operator.sh
15+
./"$SCRIPT_DIR"/delete-litmus-operator.sh

scripts/configure-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Initialization
44
SCRIPT_DIR=$(dirname "$0")
5-
source $SCRIPT_DIR/init-env.sh
5+
source "$SCRIPT_DIR"/init-env.sh
66

77
# update docker config
88
sudo bash -c 'cat <<- EOF > /etc/docker/daemon.json

scripts/create-local-registry.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# TODO: needs refactoring to work with kind
33
# Initialization
44
SCRIPT_DIR=$(dirname "$0")
5-
source $SCRIPT_DIR/init-env.sh
5+
source "$SCRIPT_DIR"/init-env.sh
66

77
#setting sudo
88
sudo echo "setting sudo root"
@@ -30,22 +30,22 @@ else
3030
fi
3131

3232
# Create certificates for registry authentication
33-
rm -rf $SCRIPT_DIR/certs
34-
mkdir $SCRIPT_DIR/certs
35-
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout $SCRIPT_DIR/certs/registry.key -out $SCRIPT_DIR/certs/registry.crt -subj "/CN=registry" -addext "subjectAltName=DNS:${REGISTRY_NAME},IP:127.0.0.1"
36-
openssl x509 -in $SCRIPT_DIR/certs/registry.crt -out $SCRIPT_DIR/certs/registry.pem -outform PEM
37-
chmod 666 $SCRIPT_DIR/certs/*
33+
rm -rf "$SCRIPT_DIR"/certs
34+
mkdir "$SCRIPT_DIR"/certs
35+
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout "$SCRIPT_DIR"/certs/registry.key -out "$SCRIPT_DIR"/certs/registry.crt -subj "/CN=registry" -addext "subjectAltName=DNS:${REGISTRY_NAME},IP:127.0.0.1"
36+
openssl x509 -in "$SCRIPT_DIR"/certs/registry.crt -out "$SCRIPT_DIR"/certs/registry.pem -outform PEM
37+
chmod 666 "$SCRIPT_DIR"/certs/*
3838

3939
# Enable the new certificates for use in the current host
40-
sudo cp $SCRIPT_DIR/certs/registry.crt $CERT_PATH
40+
sudo cp "$SCRIPT_DIR"/certs/registry.crt "$CERT_PATH"
4141
sudo $CERT_UPDATER
4242

4343

4444
# Add the hostname to /etc/hosts
4545
if [ -z $( grep "$REGISTRY_NAME" /etc/hosts) ]
4646
then
4747
REGISTRY_ADDRESS=$(hostname -I|awk '{print $1}')
48-
echo REGISTRY_ADDRESS= $REGISTRY_ADDRESS
48+
echo REGISTRY_ADDRESS= "$REGISTRY_ADDRESS"
4949
sudo REGISTRY_ADDRESS1="$REGISTRY_ADDRESS" REGISTRY1="$REGISTRY_NAME" sh -c 'echo "$REGISTRY_ADDRESS1 $REGISTRY1" >> /etc/hosts'
5050
else
5151
echo "entry already present"
@@ -57,25 +57,25 @@ cat /etc/hosts
5757
${CONTAINER_CLIENT} rm -f registry
5858

5959
# Copy the certificate to the minikube directory for use by minikube
60-
mkdir -p $HOME/.minikube/certs
61-
cp $SCRIPT_DIR/certs/registry.pem $HOME/.minikube/certs/.
60+
mkdir -p "$HOME"/.minikube/certs
61+
cp "$SCRIPT_DIR"/certs/registry.pem "$HOME"/.minikube/certs/.
6262

6363
# Remove the docker registry
6464
${CONTAINER_CLIENT} rm -f registry
6565

6666
# Create the docker registry
6767
${CONTAINER_CLIENT} run -d \Linux
68-
-v $(pwd)/$SCRIPT_DIR/certs:/certs:Z \
68+
-v $(pwd)/"$SCRIPT_DIR"/certs:/certs:Z \
6969
-e REGISTRY_HTTP_ADDR=0.0.0.0:443 \
7070
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/registry.crt \
7171
-e REGISTRY_HTTP_TLS_KEY=/certs/registry.key \
7272
-p 443:443 \
7373
registry:2
7474

7575
# Restart docker
76-
if [ ${CONTAINER_CLIENT}="docker" ];
76+
if [ "${CONTAINER_CLIENT}" = "docker" ];
7777
then
7878
sudo systemctl restart docker
7979
fi
8080

81-
echo "Created local registry at: ${REGISTRY_NAME}:443"
81+
echo "Created local registry at: ${REGISTRY_NAME}:443"

scripts/create-operator-bundle.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
# Initialization
44
SCRIPT_DIR=$(dirname "$0")
5-
source $SCRIPT_DIR/init-env.sh
5+
source "$SCRIPT_DIR"/init-env.sh
66

77
# Login to the registry
88
docker login quay.io/testnetworkfunction
99

1010
# create the test operator
1111
rm -rf nginx-operator
1212
mkdir nginx-operator
13-
cd nginx-operator
14-
operator-sdk init --domain $REGISTRY_NAME --plugins helm
13+
cd nginx-operator || exit
14+
operator-sdk init --domain "$REGISTRY_NAME" --plugins helm
1515

1616
# Create a simple nginx API using Helm’s built-in chart boilerplate (from helm create):
1717
operator-sdk create api --group cnftest --version v0 --kind Nginx
@@ -20,7 +20,7 @@ operator-sdk create api --group cnftest --version v0 --kind Nginx
2020
${CONTAINER_CLIENT} logs registry
2121

2222
# Build and push the operator image.
23-
make docker-build docker-push IMG=$OPERATOR_IMAGE_FULL_NAME
23+
make docker-build docker-push IMG="$OPERATOR_IMAGE_FULL_NAME"
2424

2525
# Configure the operator manifest
2626
mkdir -p config/manifests/bases
@@ -74,9 +74,9 @@ spec:
7474
EOF
7575

7676
# Make and push the operator bundle
77-
make bundle IMG=$OPERATOR_IMAGE_FULL_NAME
77+
make bundle IMG="$OPERATOR_IMAGE_FULL_NAME"
7878
IMAGE_TAG_BASE=$REGISTRY$DIRECTORY$OPERATOR_BUNDLE_BASE_IMAGE make bundle-build bundle-push
7979

8080
# cleanup
8181
cd ..
82-
rm -rf nginx-operator
82+
rm -rf nginx-operator

scripts/create-redhat-registry-secrets.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
# Initialization
44
SCRIPT_DIR=$(dirname "$0")
5-
source $SCRIPT_DIR/init-env.sh
5+
source "$SCRIPT_DIR"/init-env.sh
66

77
oc create secret docker-registry redhat-registry-secret \
88
--docker-server=registry.redhat.io \
9-
--docker-username=$LOGIN_REGISTRY \
10-
--docker-password=$PASSWORD_REGISTRY \
11-
[email protected] -n $TNF_EXAMPLE_CNF_NAMESPACE
9+
--docker-username="$LOGIN_REGISTRY" \
10+
--docker-password="$PASSWORD_REGISTRY" \
11+
[email protected] -n "$TNF_EXAMPLE_CNF_NAMESPACE"
1212

1313
oc create secret docker-registry redhat-connect-registry-secret \
1414
--docker-server=registry.connect.redhat.com \
15-
--docker-username=$LOGIN_REGISTRY \
16-
--docker-password=$PASSWORD_REGISTRY \
17-
[email protected] -n $TNF_EXAMPLE_CNF_NAMESPACE
15+
--docker-username="$LOGIN_REGISTRY" \
16+
--docker-password="$PASSWORD_REGISTRY" \
17+
[email protected] -n "$TNF_EXAMPLE_CNF_NAMESPACE"

scripts/create-secret.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22

33
# Initialization
44
SCRIPT_DIR=$(dirname "$0")
5-
source $SCRIPT_DIR/init-env.sh
5+
source "$SCRIPT_DIR"/init-env.sh
66

77
#check pem file exists, create a secret with it if present
8-
if [[ -n "$(ls $SCRIPT_DIR/certs/registry.pem 2>/dev/null)" ]]; then
8+
if [[ -n "$(ls "$SCRIPT_DIR"/certs/registry.pem 2>/dev/null)" ]]; then
99
echo "pem file found, create secret from pem file"
10-
cp $SCRIPT_DIR/certs/registry.pem $SCRIPT_DIR/certs/cert.pem
11-
oc delete secret $SECRET_NAME -n $TNF_EXAMPLE_CNF_NAMESPACE
12-
oc create secret generic $SECRET_NAME --from-file=$SCRIPT_DIR/certs/cert.pem -n $TNF_EXAMPLE_CNF_NAMESPACE
10+
cp "$SCRIPT_DIR"/certs/registry.pem "$SCRIPT_DIR"/certs/cert.pem
11+
oc delete secret "$SECRET_NAME" -n "$TNF_EXAMPLE_CNF_NAMESPACE"
12+
oc create secret generic "$SECRET_NAME" --from-file="$SCRIPT_DIR"/certs/cert.pem -n "$TNF_EXAMPLE_CNF_NAMESPACE"
1313
else
1414
echo "No pem file present, skipping secret creation"
1515
fi
16-
17-
18-

scripts/delete-community-operator.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
# Initialization
44
SCRIPT_DIR=$(dirname "$0")
5-
source $SCRIPT_DIR/init-env.sh
5+
source "$SCRIPT_DIR"/init-env.sh
66

77
# delete CSV
8-
oc delete csv $COMMUNITY_OPERATOR_NAME -n $TNF_EXAMPLE_CNF_NAMESPACE
8+
oc delete csv "$COMMUNITY_OPERATOR_NAME" -n "$TNF_EXAMPLE_CNF_NAMESPACE"
99

1010
# delete operator group
11-
oc delete operatorgroups test-group -n $TNF_EXAMPLE_CNF_NAMESPACE
11+
oc delete operatorgroups test-group -n "$TNF_EXAMPLE_CNF_NAMESPACE"
1212

1313
# delete subscription
14-
oc delete subscriptions test-subscription -n $TNF_EXAMPLE_CNF_NAMESPACE
14+
oc delete subscriptions test-subscription -n "$TNF_EXAMPLE_CNF_NAMESPACE"

0 commit comments

Comments
 (0)