Skip to content

Commit

Permalink
Use wait syntax to check for storage class in cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Rodriguez committed Dec 19, 2023
1 parent 5a8e2a7 commit ca86c51
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
14 changes: 5 additions & 9 deletions packages/gitea/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,11 @@ components:
onDeploy:
before:
- description: Check that the cluster has a storage class
shell:
windows: pwsh
cmd: |
STORAGE_CLASSES=$(./zarf tools kubectl get StorageClass -o jsonpath='{.items[*].metadata.name}')
if [ -z "${STORAGE_CLASSES}" ]; then
echo "No storage class was found in the cluster."
echo "The Zarf git server requires a storage class in the cluster to function correctly."
exit 1
fi
maxTotalSeconds: 3
wait:
cluster:
kind: storageclass
name: "###ZARF_STORAGE_CLASS###" # TODO@lucasrod16: figure out why this doesn't work
after:
- cmd: ./zarf internal create-read-only-gitea-user --no-progress
maxRetries: 3
Expand Down
14 changes: 5 additions & 9 deletions packages/zarf-registry/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,11 @@ components:
onDeploy:
before:
- description: Check that the cluster has a storage class
shell:
windows: pwsh
cmd: |
STORAGE_CLASSES=$(./zarf tools kubectl get StorageClass -o jsonpath='{.items[*].metadata.name}')
if [ -z "${STORAGE_CLASSES}" ]; then
echo "No storage class was found in the cluster."
echo "The Zarf registry requires a storage class in the cluster to function correctly."
exit 1
fi
maxTotalSeconds: 3
wait:
cluster:
kind: storageclass
name: "###ZARF_STORAGE_CLASS###" # TODO@lucasrod16: figure out why this doesn't work

- name: zarf-registry
description: |
Expand Down
4 changes: 2 additions & 2 deletions src/test/e2e/20_zarf_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ func initWithoutStorageClass(t *testing.T, components string) {
_, _, err = e2e.Kubectl("delete", "storageclass", defaultStorageClassName)
require.NoError(t, err)

expectedErrorMessage := "No storage class was found in the cluster"
_, stdErr, err := e2e.Zarf("init", components, "--confirm")
require.Error(t, err, stdErr)
require.Contains(t, stdErr, expectedErrorMessage)
require.Contains(t, stdErr, "unable to deploy component")
require.Contains(t, stdErr, "Check that the cluster has a storage class")

_, _, err = e2e.Zarf("destroy", "--confirm")
require.NoError(t, err)
Expand Down

0 comments on commit ca86c51

Please sign in to comment.