mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-18 16:21:13 +00:00
Merge pull request #63511 from juanvallejo/jvallejo/cmd-cleanup
Automatic merge from submit-queue (batch tested with PRs 63669, 63511, 63561, 63289). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. cleanup TODOs from PrintFlags wiring **Release note**: ```release-note NONE ``` Address TODOs from PrintFlags wiring cc @soltysh @deads2k
This commit is contained in:
commit
4868d7775a
@ -52,6 +52,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource"
|
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -65,15 +66,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
|
||||||
}
|
}
|
||||||
@ -146,7 +159,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())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +212,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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,56 +289,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(cmdNamespace).DefaultNamespace().
|
NamespaceParam(o.Namespace).DefaultNamespace().
|
||||||
FilenameParam(enforceNamespace, &o.DeleteOptions.FilenameOptions).
|
FilenameParam(o.EnforceNamespace, &o.DeleteOptions.FilenameOptions).
|
||||||
LabelSelectorParam(o.Selector).
|
LabelSelectorParam(o.Selector).
|
||||||
IncludeUninitialized(includeUninitialized).
|
IncludeUninitialized(o.ShouldIncludeUninitialized).
|
||||||
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(mapper, o.PruneWhitelist)
|
o.PruneResources, err = parsePruneResources(o.Mapper, 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"
|
||||||
|
|
||||||
visitedUids := sets.NewString()
|
visitedUids := sets.NewString()
|
||||||
@ -380,20 +400,13 @@ 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{
|
||||||
mapping: info.Mapping,
|
mapping: info.Mapping,
|
||||||
helper: helper,
|
helper: helper,
|
||||||
dynamicClient: dynamicClient,
|
dynamicClient: o.DynamicClient,
|
||||||
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,
|
||||||
@ -401,7 +414,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: scaler,
|
scaleClient: o.Scaler,
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
@ -475,15 +488,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: mapper,
|
mapper: o.Mapper,
|
||||||
dynamicClient: dynamicClient,
|
dynamicClient: o.DynamicClient,
|
||||||
clientsetFunc: f.ClientSet,
|
clientsetFunc: o.ClientSetFunc,
|
||||||
|
|
||||||
labelSelector: o.Selector,
|
labelSelector: o.Selector,
|
||||||
visitedUids: visitedUids,
|
visitedUids: visitedUids,
|
||||||
@ -491,26 +499,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(mapper, &(o.PruneResources))
|
namespacedRESTMappings, nonNamespacedRESTMappings, err := getRESTMappings(o.Mapper, &(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, includeUninitialized); err != nil {
|
if err := p.prune(n, m, o.ShouldIncludeUninitialized); 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, includeUninitialized); err != nil {
|
if err := p.prune(metav1.NamespaceNone, m, o.ShouldIncludeUninitialized); 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -581,12 +590,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{
|
||||||
@ -602,10 +613,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)
|
||||||
@ -623,7 +630,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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",
|
||||||
],
|
],
|
||||||
|
@ -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 {
|
|||||||
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
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|||||||
return printer.PrintObj(obj, o.Out)
|
return printer.PrintObj(obj, o.Out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
o.Namespace, o.EnforceNamespace, err = f.DefaultNamespace()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
o.DynamicClient, err = f.DynamicClient()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
o.Mapper, err = f.RESTMapper()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(juanvallejo): remove dependency on factory here. Complete necessary bits
|
|
||||||
// from it in the Complete() method.
|
|
||||||
// RunCreateSubcommand executes a create subcommand using the specified options
|
// RunCreateSubcommand executes a create subcommand using the specified options
|
||||||
func RunCreateSubcommand(f cmdutil.Factory, options *CreateSubcommandOptions) error {
|
func (o *CreateSubcommandOptions) Run() error {
|
||||||
namespace, nsOverriden, err := f.DefaultNamespace()
|
obj, err := o.StructuredGenerator.StructuredGenerate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
obj, err := options.StructuredGenerator.StructuredGenerate()
|
if !o.DryRun {
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
mapper, err := f.RESTMapper()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if !options.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 := mapper.RESTMapping(schema.GroupKind{Group: gvk.Group, Kind: gvk.Kind}, gvk.Version)
|
mapping, err := o.Mapper.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(options.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
|
|||||||
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 {
|
||||||
namespace = ""
|
o.Namespace = ""
|
||||||
}
|
}
|
||||||
actualObject, err := dynamicClient.Resource(mapping.Resource).Namespace(namespace).Create(asUnstructured)
|
actualObject, err := o.DynamicClient.Resource(mapping.Resource).Namespace(o.Namespace).Create(asUnstructured)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -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(namespace)
|
meta.SetNamespace(o.Namespace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return options.PrintObj(obj)
|
return o.PrintObj(obj)
|
||||||
}
|
}
|
||||||
|
@ -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
|
|||||||
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
|
|||||||
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()
|
||||||
}
|
}
|
||||||
|
@ -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
|
|||||||
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 {
|
|||||||
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()
|
||||||
}
|
}
|
||||||
|
@ -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 []
|
|||||||
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()
|
||||||
}
|
}
|
||||||
|
@ -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")
|
||||||
}
|
}
|
||||||
|
@ -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
|
|||||||
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 {
|
|||||||
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()
|
||||||
}
|
}
|
||||||
|
@ -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
|
|||||||
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
|
|||||||
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()
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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
|
|||||||
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 {
|
|||||||
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()
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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)
|
|||||||
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 {
|
|||||||
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()
|
||||||
}
|
}
|
||||||
|
@ -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
|
|||||||
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 {
|
|||||||
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()
|
||||||
}
|
}
|
||||||
|
@ -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
|
|||||||
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 {
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
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 {
|
|||||||
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()
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
|||||||
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
|
|||||||
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.
|
|||||||
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.
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
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()
|
||||||
}
|
}
|
||||||
|
@ -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
|
|||||||
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 {
|
|||||||
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()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user