Skip to content

Commit

Permalink
update printflags on create cmds
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Jul 9, 2018
1 parent f0b286e commit 882d059
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
7 changes: 3 additions & 4 deletions pkg/oc/cli/cmd/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import (

"github.com/spf13/cobra"

"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/kubectl/cmd/create"
"github.com/openshift/origin/pkg/oc/util/ocscheme"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers"
Expand All @@ -17,7 +16,7 @@ type CreateSubcommandOptions struct {
genericclioptions.IOStreams

// PrintFlags holds options necessary for obtaining a printer
PrintFlags *create.PrintFlags
PrintFlags *genericclioptions.PrintFlags
// Name of resource being created
Name string
// DryRun is true if the command should be simulated but not run against the server
Expand All @@ -31,7 +30,7 @@ type CreateSubcommandOptions struct {

func NewCreateSubcommandOptions(ioStreams genericclioptions.IOStreams) *CreateSubcommandOptions {
return &CreateSubcommandOptions{
PrintFlags: create.NewPrintFlags("created", legacyscheme.Scheme),
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(ocscheme.PrintingInternalScheme),
IOStreams: ioStreams,
}
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/oc/cli/cmd/create/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import (
"github.com/spf13/cobra"

"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/legacyscheme"
kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/kubectl/cmd/create"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers"

routev1client "github.com/openshift/client-go/route/clientset/versioned/typed/route/v1"
"github.com/openshift/origin/pkg/oc/util/ocscheme"
)

var (
Expand Down Expand Up @@ -44,7 +43,7 @@ func NewCmdCreateRoute(fullName string, f kcmdutil.Factory, streams genericcliop
// CreateRouteSubcommandOptions is an options struct to support create subcommands
type CreateRouteSubcommandOptions struct {
// PrintFlags holds options necessary for obtaining a printer
PrintFlags *create.PrintFlags
PrintFlags *genericclioptions.PrintFlags
// Name of resource being created
Name string
ServiceName string
Expand All @@ -66,7 +65,7 @@ type CreateRouteSubcommandOptions struct {

func NewCreateRouteSubcommandOptions(ioStreams genericclioptions.IOStreams) *CreateRouteSubcommandOptions {
return &CreateRouteSubcommandOptions{
PrintFlags: create.NewPrintFlags("created", legacyscheme.Scheme),
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(ocscheme.PrintingInternalScheme),
IOStreams: ioStreams,
}
}
Expand Down
9 changes: 7 additions & 2 deletions pkg/oc/cli/cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,14 @@ func (o *DebugOptions) Complete(cmd *cobra.Command, f kcmdutil.Factory, args []s
}
o.AsNonRoot = !o.AsRoot && cmd.Flag("as-root").Changed

templateArgSpecified := o.PrintFlags.TemplatePrinterFlags != nil &&
o.PrintFlags.TemplatePrinterFlags.TemplateArgument != nil &&
len(*o.PrintFlags.TemplatePrinterFlags.TemplateArgument) > 0

outputFormatSpecified := o.PrintFlags.OutputFormat != nil && len(*o.PrintFlags.OutputFormat) > 0

// TODO: below should be turned into a method on PrintFlags
if (o.PrintFlags.OutputFormat != nil && len(*o.PrintFlags.OutputFormat) > 0) ||
(o.PrintFlags.TemplatePrinterFlags != nil && o.PrintFlags.TemplatePrinterFlags.TemplateArgument != nil) {
if outputFormatSpecified || templateArgSpecified {
if o.DryRun {
o.PrintFlags.Complete("%s (dry run)")
}
Expand Down

0 comments on commit 882d059

Please sign in to comment.