예제 #1
0
파일: testapi.go 프로젝트: ncantor/origin
// Codec returns the codec for the API version to test against, as set by the
// KUBE_TEST_API env var.
func (g TestGroup) Codec() runtime.Codec {
	// TODO: caesarxuchao: Restructure the body once we have a central `latest`.
	if g.Group == "" {
		interfaces, err := latest.InterfacesFor(g.VersionUnderTest)
		if err != nil {
			panic(err)
		}
		return interfaces.Codec
	}
	if g.Group == "experimental" {
		interfaces, err := explatest.InterfacesFor(g.VersionUnderTest)
		if err != nil {
			panic(err)
		}
		return interfaces.Codec
	}
	panic(fmt.Errorf("cannot test group %s", g.Group))
}
예제 #2
0
func setExperimentalDefaults(config *Config) error {
	config.Prefix = "/experimental"
	if config.UserAgent == "" {
		config.UserAgent = DefaultKubernetesUserAgent()
	}
	if config.Version == "" {
		config.Version = explatest.Version
	}
	versionInterfaces, err := explatest.InterfacesFor(config.Version)
	if err != nil {
		return fmt.Errorf("Experimental API version '%s' is not recognized (valid values: %s)",
			config.Version, strings.Join(explatest.Versions, ", "))
	}
	if config.Codec == nil {
		config.Codec = versionInterfaces.Codec
	}
	if config.QPS == 0 {
		config.QPS = 5
	}
	if config.Burst == 0 {
		config.Burst = 10
	}
	return nil
}