From acbbaddada4cf302134962b1d7fd9fb2c0bdba37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arda=20G=C3=BC=C3=A7l=C3=BC?= Date: Fri, 22 Dec 2023 09:50:48 +0300 Subject: [PATCH] Initialize default attach func regardless of the value of flag --- .../src/k8s.io/kubectl/pkg/cmd/debug/debug.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/debug/debug.go b/staging/src/k8s.io/kubectl/pkg/cmd/debug/debug.go index bbabe09e72a..456ebc4b718 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/debug/debug.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/debug/debug.go @@ -213,14 +213,15 @@ func (o *DebugOptions) Complete(restClientGetter genericclioptions.RESTClientGet attachFlag := cmd.Flags().Lookup("attach") if !attachFlag.Changed && o.Interactive { o.Attach = true - // Downstream tools may want to use their own customized - // attach function to do extra work or use attach command - // with different flags instead of the static one defined in - // handleAttachPod. But if this function is not set explicitly, - // we fall back to default. - if o.AttachFunc == nil { - o.AttachFunc = o.handleAttachPod - } + } + + // Downstream tools may want to use their own customized + // attach function to do extra work or use attach command + // with different flags instead of the static one defined in + // handleAttachPod. But if this function is not set explicitly, + // we fall back to default. + if o.AttachFunc == nil { + o.AttachFunc = o.handleAttachPod } // Environment