From 31f626cb22507580b3728a031b0f0587c608a8ac Mon Sep 17 00:00:00 2001 From: Tejal Desai Date: Mon, 3 Feb 2020 15:23:16 -0800 Subject: [PATCH] initilize group to 0 --- pkg/util/command_util.go | 2 +- pkg/util/command_util_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/util/command_util.go b/pkg/util/command_util.go index c9ba9f4cf..23f035ec4 100644 --- a/pkg/util/command_util.go +++ b/pkg/util/command_util.go @@ -377,7 +377,7 @@ func GetUserFromUsername(userStr string, groupStr string, fallbackToUID bool) (s } uid := userObj.Uid - gid := "" + gid := "0" if fallbackToUID { gid = userObj.Gid } diff --git a/pkg/util/command_util_test.go b/pkg/util/command_util_test.go index b5895e9a6..472646388 100644 --- a/pkg/util/command_util_test.go +++ b/pkg/util/command_util_test.go @@ -551,12 +551,12 @@ func Test_GetUIDAndGIDFromString(t *testing.T) { fmt.Sprintf("%s:%s", currentUser.Uid, primaryGroup), fmt.Sprintf("%s:%s", currentUser.Username, primaryGroup), } - expectedUid, _ := strconv.ParseUint(currentUser.Uid, 10, 32) - expectedGid, _ := strconv.ParseUint(currentUser.Gid, 10, 32) + expectedU, _ := strconv.ParseUint(currentUser.Uid, 10, 32) + expectedG, _ := strconv.ParseUint(currentUser.Gid, 10, 32) for _, tt := range testCases { uid, gid, err := GetUIDAndGIDFromString(tt, false) - if uid != uint32(expectedUid) || gid != uint32(expectedGid) || err != nil { - t.Errorf("Could not correctly decode %s to uid/gid %d:%d. Result: %d:%d", tt, expectedUid, expectedGid, + if uid != uint32(expectedU) || gid != uint32(expectedG) || err != nil { + t.Errorf("Could not correctly decode %s to uid/gid %d:%d. Result: %d:%d", tt, expectedU, expectedG, uid, gid) } }