Esempio n. 1
0
func RunApiVersions(f *cmdutil.Factory, w io.Writer) error {
	if len(os.Args) > 1 && os.Args[1] == "apiversions" {
		printDeprecationWarning("api-versions", "apiversions")
	}

	client, err := f.Client()
	if err != nil {
		return err
	}

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

	var expAPIVersions *api.APIVersions
	showExpVersions := false
	expClient, err := f.ExperimentalClient()
	if err == nil {
		expAPIVersions, err = expClient.ServerAPIVersions()
		showExpVersions = err == nil
	}

	fmt.Fprintf(w, "Available Server Api Versions: %#v\n", *apiVersions)
	if showExpVersions {
		fmt.Fprintf(w, "Available Server Experimental Api Versions: %#v\n", *expAPIVersions)
	}

	return nil
}