@@ -61,7 +61,7 @@ const (
61
61
defaultPodLogsTimeout = 20 * time .Second
62
62
)
63
63
64
- // AttachOptions declare the arguments accepted by the Exec command
64
+ // AttachOptions declare the arguments accepted by the Attach command
65
65
type AttachOptions struct {
66
66
exec.StreamOptions
67
67
@@ -84,6 +84,7 @@ type AttachOptions struct {
84
84
Config * restclient.Config
85
85
}
86
86
87
+ // NewAttachOptions creates the options for attach
87
88
func NewAttachOptions (streams genericclioptions.IOStreams ) * AttachOptions {
88
89
return & AttachOptions {
89
90
StreamOptions : exec.StreamOptions {
@@ -94,6 +95,7 @@ func NewAttachOptions(streams genericclioptions.IOStreams) *AttachOptions {
94
95
}
95
96
}
96
97
98
+ // NewCmdAttach returns the attach Cobra command
97
99
func NewCmdAttach (f cmdutil.Factory , streams genericclioptions.IOStreams ) * cobra.Command {
98
100
o := NewAttachOptions (streams )
99
101
cmd := & cobra.Command {
@@ -120,6 +122,7 @@ type RemoteAttach interface {
120
122
Attach (method string , url * url.URL , config * restclient.Config , stdin io.Reader , stdout , stderr io.Writer , tty bool , terminalSizeQueue remotecommand.TerminalSizeQueue ) error
121
123
}
122
124
125
+ // DefaultAttachFunc is the default AttachFunc used
123
126
func DefaultAttachFunc (o * AttachOptions , containerToAttach * corev1.Container , raw bool , sizeQueue remotecommand.TerminalSizeQueue ) func () error {
124
127
return func () error {
125
128
restClient , err := restclient .RESTClientFor (o .Config )
@@ -146,6 +149,7 @@ func DefaultAttachFunc(o *AttachOptions, containerToAttach *corev1.Container, ra
146
149
// DefaultRemoteAttach is the standard implementation of attaching
147
150
type DefaultRemoteAttach struct {}
148
151
152
+ // Attach executes attach to a running container
149
153
func (* DefaultRemoteAttach ) Attach (method string , url * url.URL , config * restclient.Config , stdin io.Reader , stdout , stderr io.Writer , tty bool , terminalSizeQueue remotecommand.TerminalSizeQueue ) error {
150
154
exec , err := remotecommand .NewSPDYExecutor (config , method , url )
151
155
if err != nil {
0 commit comments