Shorten 'CodecForVersionOrDie' name, add 'ResourceVersioner' to testapi

This commit is contained in:
Daniel Smith
2014-10-09 13:13:08 -07:00
parent 13acb63fb3
commit d34914517f
5 changed files with 20 additions and 8 deletions

View File

@@ -24,7 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
// Version returns the API version to test against as set by the KUBE_API_VERSION env var.
// Version returns the API version to test against, as set by the KUBE_API_VERSION env var.
func Version() string {
version := os.Getenv("KUBE_API_VERSION")
if version == "" {
@@ -33,10 +33,22 @@ func Version() string {
return version
}
func CodecForVersionOrDie() runtime.Codec {
// Codec returns the codec for the API version to test against, as set by the
// KUBE_API_VERSION env var.
func Codec() runtime.Codec {
interfaces, err := latest.InterfacesFor(Version())
if err != nil {
panic(err)
}
return interfaces.Codec
}
// ResourceVersioner returns the ResourceVersioner for the API version to test against,
// as set by the KUBE_API_VERSION env var.
func ResourceVersioner() runtime.ResourceVersioner {
interfaces, err := latest.InterfacesFor(Version())
if err != nil {
panic(err)
}
return interfaces.ResourceVersioner
}