本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/restclient.RESTClientFor函数的典型用法代码示例。如果您正苦于以下问题:Golang RESTClientFor函数的具体用法?Golang RESTClientFor怎么用?Golang RESTClientFor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RESTClientFor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}