// NewClient creates a new CalicoClient using connection information in the specified
// filename (if it exists), dropping back to environment variables for any
// parameter not loaded from file.
func NewClient(cf string) (*client.Client, error) {
	cfg, err := LoadClientConfig(cf)
	if err != nil {
		log.Info("Error loading config")
		return nil, err
	}
	log.Infof("Loaded client config: %#v", cfg.Spec)

	c, err := client.New(*cfg)
	if err != nil {
		return nil, err
	}

	return c, err
}
示例#2
0
func initializeClient() {
	var err error

	if config, err = datastoreClient.LoadClientConfig(""); err != nil {
		panic(err)
	}
	if client, err = datastoreClient.New(*config); err != nil {
		panic(err)
	}

	if os.Getenv("CALICO_DEBUG") != "" {
		log.SetLevel(log.DebugLevel)
		log.Debugln("Debug logging enabled")
	}
}