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
b9537245
Commit
b9537245
authored
Nov 26, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17702 from hurf/logs_cleanup
Auto commit by PR queue bot
parents
5687bfa8
91ad5b4e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
14 deletions
+14
-14
cmd.go
pkg/kubectl/cmd/cmd.go
+1
-1
logs.go
pkg/kubectl/cmd/logs.go
+10
-10
logs_test.go
pkg/kubectl/cmd/logs_test.go
+3
-3
No files found.
pkg/kubectl/cmd/cmd.go
View file @
b9537245
...
@@ -157,7 +157,7 @@ Find more information at https://github.com/kubernetes/kubernetes.`,
...
@@ -157,7 +157,7 @@ Find more information at https://github.com/kubernetes/kubernetes.`,
cmds
.
AddCommand
(
NewCmdApply
(
f
,
out
))
cmds
.
AddCommand
(
NewCmdApply
(
f
,
out
))
cmds
.
AddCommand
(
NewCmdNamespace
(
out
))
cmds
.
AddCommand
(
NewCmdNamespace
(
out
))
cmds
.
AddCommand
(
NewCmdLog
(
f
,
out
))
cmds
.
AddCommand
(
NewCmdLog
s
(
f
,
out
))
cmds
.
AddCommand
(
NewCmdRollingUpdate
(
f
,
out
))
cmds
.
AddCommand
(
NewCmdRollingUpdate
(
f
,
out
))
cmds
.
AddCommand
(
NewCmdScale
(
f
,
out
))
cmds
.
AddCommand
(
NewCmdScale
(
f
,
out
))
...
...
pkg/kubectl/cmd/log.go
→
pkg/kubectl/cmd/log
s
.go
View file @
b9537245
...
@@ -35,7 +35,7 @@ import (
...
@@ -35,7 +35,7 @@ import (
)
)
const
(
const
(
log_example
=
`# Return snapshot logs from pod nginx with only one container
log
s
_example
=
`# Return snapshot logs from pod nginx with only one container
$ kubectl logs nginx
$ kubectl logs nginx
# Return snapshot of previous terminated ruby container logs from pod web-1
# Return snapshot of previous terminated ruby container logs from pod web-1
...
@@ -65,14 +65,14 @@ type LogsOptions struct {
...
@@ -65,14 +65,14 @@ type LogsOptions struct {
Out
io
.
Writer
Out
io
.
Writer
}
}
// NewCmdLog creates a new pod log command
// NewCmdLog creates a new pod log
s
command
func
NewCmdLog
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdLog
s
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
o
:=
&
LogsOptions
{}
o
:=
&
LogsOptions
{}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"logs [-f] [-p] POD [-c CONTAINER]"
,
Use
:
"logs [-f] [-p] POD [-c CONTAINER]"
,
Short
:
"Print the logs for a container in a pod."
,
Short
:
"Print the logs for a container in a pod."
,
Long
:
"Print the logs for a container in a pod. If the pod has only one container, the container name is optional."
,
Long
:
"Print the logs for a container in a pod. If the pod has only one container, the container name is optional."
,
Example
:
log_example
,
Example
:
log
s
_example
,
PreRun
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
PreRun
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"log"
{
if
len
(
os
.
Args
)
>
1
&&
os
.
Args
[
1
]
==
"log"
{
printDeprecationWarning
(
"logs"
,
"log"
)
printDeprecationWarning
(
"logs"
,
"log"
)
...
@@ -83,7 +83,7 @@ func NewCmdLog(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -83,7 +83,7 @@ func NewCmdLog(f *cmdutil.Factory, out io.Writer) *cobra.Command {
if
err
:=
o
.
Validate
();
err
!=
nil
{
if
err
:=
o
.
Validate
();
err
!=
nil
{
cmdutil
.
CheckErr
(
cmdutil
.
UsageError
(
cmd
,
err
.
Error
()))
cmdutil
.
CheckErr
(
cmdutil
.
UsageError
(
cmd
,
err
.
Error
()))
}
}
_
,
err
:=
o
.
RunLog
()
_
,
err
:=
o
.
RunLog
s
()
cmdutil
.
CheckErr
(
err
)
cmdutil
.
CheckErr
(
err
)
},
},
Aliases
:
[]
string
{
"log"
},
Aliases
:
[]
string
{
"log"
},
...
@@ -163,19 +163,19 @@ func (o LogsOptions) Validate() error {
...
@@ -163,19 +163,19 @@ func (o LogsOptions) Validate() error {
if
len
(
o
.
ResourceArg
)
==
0
{
if
len
(
o
.
ResourceArg
)
==
0
{
return
errors
.
New
(
"a pod must be specified"
)
return
errors
.
New
(
"a pod must be specified"
)
}
}
logOptions
,
ok
:=
o
.
Options
.
(
*
api
.
PodLogOptions
)
log
s
Options
,
ok
:=
o
.
Options
.
(
*
api
.
PodLogOptions
)
if
!
ok
{
if
!
ok
{
return
errors
.
New
(
"unexpected log options object"
)
return
errors
.
New
(
"unexpected log
s
options object"
)
}
}
if
errs
:=
validation
.
ValidatePodLogOptions
(
logOptions
);
len
(
errs
)
>
0
{
if
errs
:=
validation
.
ValidatePodLogOptions
(
log
s
Options
);
len
(
errs
)
>
0
{
return
errs
.
ToAggregate
()
return
errs
.
ToAggregate
()
}
}
return
nil
return
nil
}
}
// RunLog retrieves a pod log
// RunLog
s
retrieves a pod log
func
(
o
LogsOptions
)
RunLog
()
(
int64
,
error
)
{
func
(
o
LogsOptions
)
RunLog
s
()
(
int64
,
error
)
{
infos
,
err
:=
resource
.
NewBuilder
(
o
.
Mapper
,
o
.
Typer
,
o
.
ClientMapper
)
.
infos
,
err
:=
resource
.
NewBuilder
(
o
.
Mapper
,
o
.
Typer
,
o
.
ClientMapper
)
.
NamespaceParam
(
o
.
Namespace
)
.
DefaultNamespace
()
.
NamespaceParam
(
o
.
Namespace
)
.
DefaultNamespace
()
.
ResourceNames
(
"pods"
,
o
.
ResourceArg
)
.
ResourceNames
(
"pods"
,
o
.
ResourceArg
)
.
...
...
pkg/kubectl/cmd/log_test.go
→
pkg/kubectl/cmd/log
s
_test.go
View file @
b9537245
...
@@ -69,7 +69,7 @@ func TestLog(t *testing.T) {
...
@@ -69,7 +69,7 @@ func TestLog(t *testing.T) {
tf
.
ClientConfig
=
&
client
.
Config
{
GroupVersion
:
&
unversioned
.
GroupVersion
{
Version
:
test
.
version
}}
tf
.
ClientConfig
=
&
client
.
Config
{
GroupVersion
:
&
unversioned
.
GroupVersion
{
Version
:
test
.
version
}}
buf
:=
bytes
.
NewBuffer
([]
byte
{})
buf
:=
bytes
.
NewBuffer
([]
byte
{})
cmd
:=
NewCmdLog
(
f
,
buf
)
cmd
:=
NewCmdLog
s
(
f
,
buf
)
cmd
.
Flags
()
.
Set
(
"namespace"
,
"test"
)
cmd
.
Flags
()
.
Set
(
"namespace"
,
"test"
)
cmd
.
Run
(
cmd
,
[]
string
{
"foo"
})
cmd
.
Run
(
cmd
,
[]
string
{
"foo"
})
...
@@ -119,7 +119,7 @@ func TestValidateLogFlags(t *testing.T) {
...
@@ -119,7 +119,7 @@ func TestValidateLogFlags(t *testing.T) {
},
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
cmd
:=
NewCmdLog
(
f
,
bytes
.
NewBuffer
([]
byte
{}))
cmd
:=
NewCmdLog
s
(
f
,
bytes
.
NewBuffer
([]
byte
{}))
out
:=
""
out
:=
""
for
flag
,
value
:=
range
test
.
flags
{
for
flag
,
value
:=
range
test
.
flags
{
cmd
.
Flags
()
.
Set
(
flag
,
value
)
cmd
.
Flags
()
.
Set
(
flag
,
value
)
...
@@ -130,7 +130,7 @@ func TestValidateLogFlags(t *testing.T) {
...
@@ -130,7 +130,7 @@ func TestValidateLogFlags(t *testing.T) {
cmd
.
Run
=
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmd
.
Run
=
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
o
.
Complete
(
f
,
os
.
Stdout
,
cmd
,
args
)
o
.
Complete
(
f
,
os
.
Stdout
,
cmd
,
args
)
out
=
o
.
Validate
()
.
Error
()
out
=
o
.
Validate
()
.
Error
()
o
.
RunLog
()
o
.
RunLog
s
()
}
}
cmd
.
Run
(
cmd
,
[]
string
{
"foo"
})
cmd
.
Run
(
cmd
,
[]
string
{
"foo"
})
...
...
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