func LoadClientConfigFromBytes(b []byte) (*api.CalicoAPIConfig, error) {
	var c api.CalicoAPIConfig
	log.Info("Loading config from JSON or YAML data")
	c = api.CalicoAPIConfig{
		Spec: api.CalicoAPIConfigSpec{
			DatastoreType: api.EtcdV2,
		},
	}
	if err := yaml.UnmarshalStrict(b, &c); err != nil {
		return nil, err
	}
	if c.APIVersion != unversioned.VersionCurrent {
		return nil, goerrors.New("invalid config file: unknown APIVersion '" + c.APIVersion + "'")
	}
	if c.Kind != "calicoApiConfig" {
		return nil, goerrors.New("invalid config file: expected kind 'calicoApiConfig', got '" + c.Kind + "'")
	}
	log.Info("Datastore type: ", c.Spec.DatastoreType)
	return &c, nil
}
LoadClientConfig loads the ClientConfig from the supplied bytes containing
YAML or JSON format data.
package client
import (
	"context"
	goerrors "errors"
	"fmt"
	"io/ioutil"
	"reflect"
	"github.com/kelseyhightower/envconfig"
	log "github.com/sirupsen/logrus"
	"github.com/projectcalico/go-yaml-wrapper"
	"github.com/projectcalico/libcalico-go/lib/apiconfig"
	api "github.com/projectcalico/libcalico-go/lib/apis/v1"
	"github.com/projectcalico/libcalico-go/lib/apis/v1/unversioned"
	"github.com/projectcalico/libcalico-go/lib/backend"
	bapi "github.com/projectcalico/libcalico-go/lib/backend/api"
	"github.com/projectcalico/libcalico-go/lib/backend/model"
	validator "github.com/projectcalico/libcalico-go/lib/validator/v1"
)
type Client struct {
	Backend bapi.Client
}
func New(config apiconfig.CalicoAPIConfig) (*Client, error) {
	var err error
	cc := Client{}
	if cc.Backend, err = backend.NewClient(config); err != nil {
		return nil, err
	}
	return &cc, err
}
func NewFromEnv() (*Client, error) {
	config, err := apiconfig.LoadClientConfigFromEnvironment()
	if err != nil {
		return nil, err
	}
	return New(*config)
}
func (c *Client) Nodes() NodeInterface {
	return newNodes(c)
}
func (c *Client) Policies() PolicyInterface {
	return newPolicies(c)
}
func (c *Client) IPPools() IPPoolInterface {
	return newIPPools(c)
}
func (c *Client) Profiles() ProfileInterface {
	return newProfiles(c)
}
func (c *Client) HostEndpoints() HostEndpointInterface {
	return newHostEndpoints(c)
}
func (c *Client) WorkloadEndpoints() WorkloadEndpointInterface {
	return newWorkloadEndpoints(c)
}
func (c *Client) BGPPeers() BGPPeerInterface {
	return newBGPPeers(c)
}
func (c *Client) Config() ConfigInterface {
	return newConfigs(c)
}
func (c *Client) EnsureInitialized() error {
	if err := c.Backend.EnsureInitialized(); err != nil {
		return err
	}
	return nil
}
func LoadClientConfig(filename string) (*api.CalicoAPIConfig, error) {
	if filename != "" {
		b, err := ioutil.ReadFile(filename)
		if err != nil {
			return nil, err
		}
		c, err := LoadClientConfigFromBytes(b)
		if err != nil {
			return nil, fmt.Errorf("syntax error in %s: %v", filename, err)
		}
		return c, nil
	} else {
		return LoadClientConfigFromEnvironment()
	}
}