Skip to content

Commit f1eaad8

Browse files
authored
Merge pull request #4725 from kolyshkin/novar
libct/apparmor: don't use vars for public functions
2 parents 0219733 + 5f4d3f3 commit f1eaad8

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

libcontainer/apparmor/apparmor.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ package apparmor
22

33
import "errors"
44

5-
var (
6-
// IsEnabled returns true if apparmor is enabled for the host.
7-
IsEnabled = isEnabled
5+
// IsEnabled returns true if apparmor is enabled for the host.
6+
func IsEnabled() bool {
7+
return isEnabled()
8+
}
89

9-
// ApplyProfile will apply the profile with the specified name to the process after
10-
// the next exec. It is only supported on Linux and produces an ErrApparmorNotEnabled
11-
// on other platforms.
12-
ApplyProfile = applyProfile
10+
// ApplyProfile will apply the profile with the specified name to the process
11+
// after the next exec. It is only supported on Linux and produces an
12+
// [ErrApparmorNotEnabled] on other platforms.
13+
func ApplyProfile(name string) error {
14+
return applyProfile(name)
15+
}
1316

14-
// ErrApparmorNotEnabled indicates that AppArmor is not enabled or not supported.
15-
ErrApparmorNotEnabled = errors.New("apparmor: config provided but apparmor not supported")
16-
)
17+
// ErrApparmorNotEnabled indicates that AppArmor is not enabled or not supported.
18+
var ErrApparmorNotEnabled = errors.New("apparmor: config provided but apparmor not supported")

libcontainer/apparmor/apparmor_linux.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,16 @@ func setProcAttr(attr, value string) error {
5353
return err
5454
}
5555

56-
// changeOnExec reimplements aa_change_onexec from libapparmor in Go
56+
// changeOnExec reimplements aa_change_onexec from libapparmor in Go.
5757
func changeOnExec(name string) error {
5858
if err := setProcAttr("exec", "exec "+name); err != nil {
5959
return fmt.Errorf("apparmor failed to apply profile: %w", err)
6060
}
6161
return nil
6262
}
6363

64-
// applyProfile will apply the profile with the specified name to the process after
65-
// the next exec. It is only supported on Linux and produces an error on other
66-
// platforms.
64+
// applyProfile will apply the profile with the specified name to the process
65+
// after the next exec.
6766
func applyProfile(name string) error {
6867
if name == "" {
6968
return nil

0 commit comments

Comments
 (0)