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
7b1b107e
Commit
7b1b107e
authored
May 07, 2018
by
juanvallejo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup TODO comments from PrintFlags wiring
parent
a67ccaea
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
205 additions
and
190 deletions
+205
-190
apply.go
pkg/kubectl/cmd/apply.go
+74
-67
BUILD
pkg/kubectl/cmd/create/BUILD
+1
-0
create.go
pkg/kubectl/cmd/create/create.go
+31
-24
create_clusterrolebinding.go
pkg/kubectl/cmd/create/create_clusterrolebinding.go
+6
-6
create_configmap.go
pkg/kubectl/cmd/create/create_configmap.go
+6
-6
create_deployment.go
pkg/kubectl/cmd/create/create_deployment.go
+4
-4
create_deployment_test.go
pkg/kubectl/cmd/create/create_deployment_test.go
+1
-1
create_namespace.go
pkg/kubectl/cmd/create/create_namespace.go
+6
-6
create_pdb.go
pkg/kubectl/cmd/create/create_pdb.go
+6
-6
create_pdb_test.go
pkg/kubectl/cmd/create/create_pdb_test.go
+2
-2
create_priorityclass.go
pkg/kubectl/cmd/create/create_priorityclass.go
+6
-6
create_priorityclass_test.go
pkg/kubectl/cmd/create/create_priorityclass_test.go
+2
-2
create_quota.go
pkg/kubectl/cmd/create/create_quota.go
+6
-6
create_rolebinding.go
pkg/kubectl/cmd/create/create_rolebinding.go
+6
-6
create_secret.go
pkg/kubectl/cmd/create/create_secret.go
+18
-18
create_service.go
pkg/kubectl/cmd/create/create_service.go
+24
-24
create_serviceaccount.go
pkg/kubectl/cmd/create/create_serviceaccount.go
+6
-6
No files found.
pkg/kubectl/cmd/apply.go
View file @
7b1b107e
...
@@ -51,6 +51,7 @@ import (
...
@@ -51,6 +51,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/kubectl/scheme"
"k8s.io/kubernetes/pkg/kubectl/scheme"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
"k8s.io/kubernetes/pkg/kubectl/validation"
"k8s.io/kubernetes/pkg/printers"
"k8s.io/kubernetes/pkg/printers"
)
)
...
@@ -64,15 +65,27 @@ type ApplyOptions struct {
...
@@ -64,15 +65,27 @@ type ApplyOptions struct {
DeleteFlags
*
DeleteFlags
DeleteFlags
*
DeleteFlags
DeleteOptions
*
DeleteOptions
DeleteOptions
*
DeleteOptions
Selector
string
Selector
string
DryRun
bool
DryRun
bool
Prune
bool
Prune
bool
PruneResources
[]
pruneResource
PruneResources
[]
pruneResource
cmdBaseName
string
cmdBaseName
string
All
bool
All
bool
Overwrite
bool
Overwrite
bool
OpenApiPatch
bool
OpenApiPatch
bool
PruneWhitelist
[]
string
PruneWhitelist
[]
string
ShouldIncludeUninitialized
bool
Validator
validation
.
Schema
Builder
*
resource
.
Builder
Mapper
meta
.
RESTMapper
Scaler
scaleclient
.
ScalesGetter
DynamicClient
dynamic
.
DynamicInterface
ClientSetFunc
func
()
(
internalclientset
.
Interface
,
error
)
OpenAPISchema
openapi
.
Resources
Namespace
string
EnforceNamespace
bool
genericclioptions
.
IOStreams
genericclioptions
.
IOStreams
}
}
...
@@ -145,7 +158,7 @@ func NewCmdApply(baseName string, f cmdutil.Factory, ioStreams genericclioptions
...
@@ -145,7 +158,7 @@ func NewCmdApply(baseName string, f cmdutil.Factory, ioStreams genericclioptions
cmdutil
.
CheckErr
(
o
.
Complete
(
f
,
cmd
))
cmdutil
.
CheckErr
(
o
.
Complete
(
f
,
cmd
))
cmdutil
.
CheckErr
(
validateArgs
(
cmd
,
args
))
cmdutil
.
CheckErr
(
validateArgs
(
cmd
,
args
))
cmdutil
.
CheckErr
(
validatePruneAll
(
o
.
Prune
,
o
.
All
,
o
.
Selector
))
cmdutil
.
CheckErr
(
validatePruneAll
(
o
.
Prune
,
o
.
All
,
o
.
Selector
))
cmdutil
.
CheckErr
(
o
.
Run
(
f
,
cmd
))
cmdutil
.
CheckErr
(
o
.
Run
())
},
},
}
}
...
@@ -198,6 +211,32 @@ func (o *ApplyOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
...
@@ -198,6 +211,32 @@ func (o *ApplyOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
}
}
o
.
DeleteOptions
=
o
.
DeleteFlags
.
ToOptions
(
o
.
IOStreams
)
o
.
DeleteOptions
=
o
.
DeleteFlags
.
ToOptions
(
o
.
IOStreams
)
o
.
ShouldIncludeUninitialized
=
cmdutil
.
ShouldIncludeUninitialized
(
cmd
,
o
.
Prune
)
o
.
OpenAPISchema
,
_
=
f
.
OpenAPISchema
()
o
.
ClientSetFunc
=
f
.
ClientSet
o
.
Validator
,
err
=
f
.
Validator
(
cmdutil
.
GetFlagBool
(
cmd
,
"validate"
))
o
.
Builder
=
f
.
NewBuilder
()
o
.
Mapper
,
err
=
f
.
RESTMapper
()
if
err
!=
nil
{
return
err
}
o
.
Scaler
,
err
=
f
.
ScaleClient
()
if
err
!=
nil
{
return
err
}
o
.
DynamicClient
,
err
=
f
.
DynamicClient
()
if
err
!=
nil
{
return
err
}
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
DefaultNamespace
()
if
err
!=
nil
{
return
err
}
return
nil
return
nil
}
}
...
@@ -249,56 +288,37 @@ func parsePruneResources(mapper meta.RESTMapper, gvks []string) ([]pruneResource
...
@@ -249,56 +288,37 @@ func parsePruneResources(mapper meta.RESTMapper, gvks []string) ([]pruneResource
return
pruneResources
,
nil
return
pruneResources
,
nil
}
}
// TODO(juanvallejo): break dependency on factory and cmd
func
(
o
*
ApplyOptions
)
Run
()
error
{
func
(
o
*
ApplyOptions
)
Run
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
)
error
{
schema
,
err
:=
f
.
Validator
(
cmdutil
.
GetFlagBool
(
cmd
,
"validate"
))
if
err
!=
nil
{
return
err
}
var
openapiSchema
openapi
.
Resources
var
openapiSchema
openapi
.
Resources
if
o
.
OpenApiPatch
{
if
o
.
OpenApiPatch
{
openapiSchema
,
err
=
f
.
OpenAPISchema
()
openapiSchema
=
o
.
OpenAPISchema
if
err
!=
nil
{
openapiSchema
=
nil
}
}
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
return
err
}
}
// include the uninitialized objects by default if --prune is true
// include the uninitialized objects by default if --prune is true
// unless explicitly set --include-uninitialized=false
// unless explicitly set --include-uninitialized=false
includeUninitialized
:=
cmdutil
.
ShouldIncludeUninitialized
(
cmd
,
o
.
Prune
)
r
:=
o
.
Builder
.
r
:=
f
.
NewBuilder
()
.
Unstructured
()
.
Unstructured
()
.
Schema
(
schema
)
.
Schema
(
o
.
Validator
)
.
ContinueOnError
()
.
ContinueOnError
()
.
NamespaceParam
(
cmd
Namespace
)
.
DefaultNamespace
()
.
NamespaceParam
(
o
.
Namespace
)
.
DefaultNamespace
()
.
FilenameParam
(
e
nforceNamespace
,
&
o
.
DeleteOptions
.
FilenameOptions
)
.
FilenameParam
(
o
.
E
nforceNamespace
,
&
o
.
DeleteOptions
.
FilenameOptions
)
.
LabelSelectorParam
(
o
.
Selector
)
.
LabelSelectorParam
(
o
.
Selector
)
.
IncludeUninitialized
(
i
ncludeUninitialized
)
.
IncludeUninitialized
(
o
.
ShouldI
ncludeUninitialized
)
.
Flatten
()
.
Flatten
()
.
Do
()
Do
()
if
err
:=
r
.
Err
();
err
!=
nil
{
if
err
:=
r
.
Err
();
err
!=
nil
{
return
err
return
err
}
}
mapper
,
err
:=
f
.
RESTMapper
()
var
err
error
if
err
!=
nil
{
return
err
}
if
o
.
Prune
{
if
o
.
Prune
{
o
.
PruneResources
,
err
=
parsePruneResources
(
m
apper
,
o
.
PruneWhitelist
)
o
.
PruneResources
,
err
=
parsePruneResources
(
o
.
M
apper
,
o
.
PruneWhitelist
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
}
}
output
:=
cmdutil
.
GetFlagString
(
cmd
,
"output"
)
output
:=
*
o
.
PrintFlags
.
OutputFormat
shortOutput
:=
output
==
"name"
shortOutput
:=
output
==
"name"
encoder
:=
scheme
.
DefaultJSONEncoder
()
encoder
:=
scheme
.
DefaultJSONEncoder
()
...
@@ -382,22 +402,15 @@ func (o *ApplyOptions) Run(f cmdutil.Factory, cmd *cobra.Command) error {
...
@@ -382,22 +402,15 @@ func (o *ApplyOptions) Run(f cmdutil.Factory, cmd *cobra.Command) error {
if
_
,
ok
:=
annotationMap
[
api
.
LastAppliedConfigAnnotation
];
!
ok
{
if
_
,
ok
:=
annotationMap
[
api
.
LastAppliedConfigAnnotation
];
!
ok
{
fmt
.
Fprintf
(
o
.
ErrOut
,
warningNoLastAppliedConfigAnnotation
,
o
.
cmdBaseName
)
fmt
.
Fprintf
(
o
.
ErrOut
,
warningNoLastAppliedConfigAnnotation
,
o
.
cmdBaseName
)
}
}
scaler
,
err
:=
f
.
ScaleClient
()
if
err
!=
nil
{
return
err
}
helper
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
helper
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
dynamicClient
,
err
:=
f
.
DynamicClient
()
if
err
!=
nil
{
return
err
}
patcher
:=
&
patcher
{
patcher
:=
&
patcher
{
encoder
:
encoder
,
encoder
:
encoder
,
decoder
:
deserializer
,
decoder
:
deserializer
,
mapping
:
info
.
Mapping
,
mapping
:
info
.
Mapping
,
helper
:
helper
,
helper
:
helper
,
dynamicClient
:
d
ynamicClient
,
dynamicClient
:
o
.
D
ynamicClient
,
clientsetFunc
:
f
.
ClientSet
,
clientsetFunc
:
o
.
ClientSetFunc
,
overwrite
:
o
.
Overwrite
,
overwrite
:
o
.
Overwrite
,
backOff
:
clockwork
.
NewRealClock
(),
backOff
:
clockwork
.
NewRealClock
(),
force
:
o
.
DeleteOptions
.
ForceDeletion
,
force
:
o
.
DeleteOptions
.
ForceDeletion
,
...
@@ -405,7 +418,7 @@ func (o *ApplyOptions) Run(f cmdutil.Factory, cmd *cobra.Command) error {
...
@@ -405,7 +418,7 @@ func (o *ApplyOptions) Run(f cmdutil.Factory, cmd *cobra.Command) error {
timeout
:
o
.
DeleteOptions
.
Timeout
,
timeout
:
o
.
DeleteOptions
.
Timeout
,
gracePeriod
:
o
.
DeleteOptions
.
GracePeriod
,
gracePeriod
:
o
.
DeleteOptions
.
GracePeriod
,
openapiSchema
:
openapiSchema
,
openapiSchema
:
openapiSchema
,
scaleClient
:
s
caler
,
scaleClient
:
o
.
S
caler
,
}
}
patchBytes
,
patchedObject
,
err
:=
patcher
.
patch
(
info
.
Object
,
modified
,
info
.
Source
,
info
.
Namespace
,
info
.
Name
,
o
.
ErrOut
)
patchBytes
,
patchedObject
,
err
:=
patcher
.
patch
(
info
.
Object
,
modified
,
info
.
Source
,
info
.
Namespace
,
info
.
Name
,
o
.
ErrOut
)
...
@@ -479,15 +492,10 @@ func (o *ApplyOptions) Run(f cmdutil.Factory, cmd *cobra.Command) error {
...
@@ -479,15 +492,10 @@ func (o *ApplyOptions) Run(f cmdutil.Factory, cmd *cobra.Command) error {
return
nil
return
nil
}
}
dynamicClient
,
err
:=
f
.
DynamicClient
()
if
err
!=
nil
{
return
err
}
p
:=
pruner
{
p
:=
pruner
{
mapper
:
m
apper
,
mapper
:
o
.
M
apper
,
dynamicClient
:
d
ynamicClient
,
dynamicClient
:
o
.
D
ynamicClient
,
clientsetFunc
:
f
.
ClientSet
,
clientsetFunc
:
o
.
ClientSetFunc
,
labelSelector
:
o
.
Selector
,
labelSelector
:
o
.
Selector
,
visitedUids
:
visitedUids
,
visitedUids
:
visitedUids
,
...
@@ -495,26 +503,27 @@ func (o *ApplyOptions) Run(f cmdutil.Factory, cmd *cobra.Command) error {
...
@@ -495,26 +503,27 @@ func (o *ApplyOptions) Run(f cmdutil.Factory, cmd *cobra.Command) error {
cascade
:
o
.
DeleteOptions
.
Cascade
,
cascade
:
o
.
DeleteOptions
.
Cascade
,
dryRun
:
o
.
DryRun
,
dryRun
:
o
.
DryRun
,
gracePeriod
:
o
.
DeleteOptions
.
GracePeriod
,
gracePeriod
:
o
.
DeleteOptions
.
GracePeriod
,
scaler
:
o
.
Scaler
,
toPrinter
:
o
.
ToPrinter
,
toPrinter
:
o
.
ToPrinter
,
out
:
o
.
Out
,
out
:
o
.
Out
,
}
}
namespacedRESTMappings
,
nonNamespacedRESTMappings
,
err
:=
getRESTMappings
(
m
apper
,
&
(
o
.
PruneResources
))
namespacedRESTMappings
,
nonNamespacedRESTMappings
,
err
:=
getRESTMappings
(
o
.
M
apper
,
&
(
o
.
PruneResources
))
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error retrieving RESTMappings to prune: %v"
,
err
)
return
fmt
.
Errorf
(
"error retrieving RESTMappings to prune: %v"
,
err
)
}
}
for
n
:=
range
visitedNamespaces
{
for
n
:=
range
visitedNamespaces
{
for
_
,
m
:=
range
namespacedRESTMappings
{
for
_
,
m
:=
range
namespacedRESTMappings
{
if
err
:=
p
.
prune
(
f
,
n
,
m
,
i
ncludeUninitialized
);
err
!=
nil
{
if
err
:=
p
.
prune
(
n
,
m
,
o
.
ShouldI
ncludeUninitialized
);
err
!=
nil
{
return
fmt
.
Errorf
(
"error pruning namespaced object %v: %v"
,
m
.
GroupVersionKind
,
err
)
return
fmt
.
Errorf
(
"error pruning namespaced object %v: %v"
,
m
.
GroupVersionKind
,
err
)
}
}
}
}
}
}
for
_
,
m
:=
range
nonNamespacedRESTMappings
{
for
_
,
m
:=
range
nonNamespacedRESTMappings
{
if
err
:=
p
.
prune
(
f
,
metav1
.
NamespaceNone
,
m
,
i
ncludeUninitialized
);
err
!=
nil
{
if
err
:=
p
.
prune
(
metav1
.
NamespaceNone
,
m
,
o
.
ShouldI
ncludeUninitialized
);
err
!=
nil
{
return
fmt
.
Errorf
(
"error pruning nonNamespaced object %v: %v"
,
m
.
GroupVersionKind
,
err
)
return
fmt
.
Errorf
(
"error pruning nonNamespaced object %v: %v"
,
m
.
GroupVersionKind
,
err
)
}
}
}
}
...
@@ -585,12 +594,14 @@ type pruner struct {
...
@@ -585,12 +594,14 @@ type pruner struct {
dryRun
bool
dryRun
bool
gracePeriod
int
gracePeriod
int
scaler
scaleclient
.
ScalesGetter
toPrinter
func
(
string
)
(
printers
.
ResourcePrinterFunc
,
error
)
toPrinter
func
(
string
)
(
printers
.
ResourcePrinterFunc
,
error
)
out
io
.
Writer
out
io
.
Writer
}
}
func
(
p
*
pruner
)
prune
(
f
cmdutil
.
Factory
,
namespace
string
,
mapping
*
meta
.
RESTMapping
,
includeUninitialized
bool
)
error
{
func
(
p
*
pruner
)
prune
(
namespace
string
,
mapping
*
meta
.
RESTMapping
,
includeUninitialized
bool
)
error
{
objList
,
err
:=
p
.
dynamicClient
.
Resource
(
mapping
.
Resource
)
.
objList
,
err
:=
p
.
dynamicClient
.
Resource
(
mapping
.
Resource
)
.
Namespace
(
namespace
)
.
Namespace
(
namespace
)
.
List
(
metav1
.
ListOptions
{
List
(
metav1
.
ListOptions
{
...
@@ -606,10 +617,6 @@ func (p *pruner) prune(f cmdutil.Factory, namespace string, mapping *meta.RESTMa
...
@@ -606,10 +617,6 @@ func (p *pruner) prune(f cmdutil.Factory, namespace string, mapping *meta.RESTMa
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
scaler
,
err
:=
f
.
ScaleClient
()
if
err
!=
nil
{
return
err
}
for
_
,
obj
:=
range
objs
{
for
_
,
obj
:=
range
objs
{
metadata
,
err
:=
meta
.
Accessor
(
obj
)
metadata
,
err
:=
meta
.
Accessor
(
obj
)
...
@@ -627,7 +634,7 @@ func (p *pruner) prune(f cmdutil.Factory, namespace string, mapping *meta.RESTMa
...
@@ -627,7 +634,7 @@ func (p *pruner) prune(f cmdutil.Factory, namespace string, mapping *meta.RESTMa
}
}
name
:=
metadata
.
GetName
()
name
:=
metadata
.
GetName
()
if
!
p
.
dryRun
{
if
!
p
.
dryRun
{
if
err
:=
p
.
delete
(
namespace
,
name
,
mapping
,
scaler
);
err
!=
nil
{
if
err
:=
p
.
delete
(
namespace
,
name
,
mapping
,
p
.
scaler
);
err
!=
nil
{
return
err
return
err
}
}
}
}
...
...
pkg/kubectl/cmd/create/BUILD
View file @
7b1b107e
...
@@ -45,6 +45,7 @@ go_library(
...
@@ -45,6 +45,7 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/client-go/dynamic:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/typed/batch/v1:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/typed/batch/v1:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/typed/rbac/v1:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/typed/rbac/v1:go_default_library",
],
],
...
...
pkg/kubectl/cmd/create/create.go
View file @
7b1b107e
...
@@ -19,19 +19,19 @@ package create
...
@@ -19,19 +19,19 @@ package create
import
(
import
(
"fmt"
"fmt"
"io"
"io"
"net/url"
"os"
"os"
"runtime"
"runtime"
"strings"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"net/url"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
kruntime
"k8s.io/apimachinery/pkg/runtime"
kruntime
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
...
@@ -340,6 +340,12 @@ type CreateSubcommandOptions struct {
...
@@ -340,6 +340,12 @@ type CreateSubcommandOptions struct {
DryRun
bool
DryRun
bool
CreateAnnotation
bool
CreateAnnotation
bool
Namespace
string
EnforceNamespace
bool
Mapper
meta
.
RESTMapper
DynamicClient
dynamic
.
DynamicInterface
PrintObj
func
(
obj
kruntime
.
Object
)
error
PrintObj
func
(
obj
kruntime
.
Object
)
error
genericclioptions
.
IOStreams
genericclioptions
.
IOStreams
...
@@ -352,7 +358,7 @@ func NewCreateSubcommandOptions(ioStreams genericclioptions.IOStreams) *CreateSu
...
@@ -352,7 +358,7 @@ func NewCreateSubcommandOptions(ioStreams genericclioptions.IOStreams) *CreateSu
}
}
}
}
func
(
o
*
CreateSubcommandOptions
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
,
generator
kubectl
.
StructuredGenerator
)
error
{
func
(
o
*
CreateSubcommandOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
,
generator
kubectl
.
StructuredGenerator
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -375,38 +381,43 @@ func (o *CreateSubcommandOptions) Complete(cmd *cobra.Command, args []string, ge
...
@@ -375,38 +381,43 @@ func (o *CreateSubcommandOptions) Complete(cmd *cobra.Command, args []string, ge
return
printer
.
PrintObj
(
obj
,
o
.
Out
)
return
printer
.
PrintObj
(
obj
,
o
.
Out
)
}
}
return
nil
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
DefaultNamespace
()
}
if
err
!=
nil
{
return
err
}
// TODO(juanvallejo): remove dependency on factory here. Complete necessary bits
o
.
DynamicClient
,
err
=
f
.
DynamicClient
()
// from it in the Complete() method.
// RunCreateSubcommand executes a create subcommand using the specified options
func
RunCreateSubcommand
(
f
cmdutil
.
Factory
,
options
*
CreateSubcommandOptions
)
error
{
namespace
,
nsOverriden
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
obj
,
err
:=
options
.
StructuredGenerator
.
StructuredGenerate
()
o
.
Mapper
,
err
=
f
.
RESTMapper
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
mapper
,
err
:=
f
.
RESTMapper
()
return
nil
}
// RunCreateSubcommand executes a create subcommand using the specified options
func
(
o
*
CreateSubcommandOptions
)
Run
()
error
{
obj
,
err
:=
o
.
StructuredGenerator
.
StructuredGenerate
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
!
o
ptions
.
DryRun
{
if
!
o
.
DryRun
{
// create subcommands have compiled knowledge of things they create, so type them directly
// create subcommands have compiled knowledge of things they create, so type them directly
gvks
,
_
,
err
:=
legacyscheme
.
Scheme
.
ObjectKinds
(
obj
)
gvks
,
_
,
err
:=
legacyscheme
.
Scheme
.
ObjectKinds
(
obj
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
gvk
:=
gvks
[
0
]
gvk
:=
gvks
[
0
]
mapping
,
err
:=
m
apper
.
RESTMapping
(
schema
.
GroupKind
{
Group
:
gvk
.
Group
,
Kind
:
gvk
.
Kind
},
gvk
.
Version
)
mapping
,
err
:=
o
.
M
apper
.
RESTMapping
(
schema
.
GroupKind
{
Group
:
gvk
.
Group
,
Kind
:
gvk
.
Kind
},
gvk
.
Version
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
err
:=
kubectl
.
CreateOrUpdateAnnotation
(
o
ptions
.
CreateAnnotation
,
obj
,
cmdutil
.
InternalVersionJSONEncoder
());
err
!=
nil
{
if
err
:=
kubectl
.
CreateOrUpdateAnnotation
(
o
.
CreateAnnotation
,
obj
,
cmdutil
.
InternalVersionJSONEncoder
());
err
!=
nil
{
return
err
return
err
}
}
...
@@ -414,14 +425,10 @@ func RunCreateSubcommand(f cmdutil.Factory, options *CreateSubcommandOptions) er
...
@@ -414,14 +425,10 @@ func RunCreateSubcommand(f cmdutil.Factory, options *CreateSubcommandOptions) er
if
err
:=
legacyscheme
.
Scheme
.
Convert
(
obj
,
asUnstructured
,
nil
);
err
!=
nil
{
if
err
:=
legacyscheme
.
Scheme
.
Convert
(
obj
,
asUnstructured
,
nil
);
err
!=
nil
{
return
err
return
err
}
}
dynamicClient
,
err
:=
f
.
DynamicClient
()
if
err
!=
nil
{
return
err
}
if
mapping
.
Scope
.
Name
()
==
meta
.
RESTScopeNameRoot
{
if
mapping
.
Scope
.
Name
()
==
meta
.
RESTScopeNameRoot
{
n
amespace
=
""
o
.
N
amespace
=
""
}
}
actualObject
,
err
:=
dynamicClient
.
Resource
(
mapping
.
Resource
)
.
Namespace
(
n
amespace
)
.
Create
(
asUnstructured
)
actualObject
,
err
:=
o
.
DynamicClient
.
Resource
(
mapping
.
Resource
)
.
Namespace
(
o
.
N
amespace
)
.
Create
(
asUnstructured
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -429,10 +436,10 @@ func RunCreateSubcommand(f cmdutil.Factory, options *CreateSubcommandOptions) er
...
@@ -429,10 +436,10 @@ func RunCreateSubcommand(f cmdutil.Factory, options *CreateSubcommandOptions) er
// ensure we pass a versioned object to the printer
// ensure we pass a versioned object to the printer
obj
=
actualObject
obj
=
actualObject
}
else
{
}
else
{
if
meta
,
err
:=
meta
.
Accessor
(
obj
);
err
==
nil
&&
nsOverriden
{
if
meta
,
err
:=
meta
.
Accessor
(
obj
);
err
==
nil
&&
o
.
EnforceNamespace
{
meta
.
SetNamespace
(
n
amespace
)
meta
.
SetNamespace
(
o
.
N
amespace
)
}
}
}
}
return
o
ptions
.
PrintObj
(
obj
)
return
o
.
PrintObj
(
obj
)
}
}
pkg/kubectl/cmd/create/create_clusterrolebinding.go
View file @
7b1b107e
...
@@ -52,8 +52,8 @@ func NewCmdCreateClusterRoleBinding(f cmdutil.Factory, ioStreams genericclioptio
...
@@ -52,8 +52,8 @@ func NewCmdCreateClusterRoleBinding(f cmdutil.Factory, ioStreams genericclioptio
Long
:
clusterRoleBindingLong
,
Long
:
clusterRoleBindingLong
,
Example
:
clusterRoleBindingExample
,
Example
:
clusterRoleBindingExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -70,7 +70,7 @@ func NewCmdCreateClusterRoleBinding(f cmdutil.Factory, ioStreams genericclioptio
...
@@ -70,7 +70,7 @@ func NewCmdCreateClusterRoleBinding(f cmdutil.Factory, ioStreams genericclioptio
return
cmd
return
cmd
}
}
func
(
o
*
ClusterRoleBindingOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
ClusterRoleBindingOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -90,10 +90,10 @@ func (o *ClusterRoleBindingOpts) Complete(cmd *cobra.Command, args []string) err
...
@@ -90,10 +90,10 @@ func (o *ClusterRoleBindingOpts) Complete(cmd *cobra.Command, args []string) err
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreateClusterRoleBinding is the implementation of the create clusterrolebinding command.
// CreateClusterRoleBinding is the implementation of the create clusterrolebinding command.
func
(
o
*
ClusterRoleBindingOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
ClusterRoleBindingOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
pkg/kubectl/cmd/create/create_configmap.go
View file @
7b1b107e
...
@@ -74,8 +74,8 @@ func NewCmdCreateConfigMap(f cmdutil.Factory, ioStreams genericclioptions.IOStre
...
@@ -74,8 +74,8 @@ func NewCmdCreateConfigMap(f cmdutil.Factory, ioStreams genericclioptions.IOStre
Long
:
configMapLong
,
Long
:
configMapLong
,
Example
:
configMapExample
,
Example
:
configMapExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -91,7 +91,7 @@ func NewCmdCreateConfigMap(f cmdutil.Factory, ioStreams genericclioptions.IOStre
...
@@ -91,7 +91,7 @@ func NewCmdCreateConfigMap(f cmdutil.Factory, ioStreams genericclioptions.IOStre
return
cmd
return
cmd
}
}
func
(
o
*
ConfigMapOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
ConfigMapOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -111,10 +111,10 @@ func (o *ConfigMapOpts) Complete(cmd *cobra.Command, args []string) error {
...
@@ -111,10 +111,10 @@ func (o *ConfigMapOpts) Complete(cmd *cobra.Command, args []string) error {
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreateConfigMap is the implementation of the create configmap command.
// CreateConfigMap is the implementation of the create configmap command.
func
(
o
*
ConfigMapOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
ConfigMapOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
pkg/kubectl/cmd/create/create_deployment.go
View file @
7b1b107e
...
@@ -56,7 +56,7 @@ func NewCmdCreateDeployment(f cmdutil.Factory, ioStreams genericclioptions.IOStr
...
@@ -56,7 +56,7 @@ func NewCmdCreateDeployment(f cmdutil.Factory, ioStreams genericclioptions.IOStr
Example
:
deploymentExample
,
Example
:
deploymentExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -143,13 +143,13 @@ func (o *DeploymentOpts) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
...
@@ -143,13 +143,13 @@ func (o *DeploymentOpts) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// createDeployment
// createDeployment
// 1. Reads user config values from Cobra.
// 1. Reads user config values from Cobra.
// 2. Sets up the correct Generator object.
// 2. Sets up the correct Generator object.
// 3. Calls RunCreateSubcommand.
// 3. Calls RunCreateSubcommand.
func
(
o
*
DeploymentOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
DeploymentOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
pkg/kubectl/cmd/create/create_deployment_test.go
View file @
7b1b107e
...
@@ -153,6 +153,6 @@ func TestCreateDeploymentNoImage(t *testing.T) {
...
@@ -153,6 +153,6 @@ func TestCreateDeploymentNoImage(t *testing.T) {
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
err
=
options
.
Run
(
tf
)
err
=
options
.
Run
()
assert
.
Error
(
t
,
err
,
"at least one image must be specified"
)
assert
.
Error
(
t
,
err
,
"at least one image must be specified"
)
}
}
pkg/kubectl/cmd/create/create_namespace.go
View file @
7b1b107e
...
@@ -53,8 +53,8 @@ func NewCmdCreateNamespace(f cmdutil.Factory, ioStreams genericclioptions.IOStre
...
@@ -53,8 +53,8 @@ func NewCmdCreateNamespace(f cmdutil.Factory, ioStreams genericclioptions.IOStre
Long
:
namespaceLong
,
Long
:
namespaceLong
,
Example
:
namespaceExample
,
Example
:
namespaceExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -67,7 +67,7 @@ func NewCmdCreateNamespace(f cmdutil.Factory, ioStreams genericclioptions.IOStre
...
@@ -67,7 +67,7 @@ func NewCmdCreateNamespace(f cmdutil.Factory, ioStreams genericclioptions.IOStre
return
cmd
return
cmd
}
}
func
(
o
*
NamespaceOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
NamespaceOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -81,10 +81,10 @@ func (o *NamespaceOpts) Complete(cmd *cobra.Command, args []string) error {
...
@@ -81,10 +81,10 @@ func (o *NamespaceOpts) Complete(cmd *cobra.Command, args []string) error {
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreateNamespace implements the behavior to run the create namespace command
// CreateNamespace implements the behavior to run the create namespace command
func
(
o
*
NamespaceOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
NamespaceOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
pkg/kubectl/cmd/create/create_pdb.go
View file @
7b1b107e
...
@@ -58,8 +58,8 @@ func NewCmdCreatePodDisruptionBudget(f cmdutil.Factory, ioStreams genericcliopti
...
@@ -58,8 +58,8 @@ func NewCmdCreatePodDisruptionBudget(f cmdutil.Factory, ioStreams genericcliopti
Long
:
pdbLong
,
Long
:
pdbLong
,
Example
:
pdbExample
,
Example
:
pdbExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -75,7 +75,7 @@ func NewCmdCreatePodDisruptionBudget(f cmdutil.Factory, ioStreams genericcliopti
...
@@ -75,7 +75,7 @@ func NewCmdCreatePodDisruptionBudget(f cmdutil.Factory, ioStreams genericcliopti
return
cmd
return
cmd
}
}
func
(
o
*
PodDisruptionBudgetOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
PodDisruptionBudgetOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -100,10 +100,10 @@ func (o *PodDisruptionBudgetOpts) Complete(cmd *cobra.Command, args []string) er
...
@@ -100,10 +100,10 @@ func (o *PodDisruptionBudgetOpts) Complete(cmd *cobra.Command, args []string) er
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreatePodDisruptionBudget implements the behavior to run the create pdb command.
// CreatePodDisruptionBudget implements the behavior to run the create pdb command.
func
(
o
*
PodDisruptionBudgetOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
PodDisruptionBudgetOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
pkg/kubectl/cmd/create/create_pdb_test.go
View file @
7b1b107e
...
@@ -69,12 +69,12 @@ func TestCreatePdb(t *testing.T) {
...
@@ -69,12 +69,12 @@ func TestCreatePdb(t *testing.T) {
IOStreams
:
ioStreams
,
IOStreams
:
ioStreams
,
},
},
}
}
err
:=
options
.
Complete
(
cmd
,
[]
string
{
pdbName
})
err
:=
options
.
Complete
(
tf
,
cmd
,
[]
string
{
pdbName
})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
err
=
options
.
Run
(
tf
)
err
=
options
.
Run
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
...
pkg/kubectl/cmd/create/create_priorityclass.go
View file @
7b1b107e
...
@@ -56,8 +56,8 @@ func NewCmdCreatePriorityClass(f cmdutil.Factory, ioStreams genericclioptions.IO
...
@@ -56,8 +56,8 @@ func NewCmdCreatePriorityClass(f cmdutil.Factory, ioStreams genericclioptions.IO
Long
:
pcLong
,
Long
:
pcLong
,
Example
:
pcExample
,
Example
:
pcExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -73,7 +73,7 @@ func NewCmdCreatePriorityClass(f cmdutil.Factory, ioStreams genericclioptions.IO
...
@@ -73,7 +73,7 @@ func NewCmdCreatePriorityClass(f cmdutil.Factory, ioStreams genericclioptions.IO
return
cmd
return
cmd
}
}
func
(
o
*
PriorityClassOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
PriorityClassOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -92,10 +92,10 @@ func (o *PriorityClassOpts) Complete(cmd *cobra.Command, args []string) error {
...
@@ -92,10 +92,10 @@ func (o *PriorityClassOpts) Complete(cmd *cobra.Command, args []string) error {
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreatePriorityClass implements the behavior to run the create priorityClass command.
// CreatePriorityClass implements the behavior to run the create priorityClass command.
func
(
o
*
PriorityClassOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
PriorityClassOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
pkg/kubectl/cmd/create/create_priorityclass_test.go
View file @
7b1b107e
...
@@ -69,12 +69,12 @@ func TestCreatePriorityClass(t *testing.T) {
...
@@ -69,12 +69,12 @@ func TestCreatePriorityClass(t *testing.T) {
IOStreams
:
ioStreams
,
IOStreams
:
ioStreams
,
},
},
}
}
err
:=
options
.
Complete
(
cmd
,
[]
string
{
pcName
})
err
:=
options
.
Complete
(
tf
,
cmd
,
[]
string
{
pcName
})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
err
=
options
.
Run
(
tf
)
err
=
options
.
Run
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
...
pkg/kubectl/cmd/create/create_quota.go
View file @
7b1b107e
...
@@ -56,8 +56,8 @@ func NewCmdCreateQuota(f cmdutil.Factory, ioStreams genericclioptions.IOStreams)
...
@@ -56,8 +56,8 @@ func NewCmdCreateQuota(f cmdutil.Factory, ioStreams genericclioptions.IOStreams)
Long
:
quotaLong
,
Long
:
quotaLong
,
Example
:
quotaExample
,
Example
:
quotaExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -71,7 +71,7 @@ func NewCmdCreateQuota(f cmdutil.Factory, ioStreams genericclioptions.IOStreams)
...
@@ -71,7 +71,7 @@ func NewCmdCreateQuota(f cmdutil.Factory, ioStreams genericclioptions.IOStreams)
return
cmd
return
cmd
}
}
func
(
o
*
QuotaOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
QuotaOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -89,10 +89,10 @@ func (o *QuotaOpts) Complete(cmd *cobra.Command, args []string) error {
...
@@ -89,10 +89,10 @@ func (o *QuotaOpts) Complete(cmd *cobra.Command, args []string) error {
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreateQuota implements the behavior to run the create quota command
// CreateQuota implements the behavior to run the create quota command
func
(
o
*
QuotaOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
QuotaOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
pkg/kubectl/cmd/create/create_rolebinding.go
View file @
7b1b107e
...
@@ -52,8 +52,8 @@ func NewCmdCreateRoleBinding(f cmdutil.Factory, ioStreams genericclioptions.IOSt
...
@@ -52,8 +52,8 @@ func NewCmdCreateRoleBinding(f cmdutil.Factory, ioStreams genericclioptions.IOSt
Long
:
roleBindingLong
,
Long
:
roleBindingLong
,
Example
:
roleBindingExample
,
Example
:
roleBindingExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -70,7 +70,7 @@ func NewCmdCreateRoleBinding(f cmdutil.Factory, ioStreams genericclioptions.IOSt
...
@@ -70,7 +70,7 @@ func NewCmdCreateRoleBinding(f cmdutil.Factory, ioStreams genericclioptions.IOSt
return
cmd
return
cmd
}
}
func
(
o
*
RoleBindingOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
RoleBindingOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -91,9 +91,9 @@ func (o *RoleBindingOpts) Complete(cmd *cobra.Command, args []string) error {
...
@@ -91,9 +91,9 @@ func (o *RoleBindingOpts) Complete(cmd *cobra.Command, args []string) error {
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
func
(
o
*
RoleBindingOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
RoleBindingOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
pkg/kubectl/cmd/create/create_secret.go
View file @
7b1b107e
...
@@ -89,8 +89,8 @@ func NewCmdCreateSecretGeneric(f cmdutil.Factory, ioStreams genericclioptions.IO
...
@@ -89,8 +89,8 @@ func NewCmdCreateSecretGeneric(f cmdutil.Factory, ioStreams genericclioptions.IO
Long
:
secretLong
,
Long
:
secretLong
,
Example
:
secretExample
,
Example
:
secretExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -107,7 +107,7 @@ func NewCmdCreateSecretGeneric(f cmdutil.Factory, ioStreams genericclioptions.IO
...
@@ -107,7 +107,7 @@ func NewCmdCreateSecretGeneric(f cmdutil.Factory, ioStreams genericclioptions.IO
return
cmd
return
cmd
}
}
func
(
o
*
SecretGenericOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
SecretGenericOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -128,12 +128,12 @@ func (o *SecretGenericOpts) Complete(cmd *cobra.Command, args []string) error {
...
@@ -128,12 +128,12 @@ func (o *SecretGenericOpts) Complete(cmd *cobra.Command, args []string) error {
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreateSecretGeneric is the implementation of the create secret generic command
// CreateSecretGeneric is the implementation of the create secret generic command
func
(
o
*
SecretGenericOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
SecretGenericOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
var
(
var
(
...
@@ -174,8 +174,8 @@ func NewCmdCreateSecretDockerRegistry(f cmdutil.Factory, ioStreams genericcliopt
...
@@ -174,8 +174,8 @@ func NewCmdCreateSecretDockerRegistry(f cmdutil.Factory, ioStreams genericcliopt
Long
:
secretForDockerRegistryLong
,
Long
:
secretForDockerRegistryLong
,
Example
:
secretForDockerRegistryExample
,
Example
:
secretForDockerRegistryExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -196,7 +196,7 @@ func NewCmdCreateSecretDockerRegistry(f cmdutil.Factory, ioStreams genericcliopt
...
@@ -196,7 +196,7 @@ func NewCmdCreateSecretDockerRegistry(f cmdutil.Factory, ioStreams genericcliopt
return
cmd
return
cmd
}
}
func
(
o
*
SecretDockerRegistryOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
SecretDockerRegistryOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -228,12 +228,12 @@ func (o *SecretDockerRegistryOpts) Complete(cmd *cobra.Command, args []string) e
...
@@ -228,12 +228,12 @@ func (o *SecretDockerRegistryOpts) Complete(cmd *cobra.Command, args []string) e
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreateSecretDockerRegistry is the implementation of the create secret docker-registry command
// CreateSecretDockerRegistry is the implementation of the create secret docker-registry command
func
(
o
*
SecretDockerRegistryOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
SecretDockerRegistryOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
var
(
var
(
...
@@ -265,8 +265,8 @@ func NewCmdCreateSecretTLS(f cmdutil.Factory, ioStreams genericclioptions.IOStre
...
@@ -265,8 +265,8 @@ func NewCmdCreateSecretTLS(f cmdutil.Factory, ioStreams genericclioptions.IOStre
Long
:
secretForTLSLong
,
Long
:
secretForTLSLong
,
Example
:
secretForTLSExample
,
Example
:
secretForTLSExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -281,7 +281,7 @@ func NewCmdCreateSecretTLS(f cmdutil.Factory, ioStreams genericclioptions.IOStre
...
@@ -281,7 +281,7 @@ func NewCmdCreateSecretTLS(f cmdutil.Factory, ioStreams genericclioptions.IOStre
return
cmd
return
cmd
}
}
func
(
o
*
SecretTLSOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
SecretTLSOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -306,10 +306,10 @@ func (o *SecretTLSOpts) Complete(cmd *cobra.Command, args []string) error {
...
@@ -306,10 +306,10 @@ func (o *SecretTLSOpts) Complete(cmd *cobra.Command, args []string) error {
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreateSecretTLS is the implementation of the create secret tls command
// CreateSecretTLS is the implementation of the create secret tls command
func
(
o
*
SecretTLSOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
SecretTLSOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
pkg/kubectl/cmd/create/create_service.go
View file @
7b1b107e
...
@@ -77,8 +77,8 @@ func NewCmdCreateServiceClusterIP(f cmdutil.Factory, ioStreams genericclioptions
...
@@ -77,8 +77,8 @@ func NewCmdCreateServiceClusterIP(f cmdutil.Factory, ioStreams genericclioptions
Long
:
serviceClusterIPLong
,
Long
:
serviceClusterIPLong
,
Example
:
serviceClusterIPExample
,
Example
:
serviceClusterIPExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -96,7 +96,7 @@ func errUnsupportedGenerator(cmd *cobra.Command, generatorName string) error {
...
@@ -96,7 +96,7 @@ func errUnsupportedGenerator(cmd *cobra.Command, generatorName string) error {
return
cmdutil
.
UsageErrorf
(
cmd
,
"Generator %s not supported. "
,
generatorName
)
return
cmdutil
.
UsageErrorf
(
cmd
,
"Generator %s not supported. "
,
generatorName
)
}
}
func
(
o
*
ServiceClusterIPOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
ServiceClusterIPOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -115,12 +115,12 @@ func (o *ServiceClusterIPOpts) Complete(cmd *cobra.Command, args []string) error
...
@@ -115,12 +115,12 @@ func (o *ServiceClusterIPOpts) Complete(cmd *cobra.Command, args []string) error
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreateServiceClusterIP is the implementation of the create service clusterip command
// CreateServiceClusterIP is the implementation of the create service clusterip command
func
(
o
*
ServiceClusterIPOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
ServiceClusterIPOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
var
(
var
(
...
@@ -149,8 +149,8 @@ func NewCmdCreateServiceNodePort(f cmdutil.Factory, ioStreams genericclioptions.
...
@@ -149,8 +149,8 @@ func NewCmdCreateServiceNodePort(f cmdutil.Factory, ioStreams genericclioptions.
Long
:
serviceNodePortLong
,
Long
:
serviceNodePortLong
,
Example
:
serviceNodePortExample
,
Example
:
serviceNodePortExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -164,7 +164,7 @@ func NewCmdCreateServiceNodePort(f cmdutil.Factory, ioStreams genericclioptions.
...
@@ -164,7 +164,7 @@ func NewCmdCreateServiceNodePort(f cmdutil.Factory, ioStreams genericclioptions.
return
cmd
return
cmd
}
}
func
(
o
*
ServiceNodePortOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
ServiceNodePortOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -184,12 +184,12 @@ func (o *ServiceNodePortOpts) Complete(cmd *cobra.Command, args []string) error
...
@@ -184,12 +184,12 @@ func (o *ServiceNodePortOpts) Complete(cmd *cobra.Command, args []string) error
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreateServiceNodePort is the implementation of the create service nodeport command
// CreateServiceNodePort is the implementation of the create service nodeport command
func
(
o
*
ServiceNodePortOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
ServiceNodePortOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
var
(
var
(
...
@@ -218,8 +218,8 @@ func NewCmdCreateServiceLoadBalancer(f cmdutil.Factory, ioStreams genericcliopti
...
@@ -218,8 +218,8 @@ func NewCmdCreateServiceLoadBalancer(f cmdutil.Factory, ioStreams genericcliopti
Long
:
serviceLoadBalancerLong
,
Long
:
serviceLoadBalancerLong
,
Example
:
serviceLoadBalancerExample
,
Example
:
serviceLoadBalancerExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -232,7 +232,7 @@ func NewCmdCreateServiceLoadBalancer(f cmdutil.Factory, ioStreams genericcliopti
...
@@ -232,7 +232,7 @@ func NewCmdCreateServiceLoadBalancer(f cmdutil.Factory, ioStreams genericcliopti
return
cmd
return
cmd
}
}
func
(
o
*
ServiceLoadBalancerOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
ServiceLoadBalancerOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -251,12 +251,12 @@ func (o *ServiceLoadBalancerOpts) Complete(cmd *cobra.Command, args []string) er
...
@@ -251,12 +251,12 @@ func (o *ServiceLoadBalancerOpts) Complete(cmd *cobra.Command, args []string) er
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreateServiceLoadBalancer is the implementation of the create service loadbalancer command
// CreateServiceLoadBalancer is the implementation of the create service loadbalancer command
func
(
o
*
ServiceLoadBalancerOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
ServiceLoadBalancerOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
var
(
var
(
...
@@ -289,8 +289,8 @@ func NewCmdCreateServiceExternalName(f cmdutil.Factory, ioStreams genericcliopti
...
@@ -289,8 +289,8 @@ func NewCmdCreateServiceExternalName(f cmdutil.Factory, ioStreams genericcliopti
Long
:
serviceExternalNameLong
,
Long
:
serviceExternalNameLong
,
Example
:
serviceExternalNameExample
,
Example
:
serviceExternalNameExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -305,7 +305,7 @@ func NewCmdCreateServiceExternalName(f cmdutil.Factory, ioStreams genericcliopti
...
@@ -305,7 +305,7 @@ func NewCmdCreateServiceExternalName(f cmdutil.Factory, ioStreams genericcliopti
return
cmd
return
cmd
}
}
func
(
o
*
ServiceExternalNameOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
ServiceExternalNameOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -324,10 +324,10 @@ func (o *ServiceExternalNameOpts) Complete(cmd *cobra.Command, args []string) er
...
@@ -324,10 +324,10 @@ func (o *ServiceExternalNameOpts) Complete(cmd *cobra.Command, args []string) er
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreateExternalNameService is the implementation of the create service externalname command
// CreateExternalNameService is the implementation of the create service externalname command
func
(
o
*
ServiceExternalNameOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
ServiceExternalNameOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
pkg/kubectl/cmd/create/create_serviceaccount.go
View file @
7b1b107e
...
@@ -53,8 +53,8 @@ func NewCmdCreateServiceAccount(f cmdutil.Factory, ioStreams genericclioptions.I
...
@@ -53,8 +53,8 @@ func NewCmdCreateServiceAccount(f cmdutil.Factory, ioStreams genericclioptions.I
Long
:
serviceAccountLong
,
Long
:
serviceAccountLong
,
Example
:
serviceAccountExample
,
Example
:
serviceAccountExample
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
options
.
Complete
(
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
options
.
Run
(
f
))
cmdutil
.
CheckErr
(
options
.
Run
())
},
},
}
}
...
@@ -66,7 +66,7 @@ func NewCmdCreateServiceAccount(f cmdutil.Factory, ioStreams genericclioptions.I
...
@@ -66,7 +66,7 @@ func NewCmdCreateServiceAccount(f cmdutil.Factory, ioStreams genericclioptions.I
return
cmd
return
cmd
}
}
func
(
o
*
ServiceAccountOpts
)
Complete
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
ServiceAccountOpts
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
name
,
err
:=
NameFromCommandArgs
(
cmd
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -80,10 +80,10 @@ func (o *ServiceAccountOpts) Complete(cmd *cobra.Command, args []string) error {
...
@@ -80,10 +80,10 @@ func (o *ServiceAccountOpts) Complete(cmd *cobra.Command, args []string) error {
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
return
errUnsupportedGenerator
(
cmd
,
generatorName
)
}
}
return
o
.
CreateSubcommandOptions
.
Complete
(
cmd
,
args
,
generator
)
return
o
.
CreateSubcommandOptions
.
Complete
(
f
,
cmd
,
args
,
generator
)
}
}
// CreateServiceAccount implements the behavior to run the create service account command
// CreateServiceAccount implements the behavior to run the create service account command
func
(
o
*
ServiceAccountOpts
)
Run
(
f
cmdutil
.
Factory
)
error
{
func
(
o
*
ServiceAccountOpts
)
Run
()
error
{
return
RunCreateSubcommand
(
f
,
o
.
CreateSubcommandOptions
)
return
o
.
CreateSubcommandOptions
.
Run
(
)
}
}
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