1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-19 07:17:30 +00:00
rke/vendor/github.com/alena1108/cluster-controller/client/v1/client.go
2017-11-09 21:49:32 +02:00

64 lines
1.3 KiB
Go

package v1
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/rest"
)
const (
Group = "rancher.com"
)
var Version = "v1"
type ClustersManagerV1Interface interface {
RESTClient() rest.Interface
ClustersGetter
}
type ClustersManagerV1Client struct {
restClient rest.Interface
dynamicClient *dynamic.Client
}
func (c *ClustersManagerV1Client) Clusters() ClusterInterface {
return newClusters(c.restClient, c.dynamicClient)
}
func (c *ClustersManagerV1Client) ClusterNodes() ClusterNodeInterface {
return newClusterNodes(c.restClient, c.dynamicClient)
}
func (c *ClustersManagerV1Client) RESTClient() rest.Interface {
return c.restClient
}
func NewForConfig(c *rest.Config) (*ClustersManagerV1Client, error) {
config := *c
SetConfigDefaults(&config)
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
dynamicClient, err := dynamic.NewClient(&config)
if err != nil {
return nil, err
}
return &ClustersManagerV1Client{client, dynamicClient}, nil
}
func SetConfigDefaults(config *rest.Config) {
config.GroupVersion = &schema.GroupVersion{
Group: Group,
Version: Version,
}
config.APIPath = "/apis"
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: api.Codecs}
return
}