func SetKubernetesDefaults(config *Config) error {
	if config.Prefix == "" {
		config.Prefix = "/api"
	}
	if len(config.UserAgent) == 0 {
		config.UserAgent = DefaultKubernetesUserAgent()
	}
	if len(config.Version) == 0 {
		config.Version = defaultVersionFor(config)
	}
	version := config.Version
	versionInterfaces, err := latest.InterfacesFor(version)
	if err != nil {
		return fmt.Errorf("API version '%s' is not recognized (valid values: %s)", version, strings.Join(latest.Versions, ", "))
	}
	if config.Codec == nil {
		config.Codec = versionInterfaces.Codec
	}
	config.LegacyBehavior = (version == "v1beta1" || version == "v1beta2")
	return nil
}
SetKubernetesDefaults sets default values on the provided client config for accessing the
Kubernetes API or returns an error if any of the defaults are impossible or invalid.
package client
import (
	"fmt"
	"net"
	"net/http"
	"net/url"
	"os"
	"path"
	"reflect"
	gruntime "runtime"
	"strings"
	"time"
	"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
	"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
	"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
)
type Config struct {
	Host string
	Prefix string
	Version string
	LegacyBehavior bool
	Codec runtime.Codec
	Username string
	Password string
	BearerToken string
	TLSClientConfig
	Insecure bool
	UserAgent string
	Transport http.RoundTripper
}
type KubeletConfig struct {
	Port        uint
	EnableHttps bool
	TLSClientConfig
}
type TLSClientConfig struct {
	CertFile string
	KeyFile string
	CAFile string
	CertData []byte
	KeyData []byte
	CAData []byte
}
func New(c *Config) (*Client, error) {
	config := *c
	if err := SetKubernetesDefaults(&config); err != nil {
		return nil, err
	}
	client, err := RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &Client{client}, nil
}
func MatchesServerVersion(c *Config) error {
	client, err := New(c)
	if err != nil {
		return err
	}
	clientVersion := version.Get()
	serverVersion, err := client.ServerVersion()
	if err != nil {
		return fmt.Errorf("couldn't read version from server: %v\n", err)
	}
	if s := *serverVersion; !reflect.DeepEqual(clientVersion, s) {
		return fmt.Errorf("server version (%#v) differs from client version (%#v)!\n", s, clientVersion)
	}
	return nil
}
func NewOrDie(c *Config) *Client {
	client, err := New(c)
	if err != nil {
		panic(err)
	}
	return client
}