2020-03-29 19:52:49 -04:00
|
|
|
package alpine
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os/user"
|
|
|
|
|
|
2020-12-29 00:55:31 +00:00
|
|
|
"github.com/qdm12/gluetun/internal/os"
|
2020-03-29 19:52:49 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Configurator interface {
|
2020-12-27 00:36:39 +00:00
|
|
|
CreateUser(username string, uid int) (createdUsername string, err error)
|
2020-03-29 19:52:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type configurator struct {
|
2020-12-29 00:55:31 +00:00
|
|
|
openFile os.OpenFileFunc
|
|
|
|
|
lookupUID func(uid string) (*user.User, error)
|
|
|
|
|
lookupUser func(username string) (*user.User, error)
|
2020-03-29 19:52:49 -04:00
|
|
|
}
|
|
|
|
|
|
2020-12-29 00:55:31 +00:00
|
|
|
func NewConfigurator(openFile os.OpenFileFunc) Configurator {
|
2020-03-29 19:52:49 -04:00
|
|
|
return &configurator{
|
2020-12-29 00:55:31 +00:00
|
|
|
openFile: openFile,
|
|
|
|
|
lookupUID: user.LookupId,
|
|
|
|
|
lookupUser: user.Lookup,
|
2020-03-29 19:52:49 -04:00
|
|
|
}
|
|
|
|
|
}
|