Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logging output of user.GID #1466

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/build/types/image_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (ic *ImageConfiguration) Summarize(ctx context.Context) {
log.Infof(" runas: %s", ic.Accounts.RunAs)
log.Infof(" users:")
for _, u := range ic.Accounts.Users {
log.Infof(" - uid=%d(%s) gid=%d", u.UID, u.UserName, u.GID)
log.Infof(" - uid=%d(%s) gid=%d", u.UID, u.UserName, gidToInt(u.GID))
}
log.Infof(" groups:")
for _, g := range ic.Accounts.Groups {
Expand All @@ -272,3 +272,10 @@ func (ic *ImageConfiguration) Summarize(ctx context.Context) {
}
}
}

func gidToInt(gid GID) uint32 {
if gid == nil {
return 0
}
return *gid
}
3 changes: 3 additions & 0 deletions pkg/build/types/image_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func TestUserContents(t *testing.T) {

require.Equal(t, "/not/home", ic.Accounts.Users[0].HomeDir)
require.Equal(t, "/home/user", ic.Accounts.Users[1].HomeDir)

// Ensure this does not cause panic when users[1].gid is empty (defaulting to 0)
ic.Summarize(ctx)
}

func TestMergeInto(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/build/types/testdata/users.apko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ accounts:
uid: 2
homedir: "/not/home"
username: "something-else"
- gid: 2
uid: 3
- uid: 3
username: "user"
Loading