Skip to content

Commit c202ad5

Browse files
committed
helm/internal: add ErrChartReference
This makes it possible to signal reference (validation) errors happening before the build process actually starts dealing with the chart. At present, this does not have a more specific counterpart in the API, but this is expected to change when the conditions logic is revised. Signed-off-by: Hidde Beydals <hello@hidde.co>
1 parent dcd5dd3 commit c202ad5

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

internal/helm/chart/builder_local.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ func NewLocalBuilder(dm *DependencyManager) Builder {
6565
func (b *localChartBuilder) Build(ctx context.Context, ref Reference, p string, opts BuildOptions) (*Build, error) {
6666
localRef, ok := ref.(LocalReference)
6767
if !ok {
68-
return nil, fmt.Errorf("expected local chart reference")
68+
err := fmt.Errorf("expected local chart reference")
69+
return nil, &BuildError{Reason: ErrChartReference, Err: err}
6970
}
7071

7172
if err := ref.Validate(); err != nil {
72-
return nil, &BuildError{Reason: ErrChartPull, Err: err}
73+
return nil, &BuildError{Reason: ErrChartReference, Err: err}
7374
}
7475

7576
// Load the chart metadata from the LocalReference to ensure it points

internal/helm/chart/builder_remote.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ func NewRemoteBuilder(repository *repository.ChartRepository) Builder {
6464
func (b *remoteChartBuilder) Build(_ context.Context, ref Reference, p string, opts BuildOptions) (*Build, error) {
6565
remoteRef, ok := ref.(RemoteReference)
6666
if !ok {
67-
return nil, fmt.Errorf("expected remote chart reference")
67+
err := fmt.Errorf("expected remote chart reference")
68+
return nil, &BuildError{Reason: ErrChartReference, Err: err}
6869
}
6970

7071
if err := ref.Validate(); err != nil {
71-
return nil, &BuildError{Reason: ErrChartPull, Err: err}
72+
return nil, &BuildError{Reason: ErrChartReference, Err: err}
7273
}
7374

7475
if err := b.remote.LoadFromCache(); err != nil {

internal/helm/chart/errors.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func (e *BuildError) Unwrap() error {
6161
}
6262

6363
var (
64+
ErrChartReference = BuildErrorReason("chart reference error")
6465
ErrChartPull = BuildErrorReason("chart pull error")
6566
ErrChartMetadataPatch = BuildErrorReason("chart metadata patch error")
6667
ErrValuesFilesMerge = BuildErrorReason("values files merge error")

0 commit comments

Comments
 (0)