Merge pull request #61523 from dixudx/formatter_escape_percent_sign

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

escape literal percent sign when formatting

**What this PR does / why we need it**:

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #61503

**Special notes for your reviewer**:
/assign @janetkuo @liggitt 
/cc @kubernetes/sig-cli-bugs 

**Release note**:

```release-note
escape literal percent sign when formatting
```
This commit is contained in:
Kubernetes Submit Queue 2018-03-26 03:52:16 -07:00 committed by GitHub
commit 3a2fe7b8f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,7 +48,11 @@ func (f *Formatter) Write(str string, a ...interface{}) error {
for i := 0; i < f.IndentLevel; i++ {
indent = indent + " "
}
_, err := io.WriteString(f.Writer, indent+fmt.Sprintf(str, a...)+"\n")
if len(a) > 0 {
str = fmt.Sprintf(str, a...)
}
_, err := io.WriteString(f.Writer, indent+str+"\n")
return err
}