From c0a906d96d1bba26bdcd036d1407c07bdf181480 Mon Sep 17 00:00:00 2001 From: Ryan Phillips Date: Mon, 20 Aug 2018 14:08:54 -0500 Subject: [PATCH 1/2] UPSTREAM: 67615: attach: Move the AttachFunc default function to the initializer Fixes a partially constructed AttachOptions --- vendor/k8s.io/kubernetes/pkg/kubectl/cmd/attach.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/attach.go b/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/attach.go index 153a1406bebc..602b5234f7d6 100644 --- a/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/attach.go +++ b/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/attach.go @@ -89,7 +89,8 @@ func NewAttachOptions(streams genericclioptions.IOStreams) *AttachOptions { StreamOptions: StreamOptions{ IOStreams: streams, }, - Attach: &DefaultRemoteAttach{}, + Attach: &DefaultRemoteAttach{}, + AttachFunc: defaultAttachFunc, } } @@ -193,8 +194,6 @@ func (o *AttachOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []s } o.Config = config - o.AttachFunc = defaultAttachFunc - if o.CommandName == "" { o.CommandName = cmd.CommandPath() } From b051e60cb042fd0c8f5967841660a0f01774874d Mon Sep 17 00:00:00 2001 From: Ryan Phillips Date: Mon, 20 Aug 2018 10:57:37 -0500 Subject: [PATCH 2/2] oc debug fix crash on attach Refactors to pick up the initializer for defaultAttachFunc Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1618522 --- pkg/oc/cli/debug/debug.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pkg/oc/cli/debug/debug.go b/pkg/oc/cli/debug/debug.go index 4fe8a4b83c25..07ffa73310ab 100644 --- a/pkg/oc/cli/debug/debug.go +++ b/pkg/oc/cli/debug/debug.go @@ -139,21 +139,17 @@ type DebugOptions struct { } func NewDebugOptions(streams genericclioptions.IOStreams) *DebugOptions { + attachOpts := kcmd.NewAttachOptions(streams) + attachOpts.TTY = true + attachOpts.Stdin = true return &DebugOptions{ PrintFlags: genericclioptions.NewPrintFlags("").WithTypeSetter(scheme.Scheme), IOStreams: streams, Timeout: 15 * time.Minute, KeepInitContainers: true, AsUser: -1, - Attach: kcmd.AttachOptions{ - StreamOptions: kcmd.StreamOptions{ - IOStreams: streams, - TTY: true, - Stdin: true, - }, - Attach: &kcmd.DefaultRemoteAttach{}, - }, - LogsForObject: polymorphichelpers.LogsForObjectFn, + Attach: *attachOpts, + LogsForObject: polymorphichelpers.LogsForObjectFn, } }