(ctx context.Context)
| 26 | ) |
| 27 | |
| 28 | func appsList(ctx context.Context) ([]*scalingo.App, error) { |
| 29 | var ( |
| 30 | err error |
| 31 | apps []*scalingo.App |
| 32 | ) |
| 33 | |
| 34 | apps, err = appsAutoCompleteCache(ctx) |
| 35 | if err != nil { |
| 36 | debug.Println("fail to get applications autocomplete cache make GET request", err) |
| 37 | c, err := config.ScalingoClient(ctx) |
| 38 | if err != nil { |
| 39 | return nil, errors.Wrapf(ctx, err, "fail to get Scalingo client") |
| 40 | } |
| 41 | apps, err = c.AppsList(ctx) |
| 42 | if err != nil || len(apps) == 0 { |
| 43 | return nil, errors.Wrap(ctx, err, "list applications") |
| 44 | } |
| 45 | |
| 46 | err = writeAppsAutoCompleteCache(ctx, apps) |
| 47 | if err != nil { |
| 48 | debug.Println("fail to write applications autocomplete cache", err) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return apps, nil |
| 53 | } |
| 54 | |
| 55 | func appsAutoCompleteCache(ctx context.Context) ([]*scalingo.App, error) { |
| 56 | fd, err := os.Open(appsCacheFile) |
no test coverage detected