Use consistent slashes whether expanded on Windows or POSIX

Signed-off-by: Evan Anderson <evan.k.anderson@gmail.com>
pull/31238/head
Evan Anderson 3 weeks ago
parent 20f4e1f12d
commit a493d442e4

@ -281,7 +281,7 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values common.Values,
if strings.TrimSpace(content) == "" { if strings.TrimSpace(content) == "" {
continue continue
} }
fmt.Fprintf(b, "---\n# Source: %s\n%s\n", name, content) fmt.Fprintf(b, "---\n# Source: %s\n%s\n", filepath.ToSlash(name), content)
} }
return hs, b, "", err return hs, b, "", err
} }
@ -292,7 +292,7 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values common.Values,
if includeCrds { if includeCrds {
for _, crd := range ch.CRDObjects() { for _, crd := range ch.CRDObjects() {
if outputDir == "" { if outputDir == "" {
fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Filename, string(crd.File.Data[:])) fmt.Fprintf(b, "---\n# Source: %s\n%s\n", filepath.ToSlash(crd.Filename), string(crd.File.Data[:]))
} else { } else {
err = writeToFile(outputDir, crd.Filename, string(crd.File.Data[:]), fileWritten[crd.Filename]) err = writeToFile(outputDir, crd.Filename, string(crd.File.Data[:]), fileWritten[crd.Filename])
if err != nil { if err != nil {
@ -308,7 +308,7 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values common.Values,
if hideSecret && m.Head.Kind == "Secret" && m.Head.Version == "v1" { if hideSecret && m.Head.Kind == "Secret" && m.Head.Version == "v1" {
fmt.Fprintf(b, "---\n# Source: %s\n# HIDDEN: The Secret output has been suppressed\n", m.Name) fmt.Fprintf(b, "---\n# Source: %s\n# HIDDEN: The Secret output has been suppressed\n", m.Name)
} else { } else {
fmt.Fprintf(b, "---\n# Source: %s\n%s\n", m.Name, m.Content) fmt.Fprintf(b, "---\n# Source: %s\n%s\n", filepath.ToSlash(m.Name), m.Content)
} }
} else { } else {
newDir := outputDir newDir := outputDir

@ -657,7 +657,8 @@ func writeToFile(outputDir string, name string, data string, appendData bool) er
defer f.Close() defer f.Close()
_, err = fmt.Fprintf(f, "---\n# Source: %s\n%s\n", name, data) // Use consistent (POSIX) filepaths in comments, even if expanded on Windows.
_, err = fmt.Fprintf(f, "---\n# Source: %s\n%s\n", filepath.ToSlash(name), data)
if err != nil { if err != nil {
return err return err

@ -20,6 +20,7 @@ import (
"fmt" "fmt"
"io" "io"
"log" "log"
"path/filepath"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -53,7 +54,7 @@ func newGetHooksCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return err return err
} }
for _, hook := range res.Hooks { for _, hook := range res.Hooks {
fmt.Fprintf(out, "---\n# Source: %s\n%s\n", hook.Path, hook.Manifest) fmt.Fprintf(out, "---\n# Source: %s\n%s\n", filepath.ToSlash(hook.Path), hook.Manifest)
} }
return nil return nil
}, },

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"io" "io"
"log" "log"
"path/filepath"
"strings" "strings"
"time" "time"
@ -214,7 +215,7 @@ func (s statusPrinter) WriteTable(out io.Writer) error {
if strings.EqualFold(s.release.Info.Description, "Dry run complete") || s.debug { if strings.EqualFold(s.release.Info.Description, "Dry run complete") || s.debug {
_, _ = fmt.Fprintln(out, "HOOKS:") _, _ = fmt.Fprintln(out, "HOOKS:")
for _, h := range s.release.Hooks { for _, h := range s.release.Hooks {
_, _ = fmt.Fprintf(out, "---\n# Source: %s\n%s\n", h.Path, h.Manifest) _, _ = fmt.Fprintf(out, "---\n# Source: %s\n%s\n", filepath.ToSlash(h.Path), h.Manifest)
} }
_, _ = fmt.Fprintf(out, "MANIFEST:\n%s\n", s.release.Manifest) _, _ = fmt.Fprintf(out, "MANIFEST:\n%s\n", s.release.Manifest)
} }

@ -115,7 +115,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
continue continue
} }
if client.OutputDir == "" { if client.OutputDir == "" {
fmt.Fprintf(&manifests, "---\n# Source: %s\n%s\n", m.Path, m.Manifest) fmt.Fprintf(&manifests, "---\n# Source: %s\n%s\n", filepath.ToSlash(m.Path), m.Manifest)
} else { } else {
newDir := client.OutputDir newDir := client.OutputDir
if client.UseReleaseName { if client.UseReleaseName {
@ -231,7 +231,7 @@ func writeToFile(outputDir string, name string, data string, appendData bool) er
defer f.Close() defer f.Close()
_, err = fmt.Fprintf(f, "---\n# Source: %s\n%s\n", name, data) _, err = fmt.Fprintf(f, "---\n# Source: %s\n%s\n", filepath.ToSlash(name), data)
if err != nil { if err != nil {
return err return err

Loading…
Cancel
Save