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
01609036
Commit
01609036
authored
Apr 12, 2018
by
David Eads
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use standard interface functions for printers
parent
39e9d1b4
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
36 deletions
+24
-36
set_env.go
pkg/kubectl/cmd/set/set_env.go
+4
-6
set_image.go
pkg/kubectl/cmd/set/set_image.go
+4
-6
set_resources.go
pkg/kubectl/cmd/set/set_resources.go
+4
-6
set_selector.go
pkg/kubectl/cmd/set/set_selector.go
+4
-6
set_serviceaccount.go
pkg/kubectl/cmd/set/set_serviceaccount.go
+4
-6
set_subject.go
pkg/kubectl/cmd/set/set_subject.go
+4
-6
No files found.
pkg/kubectl/cmd/set/set_env.go
View file @
01609036
...
@@ -117,7 +117,7 @@ type EnvOptions struct {
...
@@ -117,7 +117,7 @@ type EnvOptions struct {
From
string
From
string
Prefix
string
Prefix
string
PrintObj
func
(
runtime
.
Object
)
error
PrintObj
printers
.
ResourcePrinterFunc
Builder
*
resource
.
Builder
Builder
*
resource
.
Builder
Infos
[]
*
resource
.
Info
Infos
[]
*
resource
.
Info
...
@@ -226,9 +226,7 @@ func (o *EnvOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
...
@@ -226,9 +226,7 @@ func (o *EnvOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
o
.
PrintObj
=
func
(
obj
runtime
.
Object
)
error
{
o
.
PrintObj
=
printer
.
PrintObj
return
printer
.
PrintObj
(
obj
,
o
.
Out
)
}
if
o
.
List
&&
len
(
o
.
Output
)
>
0
{
if
o
.
List
&&
len
(
o
.
Output
)
>
0
{
return
cmdutil
.
UsageErrorf
(
o
.
Cmd
,
"--list and --output may not be specified together"
)
return
cmdutil
.
UsageErrorf
(
o
.
Cmd
,
"--list and --output may not be specified together"
)
...
@@ -437,7 +435,7 @@ func (o *EnvOptions) RunEnv(f cmdutil.Factory) error {
...
@@ -437,7 +435,7 @@ func (o *EnvOptions) RunEnv(f cmdutil.Factory) error {
}
}
if
o
.
Local
||
o
.
DryRun
{
if
o
.
Local
||
o
.
DryRun
{
if
err
:=
o
.
PrintObj
(
patch
.
Info
.
AsVersioned
());
err
!=
nil
{
if
err
:=
o
.
PrintObj
(
patch
.
Info
.
AsVersioned
()
,
o
.
Out
);
err
!=
nil
{
return
err
return
err
}
}
continue
continue
...
@@ -456,7 +454,7 @@ func (o *EnvOptions) RunEnv(f cmdutil.Factory) error {
...
@@ -456,7 +454,7 @@ func (o *EnvOptions) RunEnv(f cmdutil.Factory) error {
return
fmt
.
Errorf
(
"at least one environment variable must be provided"
)
return
fmt
.
Errorf
(
"at least one environment variable must be provided"
)
}
}
if
err
:=
o
.
PrintObj
(
info
.
AsVersioned
());
err
!=
nil
{
if
err
:=
o
.
PrintObj
(
info
.
AsVersioned
()
,
o
.
Out
);
err
!=
nil
{
return
err
return
err
}
}
}
}
...
...
pkg/kubectl/cmd/set/set_image.go
View file @
01609036
...
@@ -53,7 +53,7 @@ type ImageOptions struct {
...
@@ -53,7 +53,7 @@ type ImageOptions struct {
Cmd
*
cobra
.
Command
Cmd
*
cobra
.
Command
ResolveImage
func
(
in
string
)
(
string
,
error
)
ResolveImage
func
(
in
string
)
(
string
,
error
)
PrintObj
func
(
runtime
.
Object
)
error
PrintObj
printers
.
ResourcePrinterFunc
UpdatePodSpecForObject
func
(
obj
runtime
.
Object
,
fn
func
(
*
v1
.
PodSpec
)
error
)
(
bool
,
error
)
UpdatePodSpecForObject
func
(
obj
runtime
.
Object
,
fn
func
(
*
v1
.
PodSpec
)
error
)
(
bool
,
error
)
Resources
[]
string
Resources
[]
string
...
@@ -136,9 +136,7 @@ func (o *ImageOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
...
@@ -136,9 +136,7 @@ func (o *ImageOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
return
err
return
err
}
}
o
.
PrintObj
=
func
(
obj
runtime
.
Object
)
error
{
o
.
PrintObj
=
printer
.
PrintObj
return
printer
.
PrintObj
(
obj
,
o
.
Out
)
}
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -258,7 +256,7 @@ func (o *ImageOptions) Run() error {
...
@@ -258,7 +256,7 @@ func (o *ImageOptions) Run() error {
}
}
if
o
.
Local
||
o
.
DryRun
{
if
o
.
Local
||
o
.
DryRun
{
if
err
:=
o
.
PrintObj
(
patch
.
Info
.
AsVersioned
());
err
!=
nil
{
if
err
:=
o
.
PrintObj
(
patch
.
Info
.
AsVersioned
()
,
o
.
Out
);
err
!=
nil
{
return
err
return
err
}
}
continue
continue
...
@@ -283,7 +281,7 @@ func (o *ImageOptions) Run() error {
...
@@ -283,7 +281,7 @@ func (o *ImageOptions) Run() error {
info
.
Refresh
(
obj
,
true
)
info
.
Refresh
(
obj
,
true
)
if
err
:=
o
.
PrintObj
(
info
.
AsVersioned
());
err
!=
nil
{
if
err
:=
o
.
PrintObj
(
info
.
AsVersioned
()
,
o
.
Out
);
err
!=
nil
{
return
err
return
err
}
}
}
}
...
...
pkg/kubectl/cmd/set/set_resources.go
View file @
01609036
...
@@ -79,7 +79,7 @@ type ResourcesOptions struct {
...
@@ -79,7 +79,7 @@ type ResourcesOptions struct {
DryRun
bool
DryRun
bool
PrintObj
func
(
runtime
.
Object
)
error
PrintObj
printers
.
ResourcePrinterFunc
Limits
string
Limits
string
Requests
string
Requests
string
...
@@ -155,9 +155,7 @@ func (o *ResourcesOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
...
@@ -155,9 +155,7 @@ func (o *ResourcesOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
o
.
PrintObj
=
func
(
obj
runtime
.
Object
)
error
{
o
.
PrintObj
=
printer
.
PrintObj
return
printer
.
PrintObj
(
obj
,
o
.
Out
)
}
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -262,7 +260,7 @@ func (o *ResourcesOptions) Run() error {
...
@@ -262,7 +260,7 @@ func (o *ResourcesOptions) Run() error {
}
}
if
o
.
Local
||
o
.
DryRun
{
if
o
.
Local
||
o
.
DryRun
{
if
err
:=
o
.
PrintObj
(
patch
.
Info
.
AsVersioned
());
err
!=
nil
{
if
err
:=
o
.
PrintObj
(
patch
.
Info
.
AsVersioned
()
,
o
.
Out
);
err
!=
nil
{
return
err
return
err
}
}
continue
continue
...
@@ -285,7 +283,7 @@ func (o *ResourcesOptions) Run() error {
...
@@ -285,7 +283,7 @@ func (o *ResourcesOptions) Run() error {
}
}
info
.
Refresh
(
obj
,
true
)
info
.
Refresh
(
obj
,
true
)
if
err
:=
o
.
PrintObj
(
info
.
AsVersioned
());
err
!=
nil
{
if
err
:=
o
.
PrintObj
(
info
.
AsVersioned
()
,
o
.
Out
);
err
!=
nil
{
return
err
return
err
}
}
}
}
...
...
pkg/kubectl/cmd/set/set_selector.go
View file @
01609036
...
@@ -55,7 +55,7 @@ type SelectorOptions struct {
...
@@ -55,7 +55,7 @@ type SelectorOptions struct {
out
io
.
Writer
out
io
.
Writer
ClientForMapping
func
(
mapping
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
ClientForMapping
func
(
mapping
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
PrintObj
func
(
runtime
.
Object
)
error
PrintObj
printers
.
ResourcePrinterFunc
builder
*
resource
.
Builder
builder
*
resource
.
Builder
mapper
meta
.
RESTMapper
mapper
meta
.
RESTMapper
...
@@ -162,9 +162,7 @@ func (o *SelectorOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
...
@@ -162,9 +162,7 @@ func (o *SelectorOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
o
.
PrintObj
=
func
(
obj
runtime
.
Object
)
error
{
o
.
PrintObj
=
printer
.
PrintObj
return
printer
.
PrintObj
(
obj
,
o
.
out
)
}
o
.
ClientForMapping
=
func
(
mapping
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
{
o
.
ClientForMapping
=
func
(
mapping
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
{
return
f
.
ClientForMapping
(
mapping
)
return
f
.
ClientForMapping
(
mapping
)
...
@@ -208,7 +206,7 @@ func (o *SelectorOptions) RunSelector() error {
...
@@ -208,7 +206,7 @@ func (o *SelectorOptions) RunSelector() error {
return
patch
.
Err
return
patch
.
Err
}
}
if
o
.
local
||
o
.
dryrun
{
if
o
.
local
||
o
.
dryrun
{
return
o
.
PrintObj
(
info
.
Object
)
return
o
.
PrintObj
(
info
.
Object
,
o
.
out
)
}
}
patched
,
err
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Patch
(
info
.
Namespace
,
info
.
Name
,
types
.
StrategicMergePatchType
,
patch
.
Patch
)
patched
,
err
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Patch
(
info
.
Namespace
,
info
.
Name
,
types
.
StrategicMergePatchType
,
patch
.
Patch
)
...
@@ -225,7 +223,7 @@ func (o *SelectorOptions) RunSelector() error {
...
@@ -225,7 +223,7 @@ func (o *SelectorOptions) RunSelector() error {
}
}
info
.
Refresh
(
patched
,
true
)
info
.
Refresh
(
patched
,
true
)
return
o
.
PrintObj
(
patch
.
Info
.
AsVersioned
())
return
o
.
PrintObj
(
patch
.
Info
.
AsVersioned
()
,
o
.
out
)
})
})
}
}
...
...
pkg/kubectl/cmd/set/set_serviceaccount.go
View file @
01609036
...
@@ -73,7 +73,7 @@ type serviceAccountConfig struct {
...
@@ -73,7 +73,7 @@ type serviceAccountConfig struct {
infos
[]
*
resource
.
Info
infos
[]
*
resource
.
Info
serviceAccountName
string
serviceAccountName
string
PrintObj
func
(
runtime
.
Object
)
error
PrintObj
printers
.
ResourcePrinterFunc
}
}
// NewCmdServiceAccount returns the "set serviceaccount" command.
// NewCmdServiceAccount returns the "set serviceaccount" command.
...
@@ -127,9 +127,7 @@ func (saConfig *serviceAccountConfig) Complete(f cmdutil.Factory, cmd *cobra.Com
...
@@ -127,9 +127,7 @@ func (saConfig *serviceAccountConfig) Complete(f cmdutil.Factory, cmd *cobra.Com
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
saConfig
.
PrintObj
=
func
(
obj
runtime
.
Object
)
error
{
saConfig
.
PrintObj
=
printer
.
PrintObj
return
printer
.
PrintObj
(
obj
,
saConfig
.
out
)
}
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -180,7 +178,7 @@ func (saConfig *serviceAccountConfig) Run() error {
...
@@ -180,7 +178,7 @@ func (saConfig *serviceAccountConfig) Run() error {
continue
continue
}
}
if
saConfig
.
local
||
saConfig
.
dryRun
{
if
saConfig
.
local
||
saConfig
.
dryRun
{
if
err
:=
saConfig
.
PrintObj
(
patch
.
Info
.
AsVersioned
());
err
!=
nil
{
if
err
:=
saConfig
.
PrintObj
(
patch
.
Info
.
AsVersioned
()
,
saConfig
.
out
);
err
!=
nil
{
return
err
return
err
}
}
continue
continue
...
@@ -199,7 +197,7 @@ func (saConfig *serviceAccountConfig) Run() error {
...
@@ -199,7 +197,7 @@ func (saConfig *serviceAccountConfig) Run() error {
}
}
}
}
if
err
:=
saConfig
.
PrintObj
(
info
.
AsVersioned
());
err
!=
nil
{
if
err
:=
saConfig
.
PrintObj
(
info
.
AsVersioned
()
,
saConfig
.
out
);
err
!=
nil
{
return
err
return
err
}
}
}
}
...
...
pkg/kubectl/cmd/set/set_subject.go
View file @
01609036
...
@@ -74,7 +74,7 @@ type SubjectOptions struct {
...
@@ -74,7 +74,7 @@ type SubjectOptions struct {
Groups
[]
string
Groups
[]
string
ServiceAccounts
[]
string
ServiceAccounts
[]
string
PrintObj
func
(
obj
runtime
.
Object
)
error
PrintObj
printers
.
ResourcePrinterFunc
}
}
func
NewCmdSubject
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
errOut
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdSubject
(
f
cmdutil
.
Factory
,
out
io
.
Writer
,
errOut
io
.
Writer
)
*
cobra
.
Command
{
...
@@ -124,9 +124,7 @@ func (o *SubjectOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
...
@@ -124,9 +124,7 @@ func (o *SubjectOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
o
.
PrintObj
=
func
(
obj
runtime
.
Object
)
error
{
o
.
PrintObj
=
printer
.
PrintObj
return
printer
.
PrintObj
(
obj
,
o
.
Out
)
}
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -251,7 +249,7 @@ func (o *SubjectOptions) Run(f cmdutil.Factory, fn updateSubjects) error {
...
@@ -251,7 +249,7 @@ func (o *SubjectOptions) Run(f cmdutil.Factory, fn updateSubjects) error {
}
}
if
o
.
Local
||
o
.
DryRun
{
if
o
.
Local
||
o
.
DryRun
{
if
err
:=
o
.
PrintObj
(
info
.
Object
);
err
!=
nil
{
if
err
:=
o
.
PrintObj
(
info
.
Object
,
o
.
Out
);
err
!=
nil
{
return
err
return
err
}
}
continue
continue
...
@@ -264,7 +262,7 @@ func (o *SubjectOptions) Run(f cmdutil.Factory, fn updateSubjects) error {
...
@@ -264,7 +262,7 @@ func (o *SubjectOptions) Run(f cmdutil.Factory, fn updateSubjects) error {
}
}
info
.
Refresh
(
obj
,
true
)
info
.
Refresh
(
obj
,
true
)
return
o
.
PrintObj
(
info
.
AsVersioned
())
return
o
.
PrintObj
(
info
.
AsVersioned
()
,
o
.
Out
)
}
}
return
utilerrors
.
NewAggregate
(
allErrs
)
return
utilerrors
.
NewAggregate
(
allErrs
)
}
}
...
...
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