Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #15796 #16379

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/man/man1/kubectl-api-versions.1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

.SH NAME
.PP
kubectl api\-versions \- Print available API versions.
kubectl api\-versions \- Print the supported API versions on the server, in the form of "group/version".


.SH SYNOPSIS
Expand All @@ -13,7 +13,7 @@ kubectl api\-versions \- Print available API versions.

.SH DESCRIPTION
.PP
Print available API versions.
Print the supported API versions on the server, in the form of "group/version".


.SH OPTIONS INHERITED FROM PARENT COMMANDS
Expand Down
9 changes: 4 additions & 5 deletions docs/user-guide/kubectl/kubectl.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->


<!-- END MUNGE: UNVERSIONED_WARNING -->

## kubectl
Expand Down Expand Up @@ -49,7 +48,7 @@ kubectl
### SEE ALSO

* [kubectl annotate](kubectl_annotate.md) - Update the annotations on a resource
* [kubectl api-versions](kubectl_api-versions.md) - Print available API versions.
* [kubectl api-versions](kubectl_api-versions.md) - Print the supported API versions on the server, in the form of "group/version".
* [kubectl apply](kubectl_apply.md) - Apply a configuration to a resource by filename or stdin
* [kubectl attach](kubectl_attach.md) - Attach to a running container.
* [kubectl autoscale](kubectl_autoscale.md) - Auto-scale a replication controller
Expand All @@ -75,13 +74,13 @@ kubectl
* [kubectl stop](kubectl_stop.md) - Deprecated: Gracefully shut down a resource by name or filename.
* [kubectl version](kubectl_version.md) - Print the client and server version information.

###### Auto generated by spf13/cobra at 2015-09-11 06:17:55.670147499 +0000 UTC
###### Auto generated by spf13/cobra at 2015-10-27 18:17:28.82451834 +0000 UTC



<!-- BEGIN MUNGE: IS_VERSIONED -->
<!-- TAG IS_VERSIONED -->
<!-- END MUNGE: IS_VERSIONED -->
<!-- TAG IS_VERSIONED -->
<!-- END MUNGE: IS_VERSIONED -->


<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
Expand Down
10 changes: 5 additions & 5 deletions docs/user-guide/kubectl/kubectl_api-versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

## kubectl api-versions

Print available API versions.
Print the supported API versions on the server, in the form of "group/version".

### Synopsis


Print available API versions.
Print the supported API versions on the server, in the form of "group/version".

```
kubectl api-versions
Expand Down Expand Up @@ -48,13 +48,13 @@ kubectl api-versions

* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager

###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.164255617 +0000 UTC
###### Auto generated by spf13/cobra at 2015-10-27 18:17:28.824241345 +0000 UTC



<!-- BEGIN MUNGE: IS_VERSIONED -->
<!-- TAG IS_VERSIONED -->
<!-- END MUNGE: IS_VERSIONED -->
<!-- TAG IS_VERSIONED -->
<!-- END MUNGE: IS_VERSIONED -->


<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/unversioned/discovery_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (d *DiscoveryClient) ServerResources() (map[string]*unversioned.APIResource
if err != nil {
return nil, err
}
groupVersions := extractGroupVersions(apiGroups)
groupVersions := ExtractGroupVersions(apiGroups)
result := map[string]*unversioned.APIResourceList{}
for _, groupVersion := range groupVersions {
resources, err := d.ServerResourcesForGroupVersion(groupVersion)
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/unversioned/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func MatchesServerVersion(client *Client, c *Config) error {
return nil
}

func extractGroupVersions(l *unversioned.APIGroupList) []string {
func ExtractGroupVersions(l *unversioned.APIGroupList) []string {
var groupVersions []string
for _, g := range l.Groups {
for _, gv := range g.Versions {
Expand Down Expand Up @@ -238,7 +238,7 @@ func ServerAPIVersions(c *Config) (groupVersions []string, err error) {
if err != nil {
return nil, fmt.Errorf("unexpected error: %v", err)
}
groupVersions = append(groupVersions, extractGroupVersions(&apiGroupList)...)
groupVersions = append(groupVersions, ExtractGroupVersions(&apiGroupList)...)

return groupVersions, nil
}
Expand Down
22 changes: 9 additions & 13 deletions pkg/kubectl/cmd/apiversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import (
"fmt"
"io"
"os"
"sort"

"github.com/spf13/cobra"

"k8s.io/kubernetes/pkg/api/unversioned"
unversioned_client "k8s.io/kubernetes/pkg/client/unversioned"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
)

Expand All @@ -32,7 +33,7 @@ func NewCmdApiVersions(f *cmdutil.Factory, out io.Writer) *cobra.Command {
Use: "api-versions",
// apiversions is deprecated.
Aliases: []string{"apiversions"},
Short: "Print available API versions.",
Short: "Print the supported API versions on the server, in the form of \"group/version\".",
Run: func(cmd *cobra.Command, args []string) {
err := RunApiVersions(f, out)
cmdutil.CheckErr(err)
Expand All @@ -51,19 +52,14 @@ func RunApiVersions(f *cmdutil.Factory, w io.Writer) error {
return err
}

apiVersions, err := client.ServerAPIVersions()
groupList, err := client.Discovery().ServerGroups()
if err != nil {
fmt.Printf("Couldn't get available api versions from server: %v\n", err)
os.Exit(1)
return fmt.Errorf("Couldn't get available api versions from server: %v\n", err)
}

var expAPIVersions *unversioned.APIVersions
expAPIVersions, err = client.Extensions().ServerAPIVersions()

fmt.Fprintf(w, "Available Server Api Versions: %#v\n", *apiVersions)
if err == nil {
fmt.Fprintf(w, "Available Server Experimental Api Versions: %#v\n", *expAPIVersions)
apiVersions := unversioned_client.ExtractGroupVersions(groupList)
sort.Strings(apiVersions)
for _, v := range apiVersions {
fmt.Fprintln(w, v)
}

return nil
}
3 changes: 0 additions & 3 deletions test/e2e/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,6 @@ var _ = Describe("Kubectl client", func() {
It("should check if v1 is in available api versions [Conformance]", func() {
By("validating api verions")
output := runKubectl("api-versions")
if !strings.Contains(output, "Available Server Api Versions:") {
Failf("Missing caption in kubectl api-versions")
}
if !strings.Contains(output, "v1") {
Failf("No v1 in kubectl api-versions")
}
Expand Down