Skip to content

Commit

Permalink
More changes after review
Browse files Browse the repository at this point in the history
Signed-off-by: Xavi Garcia <[email protected]>
  • Loading branch information
0xavi0 committed Feb 21, 2025
1 parent b8eb84c commit 2b6f20a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions internal/bundlereader/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func Open(ctx context.Context, name, baseDir, file string, opts *Options) (*flee

if file == "" {
if file, err := setupIOReader(baseDir); err != nil {
return nil, nil, fmt.Errorf("%s: %w", errorContext, err)
return nil, nil, fmt.Errorf("failed to open existing fleet.yaml in %q: %w", baseDir, err)
} else if file != nil {
in = file
defer file.Close()
Expand All @@ -72,15 +72,15 @@ func Open(ctx context.Context, name, baseDir, file string, opts *Options) (*flee
} else {
f, err := os.Open(filepath.Join(baseDir, file))
if err != nil {
return nil, nil, fmt.Errorf("%s: %w", errorContext, err)
return nil, nil, fmt.Errorf("failed to open file %q: %w", file, err)
}
defer f.Close()
in = f
}

b, s, err := mayCompress(ctx, name, baseDir, in, opts)
if err != nil {
return b, s, fmt.Errorf("%s: %w", errorContext, err)
return b, s, fmt.Errorf("failed to process bundle: %w", err)
}

return b, s, nil
Expand Down
10 changes: 5 additions & 5 deletions internal/bundlereader/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ func generateValues(base string, chart *fleet.HelmOptions) (valuesMap *fleet.Gen
for _, value := range chart.ValuesFiles {
valuesByte, err := os.ReadFile(base + "/" + value)
if err != nil {
return nil, fmt.Errorf("%s: %w", fmt.Sprintf("reading values file: %s/%s", base, value), err)
return nil, fmt.Errorf("reading values file: %s/%s: %w", base, value, err)
}
tmpDataOpt := &fleet.GenericMap{}
err = yaml.Unmarshal(valuesByte, tmpDataOpt)
if err != nil {
return nil, fmt.Errorf("%s: %w", fmt.Sprintf("reading values file: %s/%s", base, value), err)
return nil, fmt.Errorf("reading values file: %s/%s", base, value, err)
}
valuesMap = mergeGenericMap(valuesMap, tmpDataOpt)
}
Expand All @@ -154,15 +154,15 @@ func addRemoteCharts(directories []directory, base string, charts []*fleet.HelmO
if _, err := os.Stat(filepath.Join(base, chart.Chart)); os.IsNotExist(err) || chart.Repo != "" {
shouldAddAuthToRequest, err := shouldAddAuthToRequest(helmRepoURLRegex, chart.Repo, chart.Chart)
if err != nil {
return nil, fmt.Errorf("%s: %w", downloadChartError(*chart), err)
return nil, fmt.Errorf("failed to add auth to request for %s: %w", downloadChartError(*chart), err)
}
if !shouldAddAuthToRequest {
auth = Auth{}
}

chartURL, err := chartURL(*chart, auth)
if err != nil {
return nil, fmt.Errorf("%s: %w", downloadChartError(*chart), err)
return nil, fmt.Errorf("failed to resolve URL of %s: %w", downloadChartError(*chart), err)
}

directories = append(directories, directory{
Expand Down Expand Up @@ -225,7 +225,7 @@ func loadDirectories(ctx context.Context, compress bool, disableDepsUpdate bool,
defer sem.Release(1)
resources, err := loadDirectory(ctx, compress, disableDepsUpdate, dir.prefix, dir.base, dir.source, dir.version, dir.auth)
if err != nil {
return fmt.Errorf("%s: %w", fmt.Sprintf("loading directory %s, %s", dir.prefix, dir.base), err)
return fmt.Errorf("loading directory %s, %s: %w", dir.prefix, dir.base, err)
}

key := dir.key
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/cli/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func CreateBundles(ctx context.Context, client Getter, repoName string, baseDirs
opts := opts
createBundle, e := shouldCreateBundleForThisPath(baseDir, path, info)
if e != nil {
return fmt.Errorf("%s: %w", fmt.Sprintf("checking for bundle in path %s", path), err)
return fmt.Errorf("checking for bundle in path %q: %w", path, err)
}
if !createBundle {
return nil
Expand Down Expand Up @@ -180,7 +180,7 @@ func readBundle(ctx context.Context, name, baseDir string, opts *Options) (*flee
if opts.BundleReader != nil {
var bundle *fleet.Bundle
if err := json.NewDecoder(opts.BundleReader).Decode(bundle); err != nil {
return nil, nil, fmt.Errorf("%s: %w", fmt.Sprintf("decoding bundle %s", name), err)
return nil, nil, fmt.Errorf("decoding bundle %s: %w", name, err)
}
return bundle, nil, nil
}
Expand Down

0 comments on commit 2b6f20a

Please sign in to comment.