- Use filepaths with /tmp for tests instead - Only mock functions where filepath can't be specified such as user.Lookup
28 lines
444 B
Go
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
|
|
}
|