Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact kubectl Factory make it interface #33180

Merged
merged 3 commits into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/kubernetes/pkg/util/flag"
)

func NewKubeadmCommand(f *cmdutil.Factory, in io.Reader, out, err io.Writer) *cobra.Command {
func NewKubeadmCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cobra.Command {
cmds := &cobra.Command{
Use: "kubeadm",
Short: "kubeadm: easily bootstrap a secure Kubernetes cluster.",
Expand Down
8 changes: 4 additions & 4 deletions pkg/kubectl/cmd/annotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type AnnotateOptions struct {
newAnnotations map[string]string
removeAnnotations []string

// Common shared fields
// Common share fields
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shared is correct here

out io.Writer
}

Expand Down Expand Up @@ -91,7 +91,7 @@ var (
kubectl annotate pods foo description-`)
)

func NewCmdAnnotate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
func NewCmdAnnotate(f cmdutil.Factory, out io.Writer) *cobra.Command {
options := &AnnotateOptions{}

// retrieve a list of handled resources from printer as valid args
Expand Down Expand Up @@ -138,7 +138,7 @@ func NewCmdAnnotate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
}

// Complete adapts from the command line args and factory to the data required.
func (o *AnnotateOptions) Complete(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) (err error) {
func (o *AnnotateOptions) Complete(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) (err error) {
o.out = out
o.local = cmdutil.GetFlagBool(cmd, "local")
o.overwrite = cmdutil.GetFlagBool(cmd, "overwrite")
Expand Down Expand Up @@ -172,7 +172,7 @@ func (o AnnotateOptions) Validate() error {
}

// RunAnnotate does the work
func (o AnnotateOptions) RunAnnotate(f *cmdutil.Factory, cmd *cobra.Command) error {
func (o AnnotateOptions) RunAnnotate(f cmdutil.Factory, cmd *cobra.Command) error {
namespace, enforceNamespace, err := f.DefaultNamespace()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/apiversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
)

func NewCmdApiVersions(f *cmdutil.Factory, out io.Writer) *cobra.Command {
func NewCmdApiVersions(f cmdutil.Factory, out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "api-versions",
// apiversions is deprecated.
Expand All @@ -42,7 +42,7 @@ func NewCmdApiVersions(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return cmd
}

func RunApiVersions(f *cmdutil.Factory, w io.Writer) error {
func RunApiVersions(f cmdutil.Factory, w io.Writer) error {
if len(os.Args) > 1 && os.Args[1] == "apiversions" {
printDeprecationWarning("api-versions", "apiversions")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var (
cat pod.json | kubectl apply -f -`)
)

func NewCmdApply(f *cmdutil.Factory, out io.Writer) *cobra.Command {
func NewCmdApply(f cmdutil.Factory, out io.Writer) *cobra.Command {
var options ApplyOptions

cmd := &cobra.Command{
Expand Down Expand Up @@ -122,7 +122,7 @@ func validatePruneAll(prune, all bool, selector string) error {
return nil
}

func RunApply(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, options *ApplyOptions) error {
func RunApply(f cmdutil.Factory, cmd *cobra.Command, out io.Writer, options *ApplyOptions) error {
shortOutput := cmdutil.GetFlagString(cmd, "output") == "name"
schema, err := f.Validator(cmdutil.GetFlagBool(cmd, "validate"), cmdutil.GetFlagString(cmd, "schema-cache-dir"))
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var (
kubectl attach 123456-7890 -c ruby-container -i -t`)
)

func NewCmdAttach(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.Command {
func NewCmdAttach(f cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.Command {
options := &AttachOptions{
StreamOptions: StreamOptions{
In: cmdIn,
Expand Down Expand Up @@ -113,7 +113,7 @@ type AttachOptions struct {
}

// Complete verifies command line arguments and loads data from the command environment
func (p *AttachOptions) Complete(f *cmdutil.Factory, cmd *cobra.Command, argsIn []string) error {
func (p *AttachOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, argsIn []string) error {
if len(argsIn) == 0 {
return cmdutil.UsageError(cmd, "POD is required for attach")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/autoscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var (
kubectl autoscale rc foo --max=5 --cpu-percent=80`)
)

func NewCmdAutoscale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
func NewCmdAutoscale(f cmdutil.Factory, out io.Writer) *cobra.Command {
options := &resource.FilenameOptions{}

validArgs := []string{"deployment", "replicaset", "replicationcontroller"}
Expand Down Expand Up @@ -79,7 +79,7 @@ func NewCmdAutoscale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return cmd
}

func RunAutoscale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string, options *resource.FilenameOptions) error {
func RunAutoscale(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string, options *resource.FilenameOptions) error {
namespace, enforceNamespace, err := f.DefaultNamespace()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/clusterinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
var longDescr = `Display addresses of the master and services with label kubernetes.io/cluster-service=true
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.`

func NewCmdClusterInfo(f *cmdutil.Factory, out io.Writer) *cobra.Command {
func NewCmdClusterInfo(f cmdutil.Factory, out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "cluster-info",
// clusterinfo is deprecated.
Expand All @@ -50,7 +50,7 @@ func NewCmdClusterInfo(f *cmdutil.Factory, out io.Writer) *cobra.Command {
return cmd
}

func RunClusterInfo(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command) error {
func RunClusterInfo(f cmdutil.Factory, out io.Writer, cmd *cobra.Command) error {
if len(os.Args) > 1 && os.Args[1] == "clusterinfo" {
printDeprecationWarning("cluster-info", "clusterinfo")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/clusterinfo_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
)

// NewCmdCreateSecret groups subcommands to create various types of secrets
func NewCmdClusterInfoDump(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command {
func NewCmdClusterInfoDump(f cmdutil.Factory, cmdOut io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "dump",
Short: "Dump lots of relevant info for debugging and diagnosis",
Expand Down Expand Up @@ -84,7 +84,7 @@ func setupOutputWriter(cmd *cobra.Command, defaultWriter io.Writer, filename str
return file
}

func dumpClusterInfo(f *cmdutil.Factory, cmd *cobra.Command, args []string, out io.Writer) error {
func dumpClusterInfo(f cmdutil.Factory, cmd *cobra.Command, args []string, out io.Writer) error {
clientset, err := f.ClientSet()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubectl/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Use "{{.CommandPath}} [command] --help" for more information about a command.{{e
)

// NewKubectlCommand creates the `kubectl` command and its nested children.
func NewKubectlCommand(f *cmdutil.Factory, in io.Reader, out, err io.Writer) *cobra.Command {
func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cobra.Command {
// Parent command to which all subcommands are added.
cmds := &cobra.Command{
Use: "kubectl",
Expand Down