Maint: alpine package interface rework

- return concrete struct type
- split interface is sub-interfaces
This commit is contained in:
Quentin McGaw (desktop)
2021-07-23 18:51:51 +00:00
parent c5d92ae02c
commit 0b985e8c35
3 changed files with 22 additions and 13 deletions

View File

@@ -2,24 +2,25 @@
package alpine
import (
"context"
"os/user"
)
type Configurator interface {
CreateUser(username string, uid int) (createdUsername string, err error)
Version(ctx context.Context) (version string, err error)
var _ Alpiner = (*Alpine)(nil)
type Alpiner interface {
UserCreater
VersionGetter
}
type configurator struct {
type Alpine struct {
alpineReleasePath string
passwdPath string
lookupID func(uid string) (*user.User, error)
lookup func(username string) (*user.User, error)
}
func NewConfigurator() Configurator {
return &configurator{
func New() *Alpine {
return &Alpine{
alpineReleasePath: "/etc/alpine-release",
passwdPath: "/etc/passwd",
lookupID: user.LookupId,