Skip to content

Commit eb190ff

Browse files
leodidofntlnz
authored andcommitted
fix(pkg/cmd): injecting factory also for delete and attach commands
1 parent 753a142 commit eb190ff

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

pkg/cmd/attach.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"fmt"
55

66
"github.com/davecgh/go-spew/spew"
7+
"github.com/fntlnz/kubectl-trace/pkg/factory"
78
"github.com/spf13/cobra"
89
"k8s.io/cli-runtime/pkg/genericclioptions"
9-
// "k8s.io/kubernetes/pkg/kubectl/util/templates"
1010
)
1111

1212
var (
@@ -20,7 +20,7 @@ var (
2020
%[1]s trace attach -h
2121
2222
# ...
23-
%[1]s trace (...) attach`
23+
%[1]s trace attach`
2424
)
2525

2626
// AttachOptions ...
@@ -36,7 +36,7 @@ func NewAttachOptions(streams genericclioptions.IOStreams) *AttachOptions {
3636
}
3737

3838
// NewAttachCommand provides the attach command wrapping AttachOptions.
39-
func NewAttachCommand(streams genericclioptions.IOStreams) *cobra.Command {
39+
func NewAttachCommand(factory factory.Factory, streams genericclioptions.IOStreams) *cobra.Command {
4040
o := NewAttachOptions(streams)
4141

4242
cmd := &cobra.Command{

pkg/cmd/delete.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55

66
"github.com/davecgh/go-spew/spew"
7+
"github.com/fntlnz/kubectl-trace/pkg/factory"
78
"github.com/spf13/cobra"
89
"k8s.io/cli-runtime/pkg/genericclioptions"
910
// "k8s.io/kubernetes/pkg/kubectl/util/templates"
@@ -35,15 +36,15 @@ func NewDeleteOptions(streams genericclioptions.IOStreams) *DeleteOptions {
3536
}
3637

3738
// NewDeleteCommand provides the delete command wrapping DeleteOptions.
38-
func NewDeleteCommand(streams genericclioptions.IOStreams) *cobra.Command {
39+
func NewDeleteCommand(factory factory.Factory, streams genericclioptions.IOStreams) *cobra.Command {
3940
o := NewDeleteOptions(streams)
4041

4142
cmd := &cobra.Command{
4243
Use: "delete TRACE_ID",
4344
Short: deleteShort,
4445
Long: deleteLong, // Wrap with templates.LongDesc()
4546
Example: fmt.Sprintf(deleteExamples, "kubectl"), // Wrap with templates.Examples()
46-
Run: func(cmd *cobra.Command, args []string) {
47+
Run: func(c *cobra.Command, args []string) {
4748
fmt.Println("delete")
4849
spew.Dump(o)
4950
},

pkg/cmd/run.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ func (o *RunOptions) Validate(cmd *cobra.Command, args []string) error {
127127
// todo > complete validation
128128
// - make errors
129129
// - make validators
130-
if len(o.container) == 0 {
131-
return fmt.Errorf("invalid container")
132-
}
130+
// if len(o.container) == 0 {
131+
// return fmt.Errorf("invalid container")
132+
// }
133133

134134
return nil
135135
}

pkg/cmd/trace.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ func NewTraceCommand(streams genericclioptions.IOStreams) *cobra.Command {
7474

7575
cmd.AddCommand(NewRunCommand(f, streams))
7676
cmd.AddCommand(NewGetCommand(f, streams))
77-
cmd.AddCommand(NewAttachCommand(streams))
78-
cmd.AddCommand(NewDeleteCommand(streams))
77+
cmd.AddCommand(NewAttachCommand(f, streams))
78+
cmd.AddCommand(NewDeleteCommand(f, streams))
7979

8080
return cmd
8181
}

0 commit comments

Comments
 (0)