Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: expose results from jx get app in a better structure #2383

Merged
merged 1 commit into from Nov 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions pkg/jx/cmd/get_applications.go
Expand Up @@ -37,7 +37,8 @@ type GetApplicationsResults struct {
EnvApps []EnvApps
EnvNames []string

Applications map[string]*ApplicationEnvironmentInfo
// Applications is a map indexed by the application name then the environment name
Applications map[string]map[string]*ApplicationEnvironmentInfo
}

// EnvApps contains data about app deployments in an environment
Expand Down Expand Up @@ -212,20 +213,25 @@ func (o *GetApplicationsOptions) Run() error {
}
table.AddRow(titles...)

appMap := map[string]*ApplicationEnvironmentInfo{}
appEnvMap := map[string]map[string]*ApplicationEnvironmentInfo{}

for _, appName := range apps {
row := []string{appName}
for _, ea := range envApps {
version := ""
d := ea.Apps[appName]
appMap := appEnvMap[appName]
if appMap == nil {
appMap = map[string]*ApplicationEnvironmentInfo{}
appEnvMap[appName] = appMap
}
version = kube.GetVersion(&d.ObjectMeta)
appEnvInfo := &ApplicationEnvironmentInfo{
Deployment: &d,
Environment: &ea.Environment,
Version: version,
}
appMap[appName] = appEnvInfo
appMap[ea.Environment.Name] = appEnvInfo
if ea.Environment.Spec.Kind != v1.EnvironmentKindTypePreview {
row = append(row, version)
}
Expand Down Expand Up @@ -263,7 +269,7 @@ func (o *GetApplicationsOptions) Run() error {
}
table.AddRow(row...)
}
o.Results.Applications = appMap
o.Results.Applications = appEnvMap

table.Render()
return nil
Expand Down