当前位置: 首页>>代码示例>>Golang>>正文


Golang latest.GroupOrDie函数代码示例

本文整理汇总了Golang中k8s/io/kubernetes/pkg/api/latest.GroupOrDie函数的典型用法代码示例。如果您正苦于以下问题:Golang GroupOrDie函数的具体用法?Golang GroupOrDie怎么用?Golang GroupOrDie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GroupOrDie函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: thirdpartyapi

func (m *Master) thirdpartyapi(group, kind, version string) *apiserver.APIGroupVersion {
	resourceStorage := thirdpartyresourcedataetcd.NewREST(m.thirdPartyStorage, group, kind)

	apiRoot := makeThirdPartyPath("")

	storage := map[string]rest.Storage{
		strings.ToLower(kind) + "s": resourceStorage,
	}

	return &apiserver.APIGroupVersion{
		Root:                   apiRoot,
		Version:                apiutil.GetGroupVersion(group, version),
		APIRequestInfoResolver: m.newAPIRequestInfoResolver(),

		Creater:   thirdpartyresourcedata.NewObjectCreator(group, version, api.Scheme),
		Convertor: api.Scheme,
		Typer:     api.Scheme,

		Mapper:        thirdpartyresourcedata.NewMapper(latest.GroupOrDie("experimental").RESTMapper, kind, version, group),
		Codec:         thirdpartyresourcedata.NewCodec(latest.GroupOrDie("experimental").Codec, kind),
		Linker:        latest.GroupOrDie("experimental").SelfLinker,
		Storage:       storage,
		ServerVersion: latest.GroupOrDie("").GroupVersion,

		Context: m.requestContextMapper,

		ProxyDialerFn:     m.dialer,
		MinRequestTimeout: m.minRequestTimeout,
	}
}
开发者ID:alena1108,项目名称:kubernetes,代码行数:30,代码来源:master.go

示例2: TestRESTMapper

func TestRESTMapper(t *testing.T) {
	gv := unversioned.GroupVersion{Group: componentconfig.GroupName, Version: "v1alpha1"}
	proxyGVK := gv.WithKind("KubeProxyConfiguration")

	if gvk, err := latest.GroupOrDie(componentconfig.GroupName).RESTMapper.KindFor(gv.WithResource("kubeproxyconfiguration")); err != nil || gvk != proxyGVK {
		t.Errorf("unexpected version mapping: %v %v", gvk, err)
	}

	if m, err := latest.GroupOrDie(componentconfig.GroupName).RESTMapper.RESTMapping(proxyGVK.GroupKind(), ""); err != nil || m.GroupVersionKind != proxyGVK || m.Resource != "kubeproxyconfigurations" {
		t.Errorf("unexpected version mapping: %#v %v", m, err)
	}

	for _, version := range latest.GroupOrDie(componentconfig.GroupName).GroupVersions {
		mapping, err := latest.GroupOrDie(componentconfig.GroupName).RESTMapper.RESTMapping(proxyGVK.GroupKind(), version.Version)
		if err != nil {
			t.Errorf("unexpected error: %v", err)
			continue
		}

		if mapping.Resource != "kubeproxyconfigurations" {
			t.Errorf("incorrect resource name: %#v", mapping)
		}
		if mapping.GroupVersionKind.GroupVersion() != version {
			t.Errorf("incorrect groupVersion: %v", mapping)
		}

		interfaces, _ := latest.GroupOrDie(componentconfig.GroupName).InterfacesFor(version)
		if mapping.Codec != interfaces.Codec {
			t.Errorf("unexpected codec: %#v, expected: %#v", mapping, interfaces)
		}
	}
}
开发者ID:johndmulhausen,项目名称:kubernetes,代码行数:32,代码来源:install_test.go

示例3: init

func init() {
	kubeTestAPI := os.Getenv("KUBE_TEST_API")
	if kubeTestAPI != "" {
		testGroupVersions := strings.Split(kubeTestAPI, ",")
		for _, groupVersion := range testGroupVersions {
			// TODO: caesarxuchao: the apiutil package is hacky, it will be replaced
			// by a following PR.
			Groups[apiutil.GetGroup(groupVersion)] =
				TestGroup{apiutil.GetGroup(groupVersion), apiutil.GetVersion(groupVersion), groupVersion}
		}
	}

	// TODO: caesarxuchao: we need a central place to store all available API
	// groups and their metadata.
	if _, ok := Groups[""]; !ok {
		// TODO: The second latest.GroupOrDie("").Version will be latest.GroupVersion after we
		// have multiple group support
		Groups[""] = TestGroup{"", latest.GroupOrDie("").Version, latest.GroupOrDie("").GroupVersion}
	}
	if _, ok := Groups["extensions"]; !ok {
		Groups["extensions"] = TestGroup{"extensions", latest.GroupOrDie("extensions").Version, latest.GroupOrDie("extensions").GroupVersion}
	}

	Default = Groups[""]
	Extensions = Groups["extensions"]
}
开发者ID:MohamedFAhmed,项目名称:heapster,代码行数:26,代码来源:testapi.go

示例4: TestRESTMapper

func TestRESTMapper(t *testing.T) {
	if v, k, err := latest.GroupOrDie("componentconfig").RESTMapper.VersionAndKindForResource("kubeproxyconfiguration"); err != nil || v != "componentconfig/v1alpha1" || k != "KubeProxyConfiguration" {
		t.Errorf("unexpected version mapping: %s %s %v", v, k, err)
	}

	if m, err := latest.GroupOrDie("componentconfig").RESTMapper.RESTMapping("KubeProxyConfiguration", ""); err != nil || m.APIVersion != "componentconfig/v1alpha1" || m.Resource != "kubeproxyconfigurations" {
		t.Errorf("unexpected version mapping: %#v %v", m, err)
	}

	for _, groupVersion := range latest.GroupOrDie("componentconfig").GroupVersions {
		mapping, err := latest.GroupOrDie("componentconfig").RESTMapper.RESTMapping("KubeProxyConfiguration", groupVersion)
		if err != nil {
			t.Errorf("unexpected error: %v", err)
		}

		if mapping.Resource != "kubeproxyconfigurations" {
			t.Errorf("incorrect resource name: %#v", mapping)
		}
		if mapping.APIVersion != groupVersion {
			t.Errorf("incorrect groupVersion: %v", mapping)
		}

		interfaces, _ := latest.GroupOrDie("componentconfig").InterfacesFor(groupVersion)
		if mapping.Codec != interfaces.Codec {
			t.Errorf("unexpected codec: %#v, expected: %#v", mapping, interfaces)
		}
	}
}
开发者ID:abursavich,项目名称:kubernetes,代码行数:28,代码来源:install_test.go

示例5: thirdpartyapi

func (m *Master) thirdpartyapi(group, kind, version string) *apiserver.APIGroupVersion {
	resourceStorage := thirdpartyresourcedataetcd.NewREST(m.thirdPartyStorage, group, kind)

	apiRoot := "/thirdparty/" + group + "/"

	storage := map[string]rest.Storage{
		strings.ToLower(kind) + "s": resourceStorage,
	}

	return &apiserver.APIGroupVersion{
		Root: apiRoot,

		Creater:   thirdpartyresourcedata.NewObjectCreator(version, api.Scheme),
		Convertor: api.Scheme,
		Typer:     api.Scheme,

		Mapper:  thirdpartyresourcedata.NewMapper(latest.GroupOrDie("experimental").RESTMapper, kind, version),
		Codec:   latest.GroupOrDie("experimental").Codec,
		Linker:  latest.GroupOrDie("experimental").SelfLinker,
		Storage: storage,
		Version: version,

		Admit:   m.admissionControl,
		Context: m.requestContextMapper,

		ProxyDialerFn:     m.dialer,
		MinRequestTimeout: m.minRequestTimeout,
	}
}
开发者ID:jasonparekh,项目名称:kubernetes,代码行数:29,代码来源:master.go

示例6: thirdpartyapi

func (m *Master) thirdpartyapi(group, kind, version string) *apiserver.APIGroupVersion {
	resourceStorage := thirdpartyresourcedataetcd.NewREST(m.thirdPartyStorage, generic.UndecoratedStorage, group, kind)

	apiRoot := makeThirdPartyPath("")

	storage := map[string]rest.Storage{
		strings.ToLower(kind) + "s": resourceStorage,
	}

	serverGroupVersion := unversioned.ParseGroupVersionOrDie(latest.GroupOrDie("").GroupVersion)

	return &apiserver.APIGroupVersion{
		Root:                apiRoot,
		GroupVersion:        unversioned.GroupVersion{Group: group, Version: version},
		RequestInfoResolver: m.newRequestInfoResolver(),

		Creater:   thirdpartyresourcedata.NewObjectCreator(group, version, api.Scheme),
		Convertor: api.Scheme,
		Typer:     api.Scheme,

		Mapper:             thirdpartyresourcedata.NewMapper(latest.GroupOrDie("extensions").RESTMapper, kind, version, group),
		Codec:              thirdpartyresourcedata.NewCodec(latest.GroupOrDie("extensions").Codec, kind),
		Linker:             latest.GroupOrDie("extensions").SelfLinker,
		Storage:            storage,
		ServerGroupVersion: &serverGroupVersion,

		Context: m.requestContextMapper,

		MinRequestTimeout: m.minRequestTimeout,
	}
}
开发者ID:kimsh92,项目名称:kubernetes,代码行数:31,代码来源:master.go

示例7: RunAMaster

// TODO: Merge this into startMasterOrDie.
func RunAMaster(t *testing.T) (*master.Master, *httptest.Server) {
	etcdClient := NewEtcdClient()
	etcdStorage, err := master.NewEtcdStorage(etcdClient, latest.GroupOrDie("").InterfacesFor, testapi.Default.Version(), etcdtest.PathPrefix())
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}
	expEtcdStorage, err := master.NewEtcdStorage(etcdClient, latest.GroupOrDie("experimental").InterfacesFor, latest.GroupOrDie("experimental").Version, etcdtest.PathPrefix())
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}

	m := master.New(&master.Config{
		DatabaseStorage:    etcdStorage,
		ExpDatabaseStorage: expEtcdStorage,
		KubeletClient:      client.FakeKubeletClient{},
		EnableLogsSupport:  false,
		EnableProfiling:    true,
		EnableUISupport:    false,
		APIPrefix:          "/api",
		APIGroupPrefix:     "/apis",
		EnableExp:          true,
		Authorizer:         apiserver.NewAlwaysAllowAuthorizer(),
		AdmissionControl:   admit.NewAlwaysAdmit(),
	})

	s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		m.Handler.ServeHTTP(w, req)
	}))

	return m, s
}
开发者ID:jasonparekh,项目名称:kubernetes,代码行数:32,代码来源:master_utils.go

示例8: experimental

// experimental returns the resources and codec for the experimental api
func (m *Master) experimental(c *Config) *apiserver.APIGroupVersion {
	controllerStorage := expcontrolleretcd.NewStorage(c.DatabaseStorage)
	autoscalerStorage := horizontalpodautoscaleretcd.NewREST(c.ExpDatabaseStorage)
	thirdPartyResourceStorage := thirdpartyresourceetcd.NewREST(c.ExpDatabaseStorage)
	daemonSetStorage, daemonSetStatusStorage := daemonetcd.NewREST(c.ExpDatabaseStorage)
	deploymentStorage := deploymentetcd.NewStorage(c.ExpDatabaseStorage)
	jobStorage, jobStatusStorage := jobetcd.NewREST(c.ExpDatabaseStorage)

	thirdPartyControl := ThirdPartyController{
		master: m,
		thirdPartyResourceRegistry: thirdPartyResourceStorage,
	}
	go func() {
		util.Forever(func() {
			if err := thirdPartyControl.SyncResources(); err != nil {
				glog.Warningf("third party resource sync failed: %v", err)
			}
		}, 10*time.Second)
	}()
	storage := map[string]rest.Storage{
		strings.ToLower("replicationControllers"):       controllerStorage.ReplicationController,
		strings.ToLower("replicationControllers/scale"): controllerStorage.Scale,
		strings.ToLower("horizontalpodautoscalers"):     autoscalerStorage,
		strings.ToLower("thirdpartyresources"):          thirdPartyResourceStorage,
		strings.ToLower("daemonsets"):                   daemonSetStorage,
		strings.ToLower("daemonsets/status"):            daemonSetStatusStorage,
		strings.ToLower("deployments"):                  deploymentStorage.Deployment,
		strings.ToLower("deployments/scale"):            deploymentStorage.Scale,
		strings.ToLower("jobs"):                         jobStorage,
		strings.ToLower("jobs/status"):                  jobStatusStorage,
	}

	expMeta := latest.GroupOrDie("experimental")

	return &apiserver.APIGroupVersion{
		Root: m.apiGroupPrefix,
		APIRequestInfoResolver: m.newAPIRequestInfoResolver(),

		Creater:   api.Scheme,
		Convertor: api.Scheme,
		Typer:     api.Scheme,

		Mapper:        expMeta.RESTMapper,
		Codec:         expMeta.Codec,
		Linker:        expMeta.SelfLinker,
		Storage:       storage,
		Version:       expMeta.GroupVersion,
		ServerVersion: latest.GroupOrDie("").GroupVersion,

		Admit:   m.admissionControl,
		Context: m.requestContextMapper,

		ProxyDialerFn:     m.dialer,
		MinRequestTimeout: m.minRequestTimeout,
	}
}
开发者ID:chiefy,项目名称:kubernetes,代码行数:57,代码来源:master.go

示例9: TestInterfacesFor

func TestInterfacesFor(t *testing.T) {
	if _, err := latest.GroupOrDie("componentconfig").InterfacesFor(""); err == nil {
		t.Fatalf("unexpected non-error: %v", err)
	}
	for i, groupVersion := range append([]unversioned.GroupVersion{latest.GroupOrDie("componentconfig").GroupVersion}, latest.GroupOrDie("componentconfig").GroupVersions...) {
		if vi, err := latest.GroupOrDie("componentconfig").InterfacesFor(groupVersion.String()); err != nil || vi == nil {
			t.Fatalf("%d: unexpected result: %v", i, err)
		}
	}
}
开发者ID:fwalker,项目名称:dashboard,代码行数:10,代码来源:install_test.go

示例10: TestInterfacesFor

func TestInterfacesFor(t *testing.T) {
	if _, err := latest.GroupOrDie("extensions").InterfacesFor(""); err == nil {
		t.Fatalf("unexpected non-error: %v", err)
	}
	for i, groupVersion := range append([]string{latest.GroupOrDie("extensions").GroupVersion}, latest.GroupOrDie("extensions").GroupVersions...) {
		if vi, err := latest.GroupOrDie("extensions").InterfacesFor(groupVersion); err != nil || vi == nil {
			t.Fatalf("%d: unexpected result: %v", i, err)
		}
	}
}
开发者ID:robbfoster-taulia,项目名称:kubernetes,代码行数:10,代码来源:install_test.go

示例11: TestInterfacesFor

func TestInterfacesFor(t *testing.T) {
	if _, err := latest.GroupOrDie(extensions.GroupName).InterfacesFor(extensions.SchemeGroupVersion); err == nil {
		t.Fatalf("unexpected non-error: %v", err)
	}
	for i, version := range latest.GroupOrDie(extensions.GroupName).GroupVersions {
		if vi, err := latest.GroupOrDie(extensions.GroupName).InterfacesFor(version); err != nil || vi == nil {
			t.Fatalf("%d: unexpected result: %v", i, err)
		}
	}
}
开发者ID:nickschuch,项目名称:kube-haproxy,代码行数:10,代码来源:install_test.go

示例12: TestExpapi

// TestExpapi verifies that the unexported exapi creates
// the an experimental unversioned.APIGroupVersion.
func TestExpapi(t *testing.T) {
	master, config, assert := setUp(t)

	expAPIGroup := master.experimental(&config)
	assert.Equal(expAPIGroup.Root, master.apiGroupPrefix)
	assert.Equal(expAPIGroup.Mapper, latest.GroupOrDie("extensions").RESTMapper)
	assert.Equal(expAPIGroup.Codec, latest.GroupOrDie("extensions").Codec)
	assert.Equal(expAPIGroup.Linker, latest.GroupOrDie("extensions").SelfLinker)
	assert.Equal(expAPIGroup.Version, latest.GroupOrDie("extensions").GroupVersion)
}
开发者ID:jas1994,项目名称:kubernetes,代码行数:12,代码来源:master_test.go

示例13: TestCodec

func TestCodec(t *testing.T) {
	pod := internal.Pod{}
	// We do want to use package latest rather than testapi here, because we
	// want to test if the package install and package latest work as expected.
	data, err := latest.GroupOrDie(internal.GroupName).Codec.Encode(&pod)
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}
	other := internal.Pod{}
	if err := json.Unmarshal(data, &other); err != nil {
		t.Fatalf("unexpected error: %v", err)
	}
	if other.APIVersion != latest.GroupOrDie(internal.GroupName).GroupVersion.Version || other.Kind != "Pod" {
		t.Errorf("unexpected unmarshalled object %#v", other)
	}
}
开发者ID:johndmulhausen,项目名称:kubernetes,代码行数:16,代码来源:install_test.go

示例14: init

func init() {
	kubeTestAPI := os.Getenv("KUBE_TEST_API")
	if kubeTestAPI != "" {
		testGroupVersions := strings.Split(kubeTestAPI, ",")
		for _, gvString := range testGroupVersions {
			groupVersion, err := unversioned.ParseGroupVersion(gvString)
			if err != nil {
				panic(fmt.Sprintf("Error parsing groupversion %v: %v", gvString, err))
			}

			Groups[groupVersion.Group] = TestGroup{
				externalGroupVersion: groupVersion,
				internalGroupVersion: unversioned.GroupVersion{Group: groupVersion.Group},
			}
		}
	}

	if _, ok := Groups[api.GroupName]; !ok {
		Groups[api.GroupName] = TestGroup{
			externalGroupVersion: unversioned.GroupVersion{Group: api.GroupName, Version: latest.GroupOrDie(api.GroupName).GroupVersion.Version},
			internalGroupVersion: api.SchemeGroupVersion,
		}
	}
	if _, ok := Groups[extensions.GroupName]; !ok {
		Groups[extensions.GroupName] = TestGroup{
			externalGroupVersion: unversioned.GroupVersion{Group: extensions.GroupName, Version: latest.GroupOrDie(extensions.GroupName).GroupVersion.Version},
			internalGroupVersion: extensions.SchemeGroupVersion,
		}
	}

	Default = Groups[api.GroupName]
	Extensions = Groups[extensions.GroupName]
}
开发者ID:johndmulhausen,项目名称:kubernetes,代码行数:33,代码来源:testapi.go

示例15: SwaggerSchema

// SwaggerSchema retrieves and parses the swagger API schema the server supports.
func (c *Client) SwaggerSchema(version string) (*swagger.ApiDeclaration, error) {
	if version == "" {
		version = latest.GroupOrDie("").Version
	}

	vers, err := c.ServerAPIVersions()
	if err != nil {
		return nil, err
	}

	// This check also takes care the case that kubectl is newer than the running endpoint
	if stringDoesntExistIn(version, vers.Versions) {
		return nil, fmt.Errorf("API version: %s is not supported by the server. Use one of: %v", version, vers.Versions)
	}

	body, err := c.Get().AbsPath("/swaggerapi/api/" + version).Do().Raw()
	if err != nil {
		return nil, err
	}
	var schema swagger.ApiDeclaration
	err = json.Unmarshal(body, &schema)
	if err != nil {
		return nil, fmt.Errorf("got '%s': %v", string(body), err)
	}
	return &schema, nil
}
开发者ID:niniwzw,项目名称:kubernetes,代码行数:27,代码来源:client.go


注:本文中的k8s/io/kubernetes/pkg/api/latest.GroupOrDie函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。