Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
25160867
Commit
25160867
authored
Oct 01, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14764 from timstclair/kubectl
Auto commit by PR queue bot
parents
b9293a09
4dc9df91
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
attach.go
pkg/kubectl/cmd/attach.go
+11
-7
run.go
pkg/kubectl/cmd/run.go
+6
-2
No files found.
pkg/kubectl/cmd/attach.go
View file @
25160867
...
...
@@ -156,12 +156,6 @@ func (p *AttachOptions) Run() error {
return
fmt
.
Errorf
(
"pod %s is not running and cannot be attached to; current phase is %s"
,
p
.
PodName
,
pod
.
Status
.
Phase
)
}
containerName
:=
p
.
ContainerName
if
len
(
containerName
)
==
0
{
glog
.
V
(
4
)
.
Infof
(
"defaulting container name to %s"
,
pod
.
Spec
.
Containers
[
0
]
.
Name
)
containerName
=
pod
.
Spec
.
Containers
[
0
]
.
Name
}
// TODO: refactor with terminal helpers from the edit utility once that is merged
var
stdin
io
.
Reader
tty
:=
p
.
TTY
...
...
@@ -205,7 +199,17 @@ func (p *AttachOptions) Run() error {
Name
(
pod
.
Name
)
.
Namespace
(
pod
.
Namespace
)
.
SubResource
(
"attach"
)
.
Param
(
"container"
,
containerName
)
Param
(
"container"
,
p
.
GetContainerName
(
pod
)
)
return
p
.
Attach
.
Attach
(
req
,
p
.
Config
,
stdin
,
p
.
Out
,
p
.
Err
,
tty
)
}
// GetContainerName returns the name of the container to attach to, with a fallback.
func
(
p
*
AttachOptions
)
GetContainerName
(
pod
*
api
.
Pod
)
string
{
if
len
(
p
.
ContainerName
)
>
0
{
return
p
.
ContainerName
}
glog
.
V
(
4
)
.
Infof
(
"defaulting container name to %s"
,
pod
.
Spec
.
Containers
[
0
]
.
Name
)
return
pod
.
Spec
.
Containers
[
0
]
.
Name
}
pkg/kubectl/cmd/run.go
View file @
25160867
...
...
@@ -291,12 +291,16 @@ func handleAttachPod(c *client.Client, pod *api.Pod, opts *AttachOptions) error
return
err
}
if
status
==
api
.
PodSucceeded
||
status
==
api
.
PodFailed
{
return
handleLog
(
c
,
pod
.
Namespace
,
pod
.
Name
,
&
api
.
PodLogOptions
{
Container
:
pod
.
Spec
.
Containers
[
0
]
.
Name
},
opts
.
Out
)
return
handleLog
(
c
,
pod
.
Namespace
,
pod
.
Name
,
&
api
.
PodLogOptions
{
Container
:
opts
.
GetContainerName
(
pod
)
},
opts
.
Out
)
}
opts
.
Client
=
c
opts
.
PodName
=
pod
.
Name
opts
.
Namespace
=
pod
.
Namespace
return
opts
.
Run
()
if
err
:=
opts
.
Run
();
err
!=
nil
{
fmt
.
Fprintf
(
opts
.
Out
,
"Error attaching, falling back to logs: %v
\n
"
,
err
)
return
handleLog
(
c
,
pod
.
Namespace
,
pod
.
Name
,
&
api
.
PodLogOptions
{
Container
:
opts
.
GetContainerName
(
pod
)},
opts
.
Out
)
}
return
nil
}
func
getRestartPolicy
(
cmd
*
cobra
.
Command
,
interactive
bool
)
(
api
.
RestartPolicy
,
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment