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

Function checkFilter

apps/logs.go:49–90  ·  view source on GitHub ↗
(ctx context.Context, c *scalingo.Client, appName string, filter string)

Source from the content-addressed store, hash-verified

47}
48
49func checkFilter(ctx context.Context, c *scalingo.Client, appName string, filter string) error {
50 if filter == "" {
51 return nil
52 }
53
54 if strings.HasPrefix(filter, "one-off-") || strings.HasPrefix(filter, "postdeploy-") {
55 return nil
56 }
57
58 if filter == "router" {
59 return nil
60 }
61
62 processes, err := c.AppsContainerTypes(ctx, appName)
63 if err != nil {
64 return errors.Wrapf(ctx, err, "list container types for app %s", appName)
65 }
66
67 filters := strings.SplitSeq(filter, "|")
68 for f := range filters {
69 ctName := ""
70
71 for _, ct := range processes {
72 ctName = ct.Name
73 if strings.HasPrefix(f, ctName+"-") || f == ctName {
74 break
75 }
76 }
77
78 if !strings.HasPrefix(f, ctName+"-") && f != ctName {
79 return errors.Newf(ctx,
80 "%s is not a valid container filter\n\nEXAMPLES:\n"+
81 "\"scalingo logs -F web\": logs of every web containers\n"+
82 "\"scalingo logs -F web-1\": logs of web container 1\n"+
83 "\"scalingo logs -F router\": only router logs\n"+
84 "\"scalingo logs -F web|worker\": logs of every web and worker containers\n",
85 f)
86 }
87 }
88
89 return nil
90}

Callers 1

LogsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected