Skip to content

Commit

Permalink
bugfix write-to flag only runs filepath.Clean when the output file is…
Browse files Browse the repository at this point in the history
… not "" or -
  • Loading branch information
Rohitrajak1807 committed Jan 23, 2023
1 parent 3b39d4a commit 46aa2fe
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions cmd/clusterctl/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ func printYamlOutput(printer client.YamlPrinter, outputFile string) error {
if err != nil {
return err
}
outputFile = filepath.Clean(strings.TrimSpace(outputFile))
yaml = append(yaml, '\n')
if outputFile == "" || outputFile == "-" {
if _, err := os.Stdout.Write(yaml); err != nil {
return errors.Wrap(err, "failed to write yaml to Stdout")
}
return nil
}

outputFile = filepath.Clean(strings.TrimSpace(outputFile))
if err := os.WriteFile(outputFile, yaml, 0600); err != nil {
return errors.Wrap(err, "failed to write to destination file")
}
Expand Down

0 comments on commit 46aa2fe

Please sign in to comment.