• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang restclient.RESTClientFor函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ClientForMapping

func (f *ring1Factory) ClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error) {
	cfg, err := f.clientAccessFactory.ClientConfig()
	if err != nil {
		return nil, err
	}
	if err := client.SetKubernetesDefaults(cfg); err != nil {
		return nil, err
	}
	gvk := mapping.GroupVersionKind
	switch gvk.Group {
	case federation.GroupName:
		mappingVersion := mapping.GroupVersionKind.GroupVersion()
		return f.clientAccessFactory.FederationClientForVersion(&mappingVersion)
	case api.GroupName:
		cfg.APIPath = "/api"
	default:
		cfg.APIPath = "/apis"
	}
	gv := gvk.GroupVersion()
	cfg.GroupVersion = &gv
	if api.Registry.IsThirdPartyAPIGroupVersion(gvk.GroupVersion()) {
		cfg.NegotiatedSerializer = thirdpartyresourcedata.NewNegotiatedSerializer(api.Codecs, gvk.Kind, gv, gv)
	}
	return restclient.RESTClientFor(cfg)
}
开发者ID:kubernetes,项目名称:kubernetes,代码行数:25,代码来源:factory_object_mapping.go


示例2: NewClient

// NewClient returns a new client based on the passed in config. The
// codec is ignored, as the dynamic client uses it's own codec.
func NewClient(conf *restclient.Config) (*Client, error) {
	// avoid changing the original config
	confCopy := *conf
	conf = &confCopy

	contentConfig := ContentConfig()
	contentConfig.GroupVersion = conf.GroupVersion
	if conf.NegotiatedSerializer != nil {
		contentConfig.NegotiatedSerializer = conf.NegotiatedSerializer
	}
	conf.ContentConfig = contentConfig

	if conf.APIPath == "" {
		conf.APIPath = "/api"
	}

	if len(conf.UserAgent) == 0 {
		conf.UserAgent = restclient.DefaultKubernetesUserAgent()
	}

	cl, err := restclient.RESTClientFor(conf)
	if err != nil {
		return nil, err
	}

	return &Client{cl: cl}, nil
}
开发者ID:ncdc,项目名称:kubernetes,代码行数:29,代码来源:client.go


示例3: NewClient

// NewClient returns a new client based on the passed in config. The
// codec is ignored, as the dynamic client uses it's own codec.
func NewClient(conf *restclient.Config) (*Client, error) {
	// avoid changing the original config
	confCopy := *conf
	conf = &confCopy

	// TODO: it's questionable that this should be using anything other than unstructured schema and JSON
	conf.ContentType = runtime.ContentTypeJSON
	conf.AcceptContentTypes = runtime.ContentTypeJSON

	if conf.APIPath == "" {
		conf.APIPath = "/api"
	}

	if len(conf.UserAgent) == 0 {
		conf.UserAgent = restclient.DefaultKubernetesUserAgent()
	}
	if conf.NegotiatedSerializer == nil {
		streamingInfo, _ := api.Codecs.StreamingSerializerForMediaType("application/json;stream=watch", nil)
		conf.NegotiatedSerializer = serializer.NegotiatedSerializerWrapper(runtime.SerializerInfo{Serializer: dynamicCodec{}}, streamingInfo)
	}

	cl, err := restclient.RESTClientFor(conf)
	if err != nil {
		return nil, err
	}

	return &Client{cl: cl}, nil
}
开发者ID:AdoHe,项目名称:kubernetes,代码行数:30,代码来源:client.go


示例4: NewClient

// NewClient returns a new client based on the passed in config. The
// codec is ignored, as the dynamic client uses it's own codec.
func NewClient(conf *restclient.Config) (*Client, error) {
	// avoid changing the original config
	confCopy := *conf
	conf = &confCopy

	conf.Codec = dynamicCodec{}

	if conf.APIPath == "" {
		conf.APIPath = "/api"
	}

	if len(conf.UserAgent) == 0 {
		conf.UserAgent = restclient.DefaultKubernetesUserAgent()
	}

	if conf.QPS == 0.0 {
		conf.QPS = 5.0
	}
	if conf.Burst == 0 {
		conf.Burst = 10
	}

	cl, err := restclient.RESTClientFor(conf)
	if err != nil {
		return nil, err
	}

	return &Client{cl: cl}, nil
}
开发者ID:CNDonny,项目名称:scope,代码行数:31,代码来源:client.go


示例5: Validator

func (f *factory) Validator(validate bool, cacheDir string) (validation.Schema, error) {
	if validate {
		clientConfig, err := f.clients.ClientConfigForVersion(nil)
		if err != nil {
			return nil, err
		}
		restclient, err := restclient.RESTClientFor(clientConfig)
		if err != nil {
			return nil, err
		}
		clientset, err := f.clients.ClientSetForVersion(nil)
		if err != nil {
			return nil, err
		}
		dir := cacheDir
		if len(dir) > 0 {
			version, err := clientset.Discovery().ServerVersion()
			if err == nil {
				dir = path.Join(cacheDir, version.String())
			} else {
				dir = "" // disable caching as a fallback
			}
		}
		fedClient, err := f.clients.FederationClientForVersion(nil)
		if err != nil {
			return nil, err
		}
		return &clientSwaggerSchema{
			c:        restclient,
			fedc:     fedClient,
			cacheDir: dir,
		}, nil
	}
	return validation.NullSchema{}, nil
}
开发者ID:Random-Liu,项目名称:kubernetes,代码行数:35,代码来源:factory.go


示例6: RESTClient

func (f *fakeAPIFactory) RESTClient() (*restclient.RESTClient, error) {
	// Swap out the HTTP client out of the client with the fake's version.
	fakeClient := f.tf.Client.(*fake.RESTClient)
	restClient, err := restclient.RESTClientFor(f.tf.ClientConfig)
	if err != nil {
		panic(err)
	}
	restClient.Client = fakeClient.Client
	return restClient, f.tf.Err
}
开发者ID:nak3,项目名称:kubernetes,代码行数:10,代码来源:fake.go


示例7: NewExtensions

// NewExtensions creates a new ExtensionsClient for the given config. This client
// provides access to experimental Kubernetes features.
// Features of Extensions group are not supported and may be changed or removed in
// incompatible ways at any time.
func NewExtensions(c *restclient.Config) (*ExtensionsClient, error) {
	config := *c
	if err := setGroupDefaults(extensions.GroupName, &config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &ExtensionsClient{client}, nil
}
开发者ID:ncdc,项目名称:kubernetes,代码行数:15,代码来源:extensions.go


示例8: NewAuthorization

func NewAuthorization(c *restclient.Config) (*AuthorizationClient, error) {
	config := *c
	if err := setAuthorizationDefaults(&config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &AuthorizationClient{client}, nil
}
开发者ID:CodeJuan,项目名称:kubernetes,代码行数:11,代码来源:authorization.go


示例9: NewPolicy

func NewPolicy(c *restclient.Config) (*PolicyClient, error) {
	config := *c
	if err := setGroupDefaults(policy.GroupName, &config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &PolicyClient{client}, nil
}
开发者ID:CodeJuan,项目名称:kubernetes,代码行数:11,代码来源:policy.go


示例10: NewBatch

func NewBatch(c *restclient.Config) (*BatchClient, error) {
	config := *c
	if err := setGroupDefaults(batch.GroupName, &config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &BatchClient{client}, nil
}
开发者ID:CodeJuan,项目名称:kubernetes,代码行数:11,代码来源:batch.go


示例11: NewRbac

// NewRbac creates a new RbacClient for the given config.
func NewRbac(c *restclient.Config) (*RbacClient, error) {
	config := *c
	if err := setRbacDefaults(&config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &RbacClient{client}, nil
}
开发者ID:Cloven,项目名称:minikube,代码行数:12,代码来源:rbac.go


示例12: NewBatchV2Alpha1

func NewBatchV2Alpha1(c *restclient.Config) (*BatchClient, error) {
	config := *c
	if err := setBatchDefaults(&config, &v2alpha1.SchemeGroupVersion); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &BatchClient{client}, nil
}
开发者ID:Cloven,项目名称:minikube,代码行数:11,代码来源:batch.go


示例13: NewForConfig

// NewForConfig creates a new ApiregistrationV1alpha1Client for the given config.
func NewForConfig(c *restclient.Config) (*ApiregistrationV1alpha1Client, error) {
	config := *c
	if err := setConfigDefaults(&config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &ApiregistrationV1alpha1Client{client}, nil
}
开发者ID:kubernetes,项目名称:kubernetes,代码行数:12,代码来源:apiregistration_client.go


示例14: NewForConfig

// NewForConfig creates a new CertificatesV1alpha1Client for the given config.
func NewForConfig(c *restclient.Config) (*CertificatesV1alpha1Client, error) {
	config := *c
	if err := setConfigDefaults(&config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &CertificatesV1alpha1Client{client}, nil
}
开发者ID:eljefedelrodeodeljefe,项目名称:kubernetes,代码行数:12,代码来源:certificates_client.go


示例15: NewStorage

func NewStorage(c *restclient.Config) (*StorageClient, error) {
	config := *c
	if err := setStorageDefaults(&config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &StorageClient{client}, nil
}
开发者ID:ncdc,项目名称:kubernetes,代码行数:11,代码来源:storage.go


示例16: NewApps

func NewApps(c *restclient.Config) (*AppsClient, error) {
	config := *c
	if err := setAppsDefaults(&config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &AppsClient{client}, nil
}
开发者ID:XbinZh,项目名称:kubernetes,代码行数:11,代码来源:apps.go


示例17: NewForConfig

// NewForConfig creates a new PolicyV1beta1Client for the given config.
func NewForConfig(c *restclient.Config) (*PolicyV1beta1Client, error) {
	config := *c
	if err := setConfigDefaults(&config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &PolicyV1beta1Client{client}, nil
}
开发者ID:nak3,项目名称:kubernetes,代码行数:12,代码来源:policy_client.go


示例18: NewAutoscaling

func NewAutoscaling(c *restclient.Config) (*AutoscalingClient, error) {
	config := *c
	if err := setAutoscalingDefaults(&config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &AutoscalingClient{client}, nil
}
开发者ID:RyanBinfeng,项目名称:kubernetes,代码行数:11,代码来源:autoscaling.go


示例19: New

// New creates an OpenShift client for the given config. This client works with builds, deployments,
// templates, routes, and images. It allows operations such as list, get, update and delete on these
// objects. An error is returned if the provided configuration is not valid.
func New(c *restclient.Config) (*Client, error) {
	config := *c
	if err := SetOpenShiftDefaults(&config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}

	return &Client{client}, nil
}
开发者ID:RomainVabre,项目名称:origin,代码行数:15,代码来源:client.go


示例20: New

// New creates a Kubernetes client for the given config. This client works with pods,
// replication controllers, daemons, and services. It allows operations such as list, get, update
// and delete on these objects. An error is returned if the provided configuration
// is not valid.
func New(c *restclient.Config) (*Client, error) {
	config := *c
	if err := SetKubernetesDefaults(&config); err != nil {
		return nil, err
	}
	client, err := restclient.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}

	discoveryConfig := *c
	discoveryClient, err := discovery.NewDiscoveryClientForConfig(&discoveryConfig)
	if err != nil {
		return nil, err
	}

	var autoscalingClient *AutoscalingClient
	if registered.IsRegistered(autoscaling.GroupName) {
		autoscalingConfig := *c
		autoscalingClient, err = NewAutoscaling(&autoscalingConfig)
		if err != nil {
			return nil, err
		}
	}

	var batchClient *BatchClient
	if registered.IsRegistered(batch.GroupName) {
		batchConfig := *c
		batchClient, err = NewBatch(&batchConfig)
		if err != nil {
			return nil, err
		}
	}

	var extensionsClient *ExtensionsClient
	if registered.IsRegistered(extensions.GroupName) {
		extensionsConfig := *c
		extensionsClient, err = NewExtensions(&extensionsConfig)
		if err != nil {
			return nil, err
		}
	}
	var appsClient *AppsClient
	if registered.IsRegistered(apps.GroupName) {
		appsConfig := *c
		appsClient, err = NewApps(&appsConfig)
		if err != nil {
			return nil, err
		}
	}

	return &Client{RESTClient: client, AutoscalingClient: autoscalingClient, BatchClient: batchClient, ExtensionsClient: extensionsClient, DiscoveryClient: discoveryClient, AppsClient: appsClient}, nil
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:57,代码来源:helper.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang restclient.ServerAPIVersions函数代码示例发布时间:2022-05-28
下一篇:
Golang restclient.LoadTLSFiles函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap