mirror of https://github.com/k3s-io/k3s
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
commit
1dd4f8d82f
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue