code: func (o *Options) Run() error {
  	var (
  		serverVersion *apimachineryversion.Info
  		serverErr     error
  		versionInfo   Version
  	)
  
  	clientVersion := version.Get()
  	versionInfo.ClientVersion = &clientVersion
  
  	if !o.ClientOnly && o.discoveryClient != nil {
  		// Always request fresh data from the server
  		o.discoveryClient.Invalidate()
  		serverVersion, serverErr = o.discoveryClient.ServerVersion()
  		versionInfo.ServerVersion = serverVersion
  	}
  
  	switch o.Output {
  	case "":
  		if o.Short {
  			fmt.Fprintf(o.Out, "Client Version: %s\n", clientVersion.GitVersion)
  			if serverVersion != nil {
  				fmt.Fprintf(o.Out, "Server Version: %s\n", serverVersion.GitVersion)
  			}
  		} else {
  			fmt.Fprintf(o.Out, "Client Version: %s\n", fmt.Sprintf("%#v", clientVersion))
  			if serverVersion != nil {
  				fmt.Fprintf(o.Out, "Server Version: %s\n", fmt.Sprintf("%#v", *serverVersion))
  			}
  		}
  	case "yaml":
  		marshalled, err := yaml.Marshal(&versionInfo)
  		if err != nil {
  			return err
  		}
  		fmt.Fprintln(o.Out, string(marshalled))
  	case "json":
  		marshalled, err := json.MarshalIndent(&versionInfo, "", "  ")
  		if err != nil {
  			return err
  		}
  		fmt.Fprintln(o.Out, string(marshalled))
  	default:
  		// There is a bug in the program if we hit this case.
  		// However, we follow a policy of never panicking.
  		return fmt.Errorf("VersionOptions were not validated: --output=%q should have been rejected", o.Output)
  	}
  
  	return serverErr
  }
docs: // Run executes version command