func NewConfig(torusRoot string) (*Config, error) {
	preferences, err := prefs.NewPreferences(true)
	if err != nil {
		return nil, err
	}

	publicKey, err := prefs.LoadPublicKey(preferences)
	if err != nil {
		return nil, fmt.Errorf("Failed to load public key.")
	}

	caBundle, err := loadCABundle(preferences.Core.CABundleFile)
	if err != nil {
		return nil, err
	}

	registryURI, err := url.Parse(preferences.Core.RegistryURI)
	if err != nil {
		return nil, fmt.Errorf("Invalid registry_uri.")
	}

	cfg := &Config{
		APIVersion: apiVersion,
		Version:    Version,

		TorusRoot:  torusRoot,
		SocketPath: path.Join(torusRoot, "daemon.socket"),
		PidPath:    path.Join(torusRoot, "daemon.pid"),
		DBPath:     path.Join(torusRoot, "daemon.db"),

		RegistryURI: registryURI,
		CABundle:    caBundle,
		PublicKey:   publicKey,
	}

	return cfg, nil
}
// NewConfig returns a new Config, with loaded user preferences.
NewConfig returns a new Config, with loaded user preferences.
// NewConfig returns a new Config with loaded user preferences .
func NewConfig(torusRoot string) (*Config, error) {
	preferences, err := prefs.NewPreferences(true)
	if err != nil {
		return nil, err
	}
	publicKey, err := prefs.LoadPublicKey(preferences)
	if err != nil {
		return nil, fmt.Errorf("Failed to load public key.")
	}
	caBundle, err := loadCABundle(preferences.Core.CABundleFile)
	if err != nil {
		return nil, err
	}
	registryURI, err := url.Parse(preferences.Core.RegistryURI)
	if err != nil {
		return nil, fmt.Errorf("Invalid registry_uri.")
	}
	cfg := &Config{
		APIVersion: apiVersion,
		Version:    Version,
		TorusRoot:  torusRoot,
		SocketPath: path.Join(torusRoot, "daemon.socket"),
		PidPath:    path.Join(torusRoot, "daemon.pid"),
		DBPath:     path.Join(torusRoot, "daemon.db"),
		RegistryURI: registryURI,
		CABundle:    caBundle,
		PublicKey:   publicKey,
	}
	return cfg, nil
}
func NewConfig ( torusRoot string ) ( * Config , error ) { preferences , err := prefs . NewPreferences ( true ) if err != nil { return nil , err } publicKey , err := prefs . LoadPublicKey ( preferences ) if err != nil { return nil , fmt . Errorf ( " " ) } caBundle , err := loadCABundle ( preferences . Core . CABundleFile ) if err != nil { return nil , err } registryURI , err := url . Parse ( preferences . Core . RegistryURI ) if err != nil { return nil , fmt . Errorf ( " " ) } cfg := & Config { APIVersion : apiVersion , Version : Version , TorusRoot : torusRoot , SocketPath : path . Join ( torusRoot , " " ) , PidPath : path . Join ( torusRoot , " " ) , DBPath : path . Join ( torusRoot , " " ) , RegistryURI : registryURI , CABundle : caBundle , PublicKey : publicKey , } return cfg , nil }
NewConfig returns a new Config, with loaded user preferences.
NewConfig returns a new Config with loaded user preferences .