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
44185912
Unverified
Commit
44185912
authored
Oct 31, 2017
by
juanvallejo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move cmd/util/printing.go#PrintResourceInfoForCommand -> factory_builder.go
parent
9ed5d380
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
54 additions
and
26 deletions
+54
-26
apply.go
pkg/kubectl/cmd/apply.go
+2
-2
apply_set_last_applied.go
pkg/kubectl/cmd/apply_set_last_applied.go
+1
-1
reconcile.go
pkg/kubectl/cmd/auth/reconcile.go
+1
-1
create.go
pkg/kubectl/cmd/create.go
+1
-1
patch.go
pkg/kubectl/cmd/patch.go
+2
-2
fake.go
pkg/kubectl/cmd/testing/fake.go
+28
-0
factory.go
pkg/kubectl/cmd/util/factory.go
+5
-0
factory_builder.go
pkg/kubectl/cmd/util/factory_builder.go
+14
-0
printing.go
pkg/kubectl/cmd/util/printing.go
+0
-19
No files found.
pkg/kubectl/cmd/apply.go
View file @
44185912
...
...
@@ -292,7 +292,7 @@ func RunApply(f cmdutil.Factory, cmd *cobra.Command, out, errOut io.Writer, opti
count
++
if
len
(
output
)
>
0
&&
!
shortOutput
{
return
cmdutil
.
PrintResourceInfoForCommand
(
cmd
,
info
,
f
,
out
)
return
f
.
PrintResourceInfoForCommand
(
cmd
,
info
,
out
)
}
cmdutil
.
PrintSuccess
(
mapper
,
shortOutput
,
out
,
info
.
Mapping
.
Resource
,
info
.
Name
,
dryRun
,
"created"
)
return
nil
...
...
@@ -344,7 +344,7 @@ func RunApply(f cmdutil.Factory, cmd *cobra.Command, out, errOut io.Writer, opti
}
count
++
if
len
(
output
)
>
0
&&
!
shortOutput
{
return
cmdutil
.
PrintResourceInfoForCommand
(
cmd
,
info
,
f
,
out
)
return
f
.
PrintResourceInfoForCommand
(
cmd
,
info
,
out
)
}
cmdutil
.
PrintSuccess
(
mapper
,
shortOutput
,
out
,
info
.
Mapping
.
Resource
,
info
.
Name
,
dryRun
,
"configured"
)
return
nil
...
...
pkg/kubectl/cmd/apply_set_last_applied.go
View file @
44185912
...
...
@@ -190,7 +190,7 @@ func (o *SetLastAppliedOptions) RunSetLastApplied(f cmdutil.Factory, cmd *cobra.
if
len
(
o
.
Output
)
>
0
&&
!
o
.
ShortOutput
{
info
.
Refresh
(
patchedObj
,
false
)
return
cmdutil
.
PrintResourceInfoForCommand
(
cmd
,
info
,
f
,
o
.
Out
)
return
f
.
PrintResourceInfoForCommand
(
cmd
,
info
,
o
.
Out
)
}
cmdutil
.
PrintSuccess
(
o
.
Mapper
,
o
.
ShortOutput
,
o
.
Out
,
info
.
Mapping
.
Resource
,
info
.
Name
,
o
.
DryRun
,
"configured"
)
...
...
pkg/kubectl/cmd/auth/reconcile.go
View file @
44185912
...
...
@@ -117,7 +117,7 @@ func (o *ReconcileOptions) Complete(cmd *cobra.Command, f cmdutil.Factory, args
shortOutput
:=
output
==
"name"
o
.
Print
=
func
(
info
*
resource
.
Info
)
error
{
if
len
(
output
)
>
0
&&
!
shortOutput
{
return
cmdutil
.
PrintResourceInfoForCommand
(
cmd
,
info
,
f
,
o
.
Out
)
return
f
.
PrintResourceInfoForCommand
(
cmd
,
info
,
o
.
Out
)
}
cmdutil
.
PrintSuccess
(
mapper
,
shortOutput
,
o
.
Out
,
info
.
Mapping
.
Resource
,
info
.
Name
,
dryRun
,
"reconciled"
)
return
nil
...
...
pkg/kubectl/cmd/create.go
View file @
44185912
...
...
@@ -229,7 +229,7 @@ func RunCreate(f cmdutil.Factory, cmd *cobra.Command, out, errOut io.Writer, opt
shortOutput
:=
output
==
"name"
if
len
(
output
)
>
0
&&
!
shortOutput
{
return
cmdutil
.
PrintResourceInfoForCommand
(
cmd
,
info
,
f
,
out
)
return
f
.
PrintResourceInfoForCommand
(
cmd
,
info
,
out
)
}
if
!
shortOutput
{
f
.
PrintObjectSpecificMessage
(
info
.
Object
,
out
)
...
...
pkg/kubectl/cmd/patch.go
View file @
44185912
...
...
@@ -220,7 +220,7 @@ func RunPatch(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []strin
}
if
len
(
options
.
OutputFormat
)
>
0
&&
options
.
OutputFormat
!=
"name"
{
return
cmdutil
.
PrintResourceInfoForCommand
(
cmd
,
info
,
f
,
out
)
return
f
.
PrintResourceInfoForCommand
(
cmd
,
info
,
out
)
}
mapper
,
_
,
err
:=
f
.
UnstructuredObject
()
if
err
!=
nil
{
...
...
@@ -260,7 +260,7 @@ func RunPatch(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []strin
if
err
:=
info
.
Refresh
(
targetObj
,
true
);
err
!=
nil
{
return
err
}
return
cmdutil
.
PrintResourceInfoForCommand
(
cmd
,
info
,
f
,
out
)
return
f
.
PrintResourceInfoForCommand
(
cmd
,
info
,
out
)
})
if
err
!=
nil
{
return
err
...
...
pkg/kubectl/cmd/testing/fake.go
View file @
44185912
...
...
@@ -353,6 +353,20 @@ func (f *FakeFactory) PrinterForCommand(cmd *cobra.Command, isLocal bool, output
return
f
.
tf
.
Printer
,
f
.
tf
.
Err
}
func
(
f
*
FakeFactory
)
PrintResourceInfoForCommand
(
cmd
*
cobra
.
Command
,
info
*
resource
.
Info
,
out
io
.
Writer
)
error
{
printer
,
err
:=
f
.
PrinterForCommand
(
cmd
,
false
,
nil
,
printers
.
PrintOptions
{})
if
err
!=
nil
{
return
err
}
if
!
printer
.
IsGeneric
()
{
printer
,
err
=
f
.
PrinterForMapping
(
cmd
,
false
,
nil
,
nil
,
false
)
if
err
!=
nil
{
return
err
}
}
return
printer
.
PrintObj
(
info
.
Object
,
out
)
}
func
(
f
*
FakeFactory
)
Printer
(
mapping
*
meta
.
RESTMapping
,
options
printers
.
PrintOptions
)
(
printers
.
ResourcePrinter
,
error
)
{
return
f
.
tf
.
Printer
,
f
.
tf
.
Err
}
...
...
@@ -682,6 +696,20 @@ func (f *fakeAPIFactory) PrinterForCommand(cmd *cobra.Command, isLocal bool, out
return
f
.
tf
.
Printer
,
f
.
tf
.
Err
}
func
(
f
*
fakeAPIFactory
)
PrintResourceInfoForCommand
(
cmd
*
cobra
.
Command
,
info
*
resource
.
Info
,
out
io
.
Writer
)
error
{
printer
,
err
:=
f
.
PrinterForCommand
(
cmd
,
false
,
nil
,
printers
.
PrintOptions
{})
if
err
!=
nil
{
return
err
}
if
!
printer
.
IsGeneric
()
{
printer
,
err
=
f
.
PrinterForMapping
(
cmd
,
false
,
nil
,
nil
,
false
)
if
err
!=
nil
{
return
err
}
}
return
printer
.
PrintObj
(
info
.
Object
,
out
)
}
func
(
f
*
fakeAPIFactory
)
Describer
(
*
meta
.
RESTMapping
)
(
printers
.
Describer
,
error
)
{
return
f
.
tf
.
Describer
,
f
.
tf
.
Err
}
...
...
pkg/kubectl/cmd/util/factory.go
View file @
44185912
...
...
@@ -243,6 +243,11 @@ type BuilderFactory interface {
PrinterForMapping
(
cmd
*
cobra
.
Command
,
isLocal
bool
,
outputOpts
*
printers
.
OutputOptions
,
mapping
*
meta
.
RESTMapping
,
withNamespace
bool
)
(
printers
.
ResourcePrinter
,
error
)
// PrintObject prints an api object given command line flags to modify the output format
PrintObject
(
cmd
*
cobra
.
Command
,
isLocal
bool
,
mapper
meta
.
RESTMapper
,
obj
runtime
.
Object
,
out
io
.
Writer
)
error
// PrintResourceInfoForCommand receives a *cobra.Command and a *resource.Info and
// attempts to print an info object based on the specified output format. If the
// object passed is non-generic, it attempts to print the object using a HumanReadablePrinter.
// Requires that printer flags have been added to cmd (see AddPrinterFlags).
PrintResourceInfoForCommand
(
cmd
*
cobra
.
Command
,
info
*
resource
.
Info
,
out
io
.
Writer
)
error
// One stop shopping for a structured Builder
NewBuilder
()
*
resource
.
Builder
// One stop shopping for a unstructured Builder
...
...
pkg/kubectl/cmd/util/factory_builder.go
View file @
44185912
...
...
@@ -138,6 +138,20 @@ func (f *ring2Factory) PrintObject(cmd *cobra.Command, isLocal bool, mapper meta
return
printer
.
PrintObj
(
obj
,
out
)
}
func
(
f
*
ring2Factory
)
PrintResourceInfoForCommand
(
cmd
*
cobra
.
Command
,
info
*
resource
.
Info
,
out
io
.
Writer
)
error
{
printer
,
err
:=
f
.
PrinterForCommand
(
cmd
,
false
,
nil
,
printers
.
PrintOptions
{})
if
err
!=
nil
{
return
err
}
if
!
printer
.
IsGeneric
()
{
printer
,
err
=
f
.
PrinterForMapping
(
cmd
,
false
,
nil
,
nil
,
false
)
if
err
!=
nil
{
return
err
}
}
return
printer
.
PrintObj
(
info
.
Object
,
out
)
}
// NewBuilder returns a new resource builder for structured api objects.
func
(
f
*
ring2Factory
)
NewBuilder
()
*
resource
.
Builder
{
clientMapperFunc
:=
resource
.
ClientMapperFunc
(
f
.
objectMappingFactory
.
ClientForMapping
)
...
...
pkg/kubectl/cmd/util/printing.go
View file @
44185912
...
...
@@ -25,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/printers"
printersinternal
"k8s.io/kubernetes/pkg/printers/internalversion"
...
...
@@ -138,24 +137,6 @@ func PrinterForCommand(cmd *cobra.Command, outputOpts *printers.OutputOptions, m
return
maybeWrapSortingPrinter
(
cmd
,
printer
),
nil
}
// PrintResourceInfoForCommand receives a *cobra.Command and a *resource.Info and
// attempts to print an info object based on the specified output format. If the
// object passed is non-generic, it attempts to print the object using a HumanReadablePrinter.
// Requires that printer flags have been added to cmd (see AddPrinterFlags).
func
PrintResourceInfoForCommand
(
cmd
*
cobra
.
Command
,
info
*
resource
.
Info
,
f
Factory
,
out
io
.
Writer
)
error
{
printer
,
err
:=
f
.
PrinterForCommand
(
cmd
,
false
,
nil
,
printers
.
PrintOptions
{})
if
err
!=
nil
{
return
err
}
if
!
printer
.
IsGeneric
()
{
printer
,
err
=
f
.
PrinterForMapping
(
cmd
,
false
,
nil
,
nil
,
false
)
if
err
!=
nil
{
return
err
}
}
return
printer
.
PrintObj
(
info
.
Object
,
out
)
}
// extractOutputOptions parses printer specific commandline args and returns
// printers.OutputsOptions object.
func
extractOutputOptions
(
cmd
*
cobra
.
Command
)
*
printers
.
OutputOptions
{
...
...
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