MCPcopy Create free account
hub / github.com/containerd/nerdctl / List

Function List

pkg/cmd/apparmor/list_linux.go:31–79  ·  view source on GitHub ↗
(options types.ApparmorListOptions)

Source from the content-addressed store, hash-verified

29)
30
31func List(options types.ApparmorListOptions) error {
32 quiet := options.Quiet
33 w := options.Stdout
34 var tmpl *template.Template
35 format := options.Format
36 switch format {
37 case "", "table", "wide":
38 w = tabwriter.NewWriter(w, 4, 8, 4, ' ', 0)
39 if !quiet {
40 fmt.Fprintln(w, "NAME\tMODE")
41 }
42 case "raw":
43 return errors.New("unsupported format: \"raw\"")
44 default:
45 if quiet {
46 return errors.New("format and quiet must not be specified together")
47 }
48 var err error
49 tmpl, err = formatter.ParseTemplate(format)
50 if err != nil {
51 return err
52 }
53 }
54
55 profiles, err := apparmorutil.Profiles()
56 if err != nil {
57 return err
58 }
59
60 for _, f := range profiles {
61 if tmpl != nil {
62 var b bytes.Buffer
63 if err := tmpl.Execute(&b, f); err != nil {
64 return err
65 }
66 if _, err = fmt.Fprintln(w, b.String()); err != nil {
67 return err
68 }
69 } else if quiet {
70 fmt.Fprintln(w, f.Name)
71 } else {
72 fmt.Fprintf(w, "%s\t%s\n", f.Name, f.Mode)
73 }
74 }
75 if f, ok := w.(formatter.Flusher); ok {
76 return f.Flush()
77 }
78 return nil
79}

Callers 1

listActionFunction · 0.92

Calls 4

ParseTemplateFunction · 0.92
ProfilesFunction · 0.92
FlushMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…