mirror of https://github.com/k3s-io/k3s
fix golint failures on pkg/kubectl/cmd/completion pkg/kubectl/cmd/cp pkg/kubectl/cmd/edit
parent
a887ae8344
commit
e2c1f43551
|
@ -132,15 +132,12 @@ pkg/kubectl/cmd/attach
|
|||
pkg/kubectl/cmd/autoscale
|
||||
pkg/kubectl/cmd/certificates
|
||||
pkg/kubectl/cmd/clusterinfo
|
||||
pkg/kubectl/cmd/completion
|
||||
pkg/kubectl/cmd/convert
|
||||
pkg/kubectl/cmd/cp
|
||||
pkg/kubectl/cmd/create
|
||||
pkg/kubectl/cmd/delete
|
||||
pkg/kubectl/cmd/describe
|
||||
pkg/kubectl/cmd/diff
|
||||
pkg/kubectl/cmd/drain
|
||||
pkg/kubectl/cmd/edit
|
||||
pkg/kubectl/cmd/exec
|
||||
pkg/kubectl/cmd/explain
|
||||
pkg/kubectl/cmd/expose
|
||||
|
|
|
@ -92,6 +92,7 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
// NewCmdCompletion creates the `completion` command
|
||||
func NewCmdCompletion(out io.Writer, boilerPlate string) *cobra.Command {
|
||||
shells := []string{}
|
||||
for s := range completionShells {
|
||||
|
@ -114,6 +115,7 @@ func NewCmdCompletion(out io.Writer, boilerPlate string) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// RunCompletion checks given arguments and executes command
|
||||
func RunCompletion(out io.Writer, boilerPlate string, cmd *cobra.Command, args []string) error {
|
||||
if len(args) == 0 {
|
||||
return cmdutil.UsageErrorf(cmd, "Shell not specified.")
|
||||
|
|
|
@ -66,6 +66,7 @@ var (
|
|||
/file/path for a local file`)
|
||||
)
|
||||
|
||||
// CopyOptions have the data required to perform the copy operation
|
||||
type CopyOptions struct {
|
||||
Container string
|
||||
Namespace string
|
||||
|
@ -77,6 +78,7 @@ type CopyOptions struct {
|
|||
genericclioptions.IOStreams
|
||||
}
|
||||
|
||||
// NewCopyOptions creates the options for copy
|
||||
func NewCopyOptions(ioStreams genericclioptions.IOStreams) *CopyOptions {
|
||||
return &CopyOptions{
|
||||
IOStreams: ioStreams,
|
||||
|
@ -140,6 +142,7 @@ func extractFileSpec(arg string) (fileSpec, error) {
|
|||
return fileSpec{}, errFileSpecDoesntMatchFormat
|
||||
}
|
||||
|
||||
// Complete completes all the required options
|
||||
func (o *CopyOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
|
||||
var err error
|
||||
o.Namespace, _, err = f.ToRawKubeConfigLoader().Namespace()
|
||||
|
@ -159,6 +162,7 @@ func (o *CopyOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Validate makes sure provided values for CopyOptions are valid
|
||||
func (o *CopyOptions) Validate(cmd *cobra.Command, args []string) error {
|
||||
if len(args) != 2 {
|
||||
return cmdutil.UsageErrorf(cmd, cpUsageStr)
|
||||
|
@ -166,6 +170,7 @@ func (o *CopyOptions) Validate(cmd *cobra.Command, args []string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Run performs the execution
|
||||
func (o *CopyOptions) Run(args []string) error {
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("source and destination are required")
|
||||
|
|
|
@ -67,6 +67,7 @@ var (
|
|||
kubectl edit deployment/mydeployment -o yaml --save-config`))
|
||||
)
|
||||
|
||||
// NewCmdEdit creates the `edit` command
|
||||
func NewCmdEdit(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
||||
o := editor.NewEditOptions(editor.NormalEditMode, ioStreams)
|
||||
o.ValidateOptions = cmdutil.ValidateOptions{EnableValidation: true}
|
||||
|
|
|
@ -129,7 +129,7 @@ func TestEdit(t *testing.T) {
|
|||
}
|
||||
}
|
||||
return &http.Response{StatusCode: 200, Body: ioutil.NopCloser(bytes.NewReader(resultingOutput))}, nil
|
||||
} else {
|
||||
}
|
||||
if step.StepType != "request" {
|
||||
t.Fatalf("%s, step %d: expected request step, got %s %s", name, i, req.Method, req.URL.Path)
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ func TestEdit(t *testing.T) {
|
|||
}
|
||||
}
|
||||
return &http.Response{StatusCode: step.ResponseStatusCode, Header: cmdtesting.DefaultHeader(), Body: ioutil.NopCloser(bytes.NewReader(resultingOutput))}, nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
|
|
Loading…
Reference in New Issue