From 5b7fd0c3f95c358ba99a73076f9e024bc27dd486 Mon Sep 17 00:00:00 2001 From: Lucas Rodriguez Date: Tue, 19 Dec 2023 11:19:12 -0600 Subject: [PATCH] Ensure state values are populated before running onDeploy before actions Update storage class check description Check for more complete string in stderr in e2e test --- packages/gitea/zarf.yaml | 2 +- packages/zarf-registry/zarf.yaml | 4 ++-- src/pkg/packager/deploy.go | 20 ++++++++++---------- src/test/e2e/20_zarf_init_test.go | 3 +-- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/gitea/zarf.yaml b/packages/gitea/zarf.yaml index 7dbb971749..7557151aa8 100644 --- a/packages/gitea/zarf.yaml +++ b/packages/gitea/zarf.yaml @@ -68,7 +68,7 @@ components: actions: onDeploy: before: - - description: Check that the cluster has a storage class + - description: Check that the cluster has the specified storage class maxTotalSeconds: 3 wait: cluster: diff --git a/packages/zarf-registry/zarf.yaml b/packages/zarf-registry/zarf.yaml index 5d3297124f..76ad571de3 100644 --- a/packages/zarf-registry/zarf.yaml +++ b/packages/zarf-registry/zarf.yaml @@ -114,12 +114,12 @@ components: actions: onDeploy: before: - - description: Check that the cluster has a storage class + - description: Check that the cluster has the specified storage class maxTotalSeconds: 3 wait: cluster: kind: storageclass - name: "${ZARF_STORAGE_CLASS}" # TODO@lucasrod16: figure out why this doesn't work + name: "${ZARF_STORAGE_CLASS}" - name: zarf-registry description: | diff --git a/src/pkg/packager/deploy.go b/src/pkg/packager/deploy.go index bbdf4eaf44..1e775bc55e 100644 --- a/src/pkg/packager/deploy.go +++ b/src/pkg/packager/deploy.go @@ -255,16 +255,6 @@ func (p *Packager) deployComponent(component types.ZarfComponent, noImgChecksum onDeploy := component.Actions.OnDeploy - if err = p.runActions(onDeploy.Defaults, onDeploy.Before, p.valueTemplate); err != nil { - return charts, fmt.Errorf("unable to run component before action: %w", err) - } - - if hasFiles { - if err := p.processComponentFiles(component, componentPath.Files); err != nil { - return charts, fmt.Errorf("unable to process the component files: %w", err) - } - } - if !p.valueTemplate.Ready() && requiresCluster(component) { // Setup the state in the config and get the valuesTemplate p.valueTemplate, err = p.setupStateValuesTemplate() @@ -282,6 +272,16 @@ func (p *Packager) deployComponent(component types.ZarfComponent, noImgChecksum } } + if err = p.runActions(onDeploy.Defaults, onDeploy.Before, p.valueTemplate); err != nil { + return charts, fmt.Errorf("unable to run component before action: %w", err) + } + + if hasFiles { + if err := p.processComponentFiles(component, componentPath.Files); err != nil { + return charts, fmt.Errorf("unable to process the component files: %w", err) + } + } + if hasImages { if err := p.pushImagesToRegistry(component.Images, noImgChecksum); err != nil { return charts, fmt.Errorf("unable to push images to the registry: %w", err) diff --git a/src/test/e2e/20_zarf_init_test.go b/src/test/e2e/20_zarf_init_test.go index 5cc3cde7f7..56682bffa6 100644 --- a/src/test/e2e/20_zarf_init_test.go +++ b/src/test/e2e/20_zarf_init_test.go @@ -162,8 +162,7 @@ func initWithoutStorageClass(t *testing.T, components string) { _, stdErr, err := e2e.Zarf("init", components, "--confirm") require.Error(t, err, stdErr) - require.Contains(t, stdErr, "unable to deploy component") - require.Contains(t, stdErr, "Check that the cluster has a storage class") + require.Contains(t, stdErr, "unable to run component before action: command \"Check that the cluster has the specified storage class\"") _, _, err = e2e.Zarf("destroy", "--confirm") require.NoError(t, err)