Files
gluetun/internal/alpine/version.go
Quentin McGaw (desktop) 21f4cf7ab5 Maint: do not mock os functions
- Use filepaths with /tmp for tests instead
- Only mock functions where filepath can't be specified such as user.Lookup
2021-07-23 16:06:19 +00:00

28 lines
444 B
Go

package alpine
import (
"context"
"io"
"os"
"strings"
)
func (c *configurator) Version(ctx context.Context) (version string, err error) {
file, err := os.OpenFile(c.alpineReleasePath, os.O_RDONLY, 0)
if err != nil {
return "", err
}
b, err := io.ReadAll(file)
if err != nil {
return "", err
}
if err := file.Close(); err != nil {
return "", err
}
version = strings.ReplaceAll(string(b), "\n", "")
return version, nil
}