Example #1
0
func (store *RealStore) GetDesiredState() ([]models.DesiredAppState, error) {
	nodes, err := store.fetchNodesUnderDir("/desired")
	if err != nil {
		return []models.DesiredAppState{}, err
	}

	desiredStates := make([]models.DesiredAppState, len(nodes))
	for i, node := range nodes {
		desiredStates[i], err = models.NewDesiredAppStateFromJSON(node.Value)
		if err != nil {
			return []models.DesiredAppState{}, err
		}
	}

	return desiredStates, nil
}
Example #2
0
func (analyzer *Analyzer) populateDesiredState() error {
	nodes, err := analyzer.fetchNodesUnderDir("/desired")
	if err != nil {
		return err
	}

	analyzer.desiredByApp = make(map[string]bool, 0)

	analyzer.desiredStates = make([]models.DesiredAppState, len(nodes))
	for i, node := range nodes {
		analyzer.desiredStates[i], err = models.NewDesiredAppStateFromJSON(node.Value)
		if err != nil {
			return err
		}

		key := analyzer.desiredStates[i].AppGuid + "-" + analyzer.desiredStates[i].AppVersion
		analyzer.desiredByApp[key] = true
	}

	return nil
}