Skip to content

Commit

Permalink
Merge pull request #7972 from Rohitrajak1807/private/Rohitrajak1807/b…
Browse files Browse the repository at this point in the history
…ug-write-to-flag

🐛  bugfix write-to flag should only run filepath.Clean when the output file is not "" or -
  • Loading branch information
k8s-ci-robot authored Jan 23, 2023
2 parents aa511d8 + 0884032 commit 55634df
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/clusterctl/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ func printYamlOutput(printer client.YamlPrinter, outputFile string) error {
if err != nil {
return err
}
outputFile = filepath.Clean(strings.TrimSpace(outputFile))
yaml = append(yaml, '\n')
outputFile = strings.TrimSpace(outputFile)
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(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 55634df

Please sign in to comment.