Example #1
0
func (cont *NodeController) LoadConfig() error {
	logger.Debug("loading node config")
	var err error

	if cont.config == nil {
		logger.Debug("creating empty config")
		cont.config, err = config.NewNode()
		if err != nil {
			return err
		}
	}

	exists, err := cont.env.fs.local.Exists(NodeConfigFile)
	if err != nil {
		return err
	}

	if exists {
		logger.Debugf("reading local file '%s'", NodeConfigFile)
		nodeConfig, err := cont.env.fs.local.Read(NodeConfigFile)
		if err != nil {
			return err
		}

		logger.Debug("loading config")
		if err := cont.config.Load(nodeConfig); err != nil {
			return err
		}
	}

	logger.Trace("returning nil error")
	return nil
}
Example #2
0
func (app *NodeApp) CreateNodeConfig() {
	logger.Info("Creating node config")
	var err error
	app.config.node, err = config.NewNode()
	checkAppFatal("Couldn't initialize node config: %s", err)
	err = app.config.node.AddNode(app.entities.node.Data.Body.Name, app.entities.node.Data.Body.Id, app.index.node.Data.Body.Id)
	checkUserFatal("Cannot add node to node config: %s", err)
}
Example #3
0
func (app *NodeApp) LoadNodeConfig() {
	var err error
	nodeConfig, err := app.fs.local.Read(NodeConfigFile)
	checkAppFatal("Couldn't read node config: %s", err)
	app.config.node, err = config.NewNode()
	checkAppFatal("Couldn't initialize org config: %s", err)
	err = app.config.node.Load(nodeConfig)
	checkAppFatal("Couldn't load node config: %s", err)
}