Merge pull request #67615 from rphillips/fixes/attach_func_initializer

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>.

attach: Move the AttachFunc default function to the initializer

Fixes a partially constructed AttachOptions

**What this PR does / why we need it**: NewAttachOptions partially constructs an AttachOptions structure. The defaultAttachFunc should be set automatically, so the caller can potentially override the default behavior.

**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 #

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```

/cc @kubernetes/sig-cli-api-reviews
This commit is contained in:
Kubernetes Submit Queue 2018-08-22 07:32:57 -07:00 committed by GitHub
commit 5fb32e703b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()
}