Merge pull request #66554 from charrywanganthony/watch_json

Automatic merge from submit-queue (batch tested with PRs 66554, 66616, 66695, 66681). 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>.

fix the watch status when -o=yaml|json option is specfied

**Which issue(s) this PR fixes** : 
`kubectl get pods --watch -o json` only putput once and stop, this PR fix this.

**Release note**:
```release-note
NONE
```
pull/8/head
Kubernetes Submit Queue 2018-07-27 10:09:04 -07:00 committed by GitHub
commit 1dd4f8d82f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -575,8 +575,12 @@ func (o *GetOptions) watch(f cmdutil.Factory, cmd *cobra.Command, args []string)
// printing always takes the internal version, but the watch event uses externals
// TODO fix printing to use server-side or be version agnostic
internalGV := mapping.GroupVersionKind.GroupKind().WithVersion(runtime.APIVersionInternal).GroupVersion()
if err := printer.PrintObj(attemptToConvertToInternal(e.Object, legacyscheme.Scheme, internalGV), o.Out); err != nil {
objToPrint := e.Object
if o.IsHumanReadablePrinter {
internalGV := mapping.GroupVersionKind.GroupKind().WithVersion(runtime.APIVersionInternal).GroupVersion()
objToPrint = attemptToConvertToInternal(e.Object, legacyscheme.Scheme, internalGV)
}
if err := printer.PrintObj(objToPrint, o.Out); err != nil {
return false, err
}
return false, nil