Unverified Commit b3536812 authored by Matthew Fisher's avatar Matthew Fisher Committed by GitHub

Merge pull request #3988 from kubernetes/revert-3837-toYaml-pr

Revert "toYaml - Fix #3470 and #3410's trailing \n issues"
parents 68714865 f7f686f7
...@@ -175,7 +175,7 @@ func ToYaml(v interface{}) string { ...@@ -175,7 +175,7 @@ func ToYaml(v interface{}) string {
// Swallow errors inside of a template. // Swallow errors inside of a template.
return "" return ""
} }
return strings.TrimSuffix(string(data), "\n") return string(data)
} }
// FromYaml converts a YAML document into a map[string]interface{}. // FromYaml converts a YAML document into a map[string]interface{}.
......
...@@ -72,10 +72,10 @@ func TestToConfig(t *testing.T) { ...@@ -72,10 +72,10 @@ func TestToConfig(t *testing.T) {
f := NewFiles(getTestFiles()) f := NewFiles(getTestFiles())
out := f.Glob("**/captain.txt").AsConfig() out := f.Glob("**/captain.txt").AsConfig()
as.Equal("captain.txt: The Captain", out) as.Equal("captain.txt: The Captain\n", out)
out = f.Glob("ship/**").AsConfig() out = f.Glob("ship/**").AsConfig()
as.Equal("captain.txt: The Captain\nstowaway.txt: Legatt", out) as.Equal("captain.txt: The Captain\nstowaway.txt: Legatt\n", out)
} }
func TestToSecret(t *testing.T) { func TestToSecret(t *testing.T) {
...@@ -84,7 +84,7 @@ func TestToSecret(t *testing.T) { ...@@ -84,7 +84,7 @@ func TestToSecret(t *testing.T) {
f := NewFiles(getTestFiles()) f := NewFiles(getTestFiles())
out := f.Glob("ship/**").AsSecrets() out := f.Glob("ship/**").AsSecrets()
as.Equal("captain.txt: VGhlIENhcHRhaW4=\nstowaway.txt: TGVnYXR0", out) as.Equal("captain.txt: VGhlIENhcHRhaW4=\nstowaway.txt: TGVnYXR0\n", out)
} }
func TestLines(t *testing.T) { func TestLines(t *testing.T) {
...@@ -99,7 +99,7 @@ func TestLines(t *testing.T) { ...@@ -99,7 +99,7 @@ func TestLines(t *testing.T) {
} }
func TestToYaml(t *testing.T) { func TestToYaml(t *testing.T) {
expect := "foo: bar" expect := "foo: bar\n"
v := struct { v := struct {
Foo string `json:"foo"` Foo string `json:"foo"`
}{ }{
......
...@@ -36,7 +36,7 @@ func ToYAML(s string) (string, error) { ...@@ -36,7 +36,7 @@ func ToYAML(s string) (string, error) {
return "", err return "", err
} }
d, err := yaml.Marshal(m) d, err := yaml.Marshal(m)
return strings.TrimSuffix(string(d), "\n"), err return string(d), err
} }
// Parse parses a set line. // Parse parses a set line.
......
...@@ -370,7 +370,7 @@ func TestToYAML(t *testing.T) { ...@@ -370,7 +370,7 @@ func TestToYAML(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
expect := "name: value" expect := "name: value\n"
if o != expect { if o != expect {
t.Errorf("Expected %q, got %q", expect, o) t.Errorf("Expected %q, got %q", expect, o)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment