(ctx context.Context, renderer renderer.Renderer[[]*scalingo.App], projectSlug string)
| 10 | ) |
| 11 | |
| 12 | func List(ctx context.Context, renderer renderer.Renderer[[]*scalingo.App], projectSlug string) error { |
| 13 | c, err := config.ScalingoClient(ctx) |
| 14 | if err != nil { |
| 15 | return errors.Wrap(ctx, err, "get Scalingo client") |
| 16 | } |
| 17 | |
| 18 | apps, err := c.AppsList(ctx) |
| 19 | if err != nil { |
| 20 | return errors.Wrap(ctx, err, "list apps") |
| 21 | } |
| 22 | |
| 23 | filteredApps := filterAppsByProject(apps, projectSlug) |
| 24 | renderer.SetData(ctx, filteredApps) |
| 25 | |
| 26 | err = renderer.Render(ctx) |
| 27 | if err != nil { |
| 28 | return errors.Wrap(ctx, err, "render apps list") |
| 29 | } |
| 30 | |
| 31 | return nil |
| 32 | } |
| 33 | |
| 34 | func filterAppsByProject(apps []*scalingo.App, projectSlug string) []*scalingo.App { |
| 35 | if projectSlug == "" { |
no test coverage detected