MCPcopy Create free account
hub / github.com/Scalingo/cli / appsList

Function appsList

cmd/autocomplete/apps.go:28–53  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

26)
27
28func 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
55func appsAutoCompleteCache(ctx context.Context) ([]*scalingo.App, error) {
56 fd, err := os.Open(appsCacheFile)

Callers 2

FlagAppAutoCompleteFunction · 0.85

Calls 3

ScalingoClientFunction · 0.92
appsAutoCompleteCacheFunction · 0.85

Tested by

no test coverage detected