func NewAppsGetterFunc( cliConnection api.Connection, orgName string, spaceName string, runtime ui.Runtime, ) (thingdoer.AppsGetterFunc, error) { diegoAppsCommand := thingdoer.AppsGetter{} if orgName != "" { org, err := cliConnection.GetOrg(orgName) if err != nil || org.Guid == "" { return nil, OrgNotFoundErr{OrganizationName: orgName} } diegoAppsCommand.OrganizationGuid = org.Guid } else if spaceName != "" { space, err := cliConnection.GetSpace(spaceName) if err != nil || space.Guid == "" { return nil, SpaceNotFoundErr{SpaceName: spaceName} } diegoAppsCommand.SpaceGuid = space.Guid } var appsGetterFunc = diegoAppsCommand.DiegoApps if runtime == ui.DEA { appsGetterFunc = diegoAppsCommand.DeaApps } return appsGetterFunc, nil }
func NewListAppsCommand(cliConnection api.Connection, orgName string, spaceName string, runtime ui.Runtime) (ui.ListAppsCommand, error) { username, err := cliConnection.Username() if err != nil { return ui.ListAppsCommand{}, err } if spaceName != "" { space, err := cliConnection.GetSpace(spaceName) if err != nil || space.Guid == "" { return ui.ListAppsCommand{}, err } orgName = space.Organization.Name } traceEnv := os.Getenv("CF_TRACE") traceLogger := trace.NewLogger(false, traceEnv, "") tUI := terminal.NewUI(os.Stdin, terminal.NewTeePrinter(), traceLogger) cmd := ui.ListAppsCommand{ Username: username, Organization: orgName, Space: spaceName, UI: tUI, Runtime: runtime, } return cmd, nil }
func NewMigrateAppsCommand(cliConnection api.Connection, organizationName string, spaceName string, runtime ui.Runtime) (ui.MigrateAppsCommand, error) { username, err := cliConnection.Username() if err != nil { return ui.MigrateAppsCommand{}, err } if spaceName != "" { space, err := cliConnection.GetSpace(spaceName) if err != nil || space.Guid == "" { return ui.MigrateAppsCommand{}, err } organizationName = space.Organization.Name } return ui.MigrateAppsCommand{ Username: username, Runtime: runtime, Organization: organizationName, Space: spaceName, }, nil }