Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --path flag when using wolfictl update #763

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pkg/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,9 @@ func (o *Options) updateGitPackage(ctx context.Context, repo *git.Repository, pa
root := worktree.Filesystem.Root()
log.Printf("working directory: %s", root)

configFile := filepath.Join(root, pc.Filename)
configFilepath := filepath.Join(o.PkgPath, pc.Filename)

configFile := filepath.Join(root, configFilepath)
if configFile == "" {
return "", fmt.Errorf("no config filename found for package %s", packageName)
}
Expand Down Expand Up @@ -416,7 +418,7 @@ func (o *Options) updateGitPackage(ctx context.Context, repo *git.Repository, pa
}

// now make sure update config is configured
updated, err := config.ParseConfiguration(ctx, filepath.Join(root, pc.Filename))
updated, err := config.ParseConfiguration(ctx, filepath.Join(root, configFilepath))
if err != nil {
return "", fmt.Errorf("failed to parse %v", err)
}
Expand All @@ -435,7 +437,7 @@ func (o *Options) updateGitPackage(ctx context.Context, repo *git.Repository, pa

// Skip any processing for definitions with a single pipeline
if len(updated.Pipeline) > 1 && deps.ContainsGoBumpPipeline(updated) {
if err := o.updateGoBumpDeps(updated, root, pc.Filename, mutations); err != nil {
if err := o.updateGoBumpDeps(updated, root, configFilepath, mutations); err != nil {
return fmt.Sprintf("error cleaning up go/bump deps: %v", err), nil
}
}
Expand All @@ -447,12 +449,12 @@ func (o *Options) updateGitPackage(ctx context.Context, repo *git.Repository, pa
o.Logger.Printf("after clean go bumps: %s git status: %s", packageName, string(rs))

// Run yam formatter
err = yam.FormatConfigurationFile(root, pc.Filename)
err = yam.FormatConfigurationFile(filepath.Join(root, o.PkgPath), pc.Filename)
if err != nil {
return fmt.Sprintf("failed to format configuration file: %v", err), nil
}

_, err = worktree.Add(pc.Filename)
_, err = worktree.Add(configFilepath)
if err != nil {
return "", fmt.Errorf("failed to git add %s: %w", configFile, err)
}
Expand Down