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>
This commit is contained in:
Hidde Beydals 2021-11-18 17:56:16 +01:00
parent dcd5dd3db1
commit c202ad59aa
3 changed files with 7 additions and 4 deletions

View File

@ -65,11 +65,12 @@ func NewLocalBuilder(dm *DependencyManager) Builder {
func (b *localChartBuilder) Build(ctx context.Context, ref Reference, p string, opts BuildOptions) (*Build, error) {
localRef, ok := ref.(LocalReference)
if !ok {
return nil, fmt.Errorf("expected local chart reference")
err := fmt.Errorf("expected local chart reference")
return nil, &BuildError{Reason: ErrChartReference, Err: err}
}
if err := ref.Validate(); err != nil {
return nil, &BuildError{Reason: ErrChartPull, Err: err}
return nil, &BuildError{Reason: ErrChartReference, Err: err}
}
// Load the chart metadata from the LocalReference to ensure it points

View File

@ -64,11 +64,12 @@ func NewRemoteBuilder(repository *repository.ChartRepository) Builder {
func (b *remoteChartBuilder) Build(_ context.Context, ref Reference, p string, opts BuildOptions) (*Build, error) {
remoteRef, ok := ref.(RemoteReference)
if !ok {
return nil, fmt.Errorf("expected remote chart reference")
err := fmt.Errorf("expected remote chart reference")
return nil, &BuildError{Reason: ErrChartReference, Err: err}
}
if err := ref.Validate(); err != nil {
return nil, &BuildError{Reason: ErrChartPull, Err: err}
return nil, &BuildError{Reason: ErrChartReference, Err: err}
}
if err := b.remote.LoadFromCache(); err != nil {

View File

@ -61,6 +61,7 @@ func (e *BuildError) Unwrap() error {
}
var (
ErrChartReference = BuildErrorReason("chart reference error")
ErrChartPull = BuildErrorReason("chart pull error")
ErrChartMetadataPatch = BuildErrorReason("chart metadata patch error")
ErrValuesFilesMerge = BuildErrorReason("values files merge error")