Skip to content

Commit

Permalink
Fix the error return for building helm repositories (#1911)
Browse files Browse the repository at this point in the history
## Description

This fixes an issue with error returns when building the dependencies
for a Helm chart.

## Related Issue

Relates to #1875

## Type of change

- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Other (security config, docs update, etc)

## Checklist before merging

- [X] Test, docs, adr added or updated as needed
- [X] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow)
followed
  • Loading branch information
Racer159 authored Jul 27, 2023
1 parent 355235c commit b114cbf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/actions/save-logs/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ runs:
steps:
- name: Fix log permissions
run: |
sudo chown $USER /tmp/zarf-*.log
stat -t /tmp/zarf-*.log >/dev/null 2>&1 && sudo chown $USER /tmp/zarf-*.log
shell: bash

- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test-bigbang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,4 @@ jobs:
run: "go test ./src/extensions/bigbang/test -failfast -v -timeout 30m"

- name: Save logs
if: always() && ${{ env.IRONBANK_USERNAME != '' }}
env:
IRONBANK_USERNAME: ${{ secrets.IRONBANK_USERNAME }}
uses: ./.github/actions/save-logs
4 changes: 0 additions & 4 deletions .github/workflows/test-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ jobs:
# chown the logs since they were originally created as root
run: |
sudo env "PATH=$PATH" CI=true zarf init --components k3s,git-server,logging --confirm
sudo chown $USER /tmp/zarf-*.log
# Before we run the regular tests we need to aggressively cleanup files to reduce disk pressure
- name: Cleanup files
Expand All @@ -93,15 +92,13 @@ jobs:
sudo env "PATH=$PATH" CI=true zarf package deploy zarf-package-test-upgrade-package-amd64-6.3.3.tar.zst --confirm
sudo env "PATH=$PATH" CI=true zarf tools kubectl describe deployments -n=podinfo-upgrade
sudo env "PATH=$PATH" CI=true zarf tools kubectl describe pods -n=podinfo-upgrade
sudo chown $USER /tmp/zarf-*.log
- name: "Run the PR's tests"
# NOTE: "PATH=$PATH" preserves the default user $PATH. This is needed to maintain the version of go installed
# in a previous step. This test run will use this PR's Zarf to create a K3s cluster.
# chown the logs since they were originally created as root
run: |
sudo env "PATH=$PATH" CI=true APPLIANCE_MODE=true APPLIANCE_MODE_KEEP=true make test-e2e ARCH=amd64
sudo chown $USER /tmp/zarf-*.log
- name: "Describe nodes, pods and deployments"
# NOTE: We describe nodes, pods and deployments here to help understand failures
Expand All @@ -124,7 +121,6 @@ jobs:
zarf package create src/test/upgrade --set PODINFO_VERSION=6.3.4 --confirm
sudo env "PATH=$PATH" CI=true make test-upgrade ARCH=amd64
sudo chown $USER /tmp/zarf-*.log
- name: Save logs
if: always()
Expand Down
13 changes: 11 additions & 2 deletions src/internal/packager/helm/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ func (h *Helm) PackageChartFromLocalFiles(destination string) (string, error) {
spinner.Errorf(err, "Validation failed for chart from %s (%s)", h.Chart.LocalPath, err.Error())
return "", err
}
h.buildChartDependencies(spinner)

err = h.buildChartDependencies(spinner)
if err != nil {
spinner.Errorf(err, "Unable to build dependencies for the chart: %s", err.Error())
return "", err
}

client := action.NewPackage()

client.Destination = destination
Expand Down Expand Up @@ -206,7 +212,10 @@ func (h *Helm) buildChartDependencies(spinner *message.Spinner) error {
// Build the deps from the helm chart
err = man.Build()
if e, ok := err.(downloader.ErrRepoNotFound); ok {
return fmt.Errorf("%s. Please add the missing repos via 'helm repo add'", e.Error())
return fmt.Errorf("%s. Please add the missing repo via 'helm repo add <name> <url>'", e.Error())
} else if err != nil {
return err
}

return nil
}

0 comments on commit b114cbf

Please sign in to comment.