Skip to content

Commit

Permalink
fix(pkg/cmd): injecting factory also for delete and attach commands
Browse files Browse the repository at this point in the history
  • Loading branch information
leodido authored and fntlnz committed Nov 25, 2018
1 parent 753a142 commit eb190ff
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pkg/cmd/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"

"github.com/davecgh/go-spew/spew"
"github.com/fntlnz/kubectl-trace/pkg/factory"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
// "k8s.io/kubernetes/pkg/kubectl/util/templates"
)

var (
Expand All @@ -20,7 +20,7 @@ var (
%[1]s trace attach -h
# ...
%[1]s trace (...) attach`
%[1]s trace attach`
)

// AttachOptions ...
Expand All @@ -36,7 +36,7 @@ func NewAttachOptions(streams genericclioptions.IOStreams) *AttachOptions {
}

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

cmd := &cobra.Command{
Expand Down
5 changes: 3 additions & 2 deletions pkg/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

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

// NewDeleteCommand provides the delete command wrapping DeleteOptions.
func NewDeleteCommand(streams genericclioptions.IOStreams) *cobra.Command {
func NewDeleteCommand(factory factory.Factory, streams genericclioptions.IOStreams) *cobra.Command {
o := NewDeleteOptions(streams)

cmd := &cobra.Command{
Use: "delete TRACE_ID",
Short: deleteShort,
Long: deleteLong, // Wrap with templates.LongDesc()
Example: fmt.Sprintf(deleteExamples, "kubectl"), // Wrap with templates.Examples()
Run: func(cmd *cobra.Command, args []string) {
Run: func(c *cobra.Command, args []string) {
fmt.Println("delete")
spew.Dump(o)
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ func (o *RunOptions) Validate(cmd *cobra.Command, args []string) error {
// todo > complete validation
// - make errors
// - make validators
if len(o.container) == 0 {
return fmt.Errorf("invalid container")
}
// if len(o.container) == 0 {
// return fmt.Errorf("invalid container")
// }

return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func NewTraceCommand(streams genericclioptions.IOStreams) *cobra.Command {

cmd.AddCommand(NewRunCommand(f, streams))
cmd.AddCommand(NewGetCommand(f, streams))
cmd.AddCommand(NewAttachCommand(streams))
cmd.AddCommand(NewDeleteCommand(streams))
cmd.AddCommand(NewAttachCommand(f, streams))
cmd.AddCommand(NewDeleteCommand(f, streams))

return cmd
}

0 comments on commit eb190ff

Please sign in to comment.