in spinnaker/spinnaker.go [298:343]
func (s Spinnaker) GetApp(appName string) (*D.App, error) {
// data arg is a map like {accountName: {clusterName: {regionName: {asgName: [instanceId]}}}}
data := make(D.AppMap)
for account, clusters := range s.clusters(appName) {
cloudProvider, err := s.CloudProvider(account)
if err != nil {
return nil, errors.Wrap(err, "retrieve cloud provider failed")
}
account := D.AccountName(account)
data[account] = D.AccountInfo{
CloudProvider: cloudProvider,
Clusters: make(map[D.ClusterName]map[D.RegionName]map[D.ASGName][]D.InstanceID),
}
for _, clusterName := range clusters {
clusterName := D.ClusterName(clusterName)
data[account].Clusters[clusterName] = make(map[D.RegionName]map[D.ASGName][]D.InstanceID)
asgs, err := s.asgs(appName, string(account), string(clusterName))
if err != nil {
log.Printf("WARNING: could not retrieve asgs for app:%s account:%s cluster:%s : %v", appName, account, clusterName, err)
continue
}
for _, asg := range asgs {
// We don't terminate instances in disabled ASGs
if asg.Disabled {
continue
}
region := D.RegionName(asg.Region)
asgName := D.ASGName(asg.Name)
_, present := data[account].Clusters[clusterName][region]
if !present {
data[account].Clusters[clusterName][region] = make(map[D.ASGName][]D.InstanceID)
}
data[account].Clusters[clusterName][region][asgName] = make([]D.InstanceID, len(asg.Instances))
for i, instance := range asg.Instances {
data[account].Clusters[clusterName][region][asgName][i] = D.InstanceID(instance.Name)
}
}
}
}
return D.NewApp(appName, data), nil
}