cluster_client.go 2.4 KB
Newer Older
Z
zryfish 已提交
1
/*
2
Copyright 2020 The KubeSphere Authors.
Z
zryfish 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Code generated by client-gen. DO NOT EDIT.

package v1alpha1

import (
	rest "k8s.io/client-go/rest"
Z
zryfish 已提交
23
	v1alpha1 "kubesphere.io/kubesphere/pkg/apis/cluster/v1alpha1"
Z
zryfish 已提交
24 25 26
	"kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme"
)

Z
zryfish 已提交
27
type ClusterV1alpha1Interface interface {
Z
zryfish 已提交
28
	RESTClient() rest.Interface
Z
zryfish 已提交
29
	ClustersGetter
Z
zryfish 已提交
30 31
}

Z
zryfish 已提交
32 33
// ClusterV1alpha1Client is used to interact with features provided by the cluster.kubesphere.io group.
type ClusterV1alpha1Client struct {
Z
zryfish 已提交
34 35 36
	restClient rest.Interface
}

Z
zryfish 已提交
37 38 39 40 41 42
func (c *ClusterV1alpha1Client) Clusters() ClusterInterface {
	return newClusters(c)
}

// NewForConfig creates a new ClusterV1alpha1Client for the given config.
func NewForConfig(c *rest.Config) (*ClusterV1alpha1Client, error) {
Z
zryfish 已提交
43 44 45 46 47 48 49 50
	config := *c
	if err := setConfigDefaults(&config); err != nil {
		return nil, err
	}
	client, err := rest.RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
Z
zryfish 已提交
51
	return &ClusterV1alpha1Client{client}, nil
Z
zryfish 已提交
52 53
}

Z
zryfish 已提交
54
// NewForConfigOrDie creates a new ClusterV1alpha1Client for the given config and
Z
zryfish 已提交
55
// panics if there is an error in the config.
Z
zryfish 已提交
56
func NewForConfigOrDie(c *rest.Config) *ClusterV1alpha1Client {
Z
zryfish 已提交
57 58 59 60 61 62 63
	client, err := NewForConfig(c)
	if err != nil {
		panic(err)
	}
	return client
}

Z
zryfish 已提交
64 65 66
// New creates a new ClusterV1alpha1Client for the given RESTClient.
func New(c rest.Interface) *ClusterV1alpha1Client {
	return &ClusterV1alpha1Client{c}
Z
zryfish 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
}

func setConfigDefaults(config *rest.Config) error {
	gv := v1alpha1.SchemeGroupVersion
	config.GroupVersion = &gv
	config.APIPath = "/apis"
	config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()

	if config.UserAgent == "" {
		config.UserAgent = rest.DefaultKubernetesUserAgent()
	}

	return nil
}

// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
Z
zryfish 已提交
84
func (c *ClusterV1alpha1Client) RESTClient() rest.Interface {
Z
zryfish 已提交
85 86 87 88 89
	if c == nil {
		return nil
	}
	return c.restClient
}