diff --git a/pkg/controller/info/info.go b/pkg/controller/info/info.go index 9296c4e50..4437fe189 100644 --- a/pkg/controller/info/info.go +++ b/pkg/controller/info/info.go @@ -50,12 +50,28 @@ func maskUser(s, username string) string { return strings.ReplaceAll(s, username, "(USER)") } -func (c *Controller) Info(_ context.Context, _ *logrus.Entry, param *config.Param) error { //nolint:funlen +func getCurrentUserName() (string, error) { currentUser, err := user.Current() if err != nil { - return fmt.Errorf("get a current user: %w", err) + return "", fmt.Errorf("get a current user: %w", err) } userName := currentUser.Username + if runtime.GOOS == "windows" { + // On Windows, the user name is in the form of "domain\user". + domain, userName, ok := strings.Cut(userName, "\\") + if ok { + return userName, nil + } + return domain, nil + } + return userName, nil +} + +func (c *Controller) Info(_ context.Context, _ *logrus.Entry, param *config.Param) error { //nolint:funlen + userName, err := getCurrentUserName() + if err != nil { + return fmt.Errorf("get a current user name: %w", err) + } filePaths := c.finder.Finds(param.PWD, param.ConfigFilePath) cfgs := make([]*Config, len(filePaths))