Skip to content

Commit

Permalink
feat(cmd/pkg): run methods for get and run commands
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
  • Loading branch information
leodido authored and fntlnz committed Nov 25, 2018
1 parent 7627b94 commit 493a75e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
17 changes: 16 additions & 1 deletion pkg/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"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 Down Expand Up @@ -74,6 +73,9 @@ func NewGetCommand(factory factory.Factory, streams genericclioptions.IOStreams)
if err := o.Complete(factory, c, args); err != nil {
return err
}
if err := o.Run(); err != nil {
return err
}
return nil
},
}
Expand All @@ -100,16 +102,29 @@ func (o *GetOptions) Validate(cmd *cobra.Command, args []string) error {

// Complete completes the setup of the command.
func (o *GetOptions) Complete(factory factory.Factory, cmd *cobra.Command, args []string) error {
var err error
o.namespace, o.explicitNamespace, _ = factory.ToRawKubeConfigLoader().Namespace()
if err != nil {
return err
}

// All namespaces, when present, overrides namespace flag
if cmd.Flag("all-namespaces").Changed {
o.allNamespaces = *o.ResourceBuilderFlags.AllNamespaces
o.explicitNamespace = false
o.namespace = ""
}
// Need either a namespace, a trace ID, or all namespaces
if o.traceArg == "" && !o.allNamespaces && !o.explicitNamespace {
return fmt.Errorf(missingTargetErr)
}

// todo > init printers (need PrintFlags)

return nil
}

// Run executes the get command.
func (o *GetOptions) Run() error {
return nil
}
18 changes: 16 additions & 2 deletions pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func NewRunCommand(factory factory.Factory, streams genericclioptions.IOStreams)
if err := o.Complete(factory, c, args); err != nil {
return err
}
if err := o.Run(); err != nil {
return err
}
return nil
},
}
Expand Down Expand Up @@ -122,12 +125,23 @@ func (o *RunOptions) Validate(cmd *cobra.Command, args []string) error {

// Complete completes the setup of the command.
func (o *RunOptions) Complete(factory factory.Factory, cmd *cobra.Command, args []string) error {
o.namespace, o.explicitNamespace, _ = factory.ToRawKubeConfigLoader().Namespace()
var err error
o.namespace, o.explicitNamespace, err = factory.ToRawKubeConfigLoader().Namespace()
if err != nil {
return err
}

spew.Dump(o)
b := factory.NewBuilder()
spew.Dump(b)

// get resource by pof | type/name
// get resource by pod | type/name
// get container

return nil
}

// Run executes the run command.
func (o *RunOptions) Run() error {
return nil
}

0 comments on commit 493a75e

Please sign in to comment.