Skip to content

Commit

Permalink
Wire up api-versions and api-resources to oc
Browse files Browse the repository at this point in the history
  • Loading branch information
soltysh committed May 30, 2018
1 parent 692e69b commit ac563cb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
2 changes: 2 additions & 0 deletions pkg/oc/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ func NewCommandCLI(name, fullName string, in io.Reader, out, errout io.Writer) *
importer.NewCmdImport(fullName, f, in, out, errout),
image.NewCmdImage(fullName, f, in, out, errout),
registry.NewCmd(fullName, f, in, out, errout),
cmd.NewCmdApiVersions(fullName, f, out),
cmd.NewCmdApiResources(fullName, f, out),
},
},
{
Expand Down
37 changes: 37 additions & 0 deletions pkg/oc/cli/cmd/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl/cmd/config"
"k8s.io/kubernetes/pkg/kubectl/cmd/resource"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"

cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/oc/cli/cmd/create"
Expand Down Expand Up @@ -788,3 +789,39 @@ func NewCmdAuth(fullName string, f *clientcmd.Factory, out, errout io.Writer) *c
func NewCmdPlugin(fullName string, f *clientcmd.Factory, in io.Reader, out, errout io.Writer) *cobra.Command {
return kcmd.NewCmdPlugin(f, in, out, errout)
}

var (
apiresourcesExample = templates.Examples(`
# Print the supported API Resources
%[1]s api-resources
# Print the supported API Resources with more information
%[1]s api-resources -o wide
# Print the supported namespaced resources
%[1]s api-resources --namespaced=true
# Print the supported non-namespaced resources
%[1]s api-resources --namespaced=false
# Print the supported API Resources with specific APIGroup
%[1]s api-resources --api-group=extensions`)
)

func NewCmdApiVersions(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
cmd := kcmd.NewCmdApiVersions(f, out)
cmd.Example = fmt.Sprintf(apiresourcesExample, fullName)
return cmd
}

var (
apiversionsExample = templates.Examples(i18n.T(`
# Print the supported API versions
%[1]s api-versions`))
)

func NewCmdApiResources(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
cmd := kcmd.NewCmdApiResources(f, out)
cmd.Example = fmt.Sprintf(apiversionsExample, fullName)
return cmd
}
11 changes: 3 additions & 8 deletions pkg/oc/cli/kubectl_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
// NEVER ADD TO THIS LIST
// TODO kill this list
var MissingCommands = sets.NewString(
"namespace", "rolling-update",
"cluster-info", "api-versions",
"stop",
"namespace",
"rolling-update",
"cluster-info",

// are on admin commands
"cordon",
Expand All @@ -30,12 +30,7 @@ var MissingCommands = sets.NewString(
"certificate",

// TODO commands to assess
"apiversions",
"clusterinfo",
"resize",
"rollingupdate",
"run-container",
"update",
"alpha",
)

Expand Down

0 comments on commit ac563cb

Please sign in to comment.