Skip to content

Commit

Permalink
users: eliminate LookupGroupId and its one use case (#16093)
Browse files Browse the repository at this point in the history
This PR deletes the user.LookupGroupId function as it was only being used
in a single test case, and its value was not important to the test.
  • Loading branch information
shoenig authored Feb 8, 2023
1 parent 214e5b9 commit 77ea4e3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
5 changes: 1 addition & 4 deletions client/allocrunner/taskrunner/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2560,9 +2560,6 @@ func TestTaskTemplateManager_writeToFile(t *testing.T) {
cu, err := users.Current()
require.NoError(t, err)

cg, err := users.LookupGroupId(cu.Gid)
require.NoError(t, err)

file := "my.tmpl"
template := &structs.Template{
// EmbeddedTmpl set below as it needs the taskDir
Expand All @@ -2574,7 +2571,7 @@ func TestTaskTemplateManager_writeToFile(t *testing.T) {

// Add template now that we know the taskDir
harness.templates[0].EmbeddedTmpl = fmt.Sprintf(`Testing writeToFile...
{{ "hello" | writeToFile "%s" "`+cu.Username+`" "`+cg.Name+`" "0644" }}
{{ "hello" | writeToFile "%s" "`+cu.Username+`" "`+cu.Gid+`" "0644" }}
...done
`, filepath.Join(harness.taskDir, "writetofile.out"))

Expand Down
7 changes: 0 additions & 7 deletions helper/users/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ func Lookup(username string) (*user.User, error) {
return user.Lookup(username)
}

// LookupGroupId while holding a global process lock.
func LookupGroupId(gid string) (*user.Group, error) {
lock.Lock()
defer lock.Unlock()
return user.LookupGroupId(gid)
}

// Current returns the current user, acquired while holding a global process
// lock.
func Current() (*user.User, error) {
Expand Down

0 comments on commit 77ea4e3

Please sign in to comment.