func (o *APIVersion) Equals(p *APIVersion) bool {
	return o.String() == p.String()
}
Equals returns true if 'o' and 'p' represent the same version
package kubernetes
import (
	"fmt"
	"log"
	"regexp"
	"strconv"
)
type VersionStage int
const (
	StageAlpha VersionStage = iota
	StageBeta
	StageGA
)
var stageName = map[VersionStage]string{
	StageAlpha: "alpha",
	StageBeta:  "beta",
	StageGA:    "",
}
type APIVersion struct {
	Version int
	Stage VersionStage
	StageVersion *int
}
func NewAPIVersion(literal string) (apiversion *APIVersion, err error) {
	re := regexp.MustCompile("^v(\\d+)((alpha|beta|)(\\d))?$")
	parts := re.FindStringSubmatch(literal)
	if parts == nil || len(parts) != 5 {
		return nil, fmt.Errorf("Error parsing %s", literal)
	}
	apiversion = &APIVersion{}
	apiversion.Version, err = strconv.Atoi(parts[1])
	if err != nil {
		log.Printf("Error parsing integer '%s'", parts[1])
		return nil, err
	}
	apiversion.Stage, err = getVersionStage(parts[3])
	if err != nil {
		return nil, err
	}
	if apiversion.Stage != StageGA {
		var res int
		res, err = strconv.Atoi(parts[4])
		if err != nil {
			return nil, err
		}
		apiversion.StageVersion = &res
	}
	return
}
func getVersionStage(stage string) (VersionStage, error) {
	switch stage {
	case stageName[StageAlpha]:
		return StageAlpha, nil
	case stageName[StageBeta]:
		return StageBeta, nil
	case stageName[StageGA]:
		return StageGA, nil
	default:
		return 0, fmt.Errorf("unknown stage %s", stage)
	}
}
func (o *APIVersion) String() string {
	if o == nil {
		return ""
	}
	if o.Stage == StageGA {
		return fmt.Sprintf("v%d", o.Version)
	}
	return fmt.Sprintf("v%d%s%d", o.Version, stageName[o.Stage], *o.StageVersion)
}