github.com/argoproj/argo-cd/v2@v2.10.9/pkg/client/clientset/versioned/clientset.go (about) 1 // Code generated by client-gen. DO NOT EDIT. 2 3 package versioned 4 5 import ( 6 "fmt" 7 "net/http" 8 9 argoprojv1alpha1 "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned/typed/application/v1alpha1" 10 discovery "k8s.io/client-go/discovery" 11 rest "k8s.io/client-go/rest" 12 flowcontrol "k8s.io/client-go/util/flowcontrol" 13 ) 14 15 type Interface interface { 16 Discovery() discovery.DiscoveryInterface 17 ArgoprojV1alpha1() argoprojv1alpha1.ArgoprojV1alpha1Interface 18 } 19 20 // Clientset contains the clients for groups. 21 type Clientset struct { 22 *discovery.DiscoveryClient 23 argoprojV1alpha1 *argoprojv1alpha1.ArgoprojV1alpha1Client 24 } 25 26 // ArgoprojV1alpha1 retrieves the ArgoprojV1alpha1Client 27 func (c *Clientset) ArgoprojV1alpha1() argoprojv1alpha1.ArgoprojV1alpha1Interface { 28 return c.argoprojV1alpha1 29 } 30 31 // Discovery retrieves the DiscoveryClient 32 func (c *Clientset) Discovery() discovery.DiscoveryInterface { 33 if c == nil { 34 return nil 35 } 36 return c.DiscoveryClient 37 } 38 39 // NewForConfig creates a new Clientset for the given config. 40 // If config's RateLimiter is not set and QPS and Burst are acceptable, 41 // NewForConfig will generate a rate-limiter in configShallowCopy. 42 // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), 43 // where httpClient was generated with rest.HTTPClientFor(c). 44 func NewForConfig(c *rest.Config) (*Clientset, error) { 45 configShallowCopy := *c 46 47 if configShallowCopy.UserAgent == "" { 48 configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() 49 } 50 51 // share the transport between all clients 52 httpClient, err := rest.HTTPClientFor(&configShallowCopy) 53 if err != nil { 54 return nil, err 55 } 56 57 return NewForConfigAndClient(&configShallowCopy, httpClient) 58 } 59 60 // NewForConfigAndClient creates a new Clientset for the given config and http client. 61 // Note the http client provided takes precedence over the configured transport values. 62 // If config's RateLimiter is not set and QPS and Burst are acceptable, 63 // NewForConfigAndClient will generate a rate-limiter in configShallowCopy. 64 func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { 65 configShallowCopy := *c 66 if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { 67 if configShallowCopy.Burst <= 0 { 68 return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") 69 } 70 configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) 71 } 72 73 var cs Clientset 74 var err error 75 cs.argoprojV1alpha1, err = argoprojv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 76 if err != nil { 77 return nil, err 78 } 79 80 cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) 81 if err != nil { 82 return nil, err 83 } 84 return &cs, nil 85 } 86 87 // NewForConfigOrDie creates a new Clientset for the given config and 88 // panics if there is an error in the config. 89 func NewForConfigOrDie(c *rest.Config) *Clientset { 90 cs, err := NewForConfig(c) 91 if err != nil { 92 panic(err) 93 } 94 return cs 95 } 96 97 // New creates a new Clientset for the given RESTClient. 98 func New(c rest.Interface) *Clientset { 99 var cs Clientset 100 cs.argoprojV1alpha1 = argoprojv1alpha1.New(c) 101 102 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 103 return &cs 104 }