// ListInProject lists all applications in given project
// Queries cluster and config file.
// Shows also empty applications (empty applications are those that are just
// mentioned in config file but don't have any object associated with it on cluster).
ListInProject lists all applications in given project
Queries cluster and config file.
Shows also empty applications (empty applications are those that are just
mentioned in config file but don't have any object associated with it on cluster).
// ListInProject lists all applications in given project // Queries cluster and config file . // Shows also empty applications ( empty applications are those that are just // mentioned in config file but don ' t have any object associated with it on cluster ) .
func ListInProject(client *occlient.Client) ([]config.ApplicationInfo, error) {
	var applications []config.ApplicationInfo
	cfg, err := config.New()
	if err != nil {
		return nil, errors.Wrap(err, "unable to create new application")
	}
	for i := range cfg.ActiveApplications {
		if cfg.ActiveApplications[i].Project == client.Namespace {
			applications = append(applications, cfg.ActiveApplications[i])
		}
	}
	appNames, err := client.GetLabelValues(applabels.ApplicationLabel, applabels.ApplicationLabel)
	if err != nil {
		return nil, errors.Wrap(err, "unable to list applications")
	}
	for _, name := range appNames {
		found := false
		for _, app := range applications {
			if app.Project == client.Namespace && app.Name == name {
				found = true
			}
		}
		if !found {
			applications = append(applications, config.ApplicationInfo{
				Name: name,
				Active:  false,
				Project: client.Namespace,
			})
		}
	}
	return applications, nil
}
func ListInProject ( client * occlient . Client ) ( [ ] config . ApplicationInfo , error ) { var applications [ ] config . ApplicationInfo cfg , err := config . New ( ) if err != nil { return nil , errors . Wrap ( err , " " ) } for i := range cfg . ActiveApplications { if cfg . ActiveApplications [ i ] . Project == client . Namespace { applications = append ( applications , cfg . ActiveApplications [ i ] ) } } appNames , err := client . GetLabelValues ( applabels . ApplicationLabel , applabels . ApplicationLabel ) if err != nil { return nil , errors . Wrap ( err , " " ) } for _ , name := range appNames { found := false for _ , app := range applications { if app . Project == client . Namespace && app . Name == name { found = true } } if ! found { applications = append ( applications , config . ApplicationInfo { Name : name , Active : false , Project : client . Namespace , } ) } } return applications , nil }
ListInProject lists all applications in given project
Queries cluster and config file.
ListInProject lists all applications in given project Queries cluster and config file .
// All applications of the current project from config file // Get applications from cluster // skip applications that are already in the list (they were mentioned in config file) // if this application is not in config file, it can't be active