Skip to content

Commit

Permalink
Ensure state values are populated before running onDeploy before actions
Browse files Browse the repository at this point in the history
Update storage class check description
Check for more complete string in stderr in e2e test
  • Loading branch information
Lucas Rodriguez committed Dec 19, 2023
1 parent cfd7d8a commit 5b7fd0c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/gitea/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions packages/zarf-registry/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
20 changes: 10 additions & 10 deletions src/pkg/packager/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/test/e2e/20_zarf_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5b7fd0c

Please sign in to comment.