go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/groups/groups.go (about)

     1  // Copyright (c) Mondoo, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package groups
     5  
     6  import (
     7  	"errors"
     8  )
     9  
    10  type Group struct {
    11  	ID      string // is the string representation of gid on linux/unix and sid on windows
    12  	Gid     int64
    13  	Sid     string
    14  	Name    string
    15  	Members []string
    16  }
    17  
    18  type OSGroupManager interface {
    19  	Name() string
    20  	Group(id string) (*Group, error)
    21  	List() ([]*Group, error)
    22  }
    23  
    24  func findGroup(groups []*Group, id string) (*Group, error) {
    25  	// search for id
    26  	for i := range groups {
    27  		group := groups[i]
    28  		if group.ID == id {
    29  			return group, nil
    30  		}
    31  	}
    32  
    33  	return nil, errors.New("group> " + id + " does not exist")
    34  }