Skip to content

Commit

Permalink
Merge pull request #19884 from soltysh/api_resources
Browse files Browse the repository at this point in the history
Expose api-versions and api-resources in oc
  • Loading branch information
openshift-merge-robot authored May 30, 2018
2 parents c1a18ca + 66bad2f commit bc87ffb
Show file tree
Hide file tree
Showing 17 changed files with 523 additions and 8 deletions.
103 changes: 103 additions & 0 deletions contrib/completions/bash/oc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 103 additions & 0 deletions contrib/completions/zsh/oc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/man/man1/.files_generated_oc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/man/man1/oc-api-resources.1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/man/man1/oc-api-versions.1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 NewCmdApiResources(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
cmd := kcmd.NewCmdApiResources(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 NewCmdApiVersions(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
cmd := kcmd.NewCmdApiVersions(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
15 changes: 15 additions & 0 deletions test/cmd/apiresources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/../../hack/lib/init.sh"
trap os::test::junit::reconcile_output EXIT

os::test::junit::declare_suite_start "cmd/apiresources"

os::cmd::expect_success_and_text 'oc api-resources' 'imagestreamtags'
os::cmd::expect_success_and_text 'oc api-resources --api-group=build.openshift.io' 'BuildConfig'
os::cmd::expect_success_and_text 'oc api-resources --namespaced=false' 'Image'
os::cmd::expect_success_and_text 'oc api-resources --verbs=get' 'project.openshift.io'

os::cmd::expect_success_and_text 'oc api-versions' 'route.openshift.io/v1'

echo "apiresources: ok"
os::test::junit::declare_suite_end
3 changes: 3 additions & 0 deletions vendor/k8s.io/kubernetes/docs/.generated_docs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/k8s.io/kubernetes/hack/make-rules/test-cmd-util.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bc87ffb

Please sign in to comment.