a3c97beee0
Implement a function that returns an error to replace existing uses of the IsOSSupported utility, where callers had to produce the error after checking. The IsOSSupported function was used in combination with images, so implementing a utility in "image" to prevent having to import pkg/system (which contains many unrelated functions) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
18 lines
369 B
Go
18 lines
369 B
Go
package image
|
|
|
|
import (
|
|
"errors"
|
|
"runtime"
|
|
"strings"
|
|
|
|
"github.com/docker/docker/errdefs"
|
|
)
|
|
|
|
// CheckOS checks if the given OS matches the host's platform, and
|
|
// returns an error otherwise.
|
|
func CheckOS(os string) error {
|
|
if !strings.EqualFold(runtime.GOOS, os) {
|
|
return errdefs.InvalidParameter(errors.New("operating system is not supported"))
|
|
}
|
|
return nil
|
|
}
|