Revision c4782aaddeee385f2602a658758dc310d7b146b1 authored by Joe Stringer on 21 June 2024, 20:06:22 UTC, committed by Joe Stringer on 21 June 2024, 20:08:13 UTC
This reverts commit 6613b1cb6996ca515961993510da0b8f51bc4b83. Signed-off-by: Joe Stringer <joe@cilium.io>
1 parent f051660
dockergroupcheck.go
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package main
import (
"fmt"
"os/user"
"runtime"
)
// A dockerGroupCheck checks that the current user is in the docker group.
type dockerGroupCheck struct{}
func (dockerGroupCheck) Name() string {
return "docker-group"
}
func (dockerGroupCheck) Run() (checkResult, string) {
if runtime.GOOS != "linux" {
return checkSkipped, "docker group only used on linux"
}
currentUser, err := user.Current()
if err != nil {
return checkFailed, err.Error()
}
groupIDs, err := currentUser.GroupIds()
if err != nil {
return checkFailed, err.Error()
}
dockerGroup, err := user.LookupGroup("docker")
if err != nil {
return checkFailed, err.Error()
}
for _, groupID := range groupIDs {
if groupID == dockerGroup.Gid {
return checkOK, fmt.Sprintf("user %s in docker group", currentUser.Username)
}
}
return checkError, fmt.Sprintf("user %s not in docker group", currentUser.Username)
}
func (dockerGroupCheck) Hint() string {
return `Run "sudo usermod $USER --append --group docker", then log out and back in.`
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...