// New creates a new Clientset for the given RESTClient.
973197
func New(c rest.Interface) *Clientset {
	var cs Clientset
	cs.metricsV1alpha1 = metricsv1alpha1.New(c)
	cs.metricsV1beta1 = metricsv1beta1.New(c)

	cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
	return &cs
}
271028
func New(token, environment, codeVersion, serverHost, serverRoot string) *Client {
	return NewAsync(token, environment, codeVersion, serverHost, serverRoot)
}
468041
func New(address string, opts ...ClientOpt) (*Client, error) {
	var copts clientOpts
	for _, o := range opts {
		if err := o(&copts); err != nil {
			return nil, err
		}
	}
	if copts.timeout == 0 {
		copts.timeout = 10 * time.Second
	}
	rt := fmt.Sprintf("%s.%s", plugin.RuntimePlugin, runtime.GOOS)
	if copts.defaultRuntime != "" {
		rt = copts.defaultRuntime
	}
	c := &Client{
		runtime: rt,
	}
	if copts.services != nil {
		c.services = *copts.services
	}
	if address != "" {
		gopts := []grpc.DialOption{
			grpc.WithBlock(),
			grpc.WithInsecure(),
			grpc.FailOnNonTempDialError(true),
			grpc.WithBackoffMaxDelay(3 * time.Second),
			grpc.WithDialer(dialer.Dialer),

			// TODO(stevvooe): We may need to allow configuration of this on the client.
			grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(defaults.DefaultMaxRecvMsgSize)),
			grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(defaults.DefaultMaxSendMsgSize)),
		}
		if len(copts.dialOptions) > 0 {
			gopts = copts.dialOptions
		}
		if copts.defaultns != "" {
			unary, stream := newNSInterceptors(copts.defaultns)
			gopts = append(gopts,
				grpc.WithUnaryInterceptor(unary),
				grpc.WithStreamInterceptor(stream),
			)
		}
		connector := func() (*grpc.ClientConn, error) {
			ctx, cancel := context.WithTimeout(context.Background(), copts.timeout)
			defer cancel()
			conn, err := grpc.DialContext(ctx, dialer.DialAddress(address), gopts...)
			if err != nil {
				return nil, errors.Wrapf(err, "failed to dial %q", address)
			}
			return conn, nil
		}
		conn, err := connector()
		if err != nil {
			return nil, err
		}
		c.conn, c.connector = conn, connector
	}
	if copts.services == nil && c.conn == nil {
		return nil, errors.New("no grpc connection or services is available")
	}

	// check namespace labels for default runtime
	if copts.defaultRuntime == "" && copts.defaultns != "" {
		namespaces := c.NamespaceService()
		ctx := context.Background()
		if labels, err := namespaces.Labels(ctx, copts.defaultns); err == nil {
			if defaultRuntime, ok := labels[defaults.DefaultRuntimeNSLabel]; ok {
				c.runtime = defaultRuntime
			}
		} else {
			return nil, err
		}
	}

	return c, nil
}
1124923
func New(c rest.Interface) *Clientset {
	var cs Clientset
	cs.kops = kopsinternalversion.New(c)
	cs.kopsV1alpha1 = kopsv1alpha1.New(c)
	cs.kopsV1alpha2 = kopsv1alpha2.New(c)

	cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
	return &cs
}
547883
func New(rs *resources.Spec) *Client {
	return &Client{rs: rs, m: minifiers.New(rs.MediaTypes, rs.OutputFormats)}
}
86370
func New(c rest.Interface) *Clientset {
	var cs Clientset
	cs.apiregistrationV1beta1 = apiregistrationv1beta1.New(c)
	cs.apiregistrationV1 = apiregistrationv1.New(c)

	cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
	return &cs
}
229833
func New(addr string) *Client {
	return &Client{Address: addr, Client: &http.Client{}}
}
366542
func New(opts ...ClientOption) (*Client, error) {
	c := &Client{
		haveCache: noHaveCache{},
		Logger:    log.New(os.Stderr, "", log.Ldate|log.Ltime),
		authMode:  auth.None{},
	}
	for _, v := range opts {
		v.modifyClient(c)
	}
	if c.sto != nil && len(opts) > 1 {
		return nil, errors.New("use of OptionUseStorageClient precludes use of any other options")
	}

	if inGopherJS {
		c.noExtConfig = true
		c.sameOrigin = true
	}
	if c.noExtConfig {
		c.setDefaultHTTPClient()
		return c, nil
	}

	if c.server != "" {
		if !isURLOrHostPort(c.server) {
			configOnce.Do(parseConfig)
			serverConf, ok := config.Servers[c.server]
			if !ok {
				log.Fatalf("%q looks like a server alias, but no such alias found in config at %v", c.server, osutil.UserClientConfigPath())
			}
			c.server = serverConf.Server
		}
		c.setDefaultHTTPClient()
		return c, nil
	}

	var err error
	c.server, err = getServer()
	if err != nil {
		return nil, err
	}
	err = c.SetupAuth()
	if err != nil {
		return nil, err
	}
	c.setDefaultHTTPClient()
	return c, nil
}
248888
func New(dispatcher eventservice.Dispatcher, opts ...options.Opt) *Client {
	params := defaultParams()
	options.Apply(params, opts)

	return &Client{
		Service:         eventservice.New(dispatcher, opts...),
		params:          *params,
		connectionState: int32(Disconnected),
	}
}
662112
func New(c rest.Interface) *Clientset {
	var cs Clientset
	cs.project = projectinternalversion.New(c)

	cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
	return &cs
}
303657
func New(network, addr string) (client *Client, err error) {
	client = &Client{
		net:             network,
		addr:            addr,
		respHandler:     newResponseHandlerMap(),
		innerHandler:    newResponseHandlerMap(),
		in:              make(chan *Response, queueSize),
		ResponseTimeout: DefaultTimeout,
	}
	client.conn, err = net.Dial(client.net, client.addr)
	if err != nil {
		return
	}
	client.rw = bufio.NewReadWriter(bufio.NewReader(client.conn),
		bufio.NewWriter(client.conn))
	go client.readLoop()
	go client.processLoop()
	return
}
968791
func New(key string) *Client {
	config := ClientConfig{
		Scheme: defaultScheme,
		Host:   defaultHost,
		Port:   defaultPort,
		Key:    key,
	}
	return NewWithConfig(config)
}
1161926
func New(c []config.Client) {
	for _, v := range c {
		var scopes []Scope
		for _, scope := range v.Scopes {
			scopes = append(scopes, Scope(scope))
		}
		clients = append(clients, Client{
			Serial: v.Serial,
			Scopes: scopes,
		})
	}
}
831823
func New(endpoints []string, ca, cert, key string) (*Client, error) {
	client := Client{Endpoints: endpoints}

	if ca != "" || cert != "" || key != "" {
		tlsInfo := transport.TLSInfo{
			CertFile:      cert,
			KeyFile:       key,
			TrustedCAFile: ca,
		}
		tlsConfig, err := tlsInfo.ClientConfig()
		if err != nil {
			return nil, err
		}
		client.TLS = tlsConfig
	}

	return &client, nil
}
207135
func New(c rest.Interface) *Clientset {
	var cs Clientset
	cs.ciliumV2 = ciliumv2.New(c)

	cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
	return &cs
}
179259
func New(iface netlink.Link, opts ...ClientOpt) (*Client, error) {
	c := &Client{
		iface:   iface,
		timeout: 10 * time.Second,
		retry:   3,
	}

	for _, opt := range opts {
		if err := opt(c); err != nil {
			return nil, err
		}
	}

	if c.conn == nil {
		var err error
		c.conn, err = NewPacketUDPConn(iface.Attrs().Name, ClientPort)
		if err != nil {
			return nil, err
		}
	}
	return c, nil
}
568304
func NewForConfig(c *rest.Config) (*Clientset, error) {
	configShallowCopy := *c
	if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
		configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
	}
	var cs Clientset
	var err error
	cs.wardleV1alpha1, err = wardlev1alpha1.NewForConfig(&configShallowCopy)
	if err != nil {
		return nil, err
	}
	cs.wardleV1beta1, err = wardlev1beta1.NewForConfig(&configShallowCopy)
	if err != nil {
		return nil, err
	}

	cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
	if err != nil {
		return nil, err
	}
	return &cs, nil
}