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

Function writeAppsAutoCompleteCache

cmd/autocomplete/apps.go:74–90  ·  view source on GitHub ↗
(ctx context.Context, apps []*scalingo.App)

Source from the content-addressed store, hash-verified

72}
73
74func writeAppsAutoCompleteCache(ctx context.Context, apps []*scalingo.App) error {
75 fd, err := os.OpenFile(appsCacheFile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
76 if err != nil {
77 return errors.Wrapf(ctx, err, "open apps cache file %s for write", appsCacheFile)
78 }
79 defer func() { _ = fd.Close() }()
80 cache := appsCache{
81 Apps: apps,
82 CreatedAt: time.Now(),
83 }
84 err = gob.NewEncoder(fd).Encode(&cache)
85 if err != nil {
86 return errors.Wrap(ctx, err, "encode apps cache file")
87 }
88
89 return nil
90}

Callers 1

appsListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected