Merge pull request #31 from tonistiigi/platforms-fixes

fixes for managing platforms
This commit is contained in:
Tibor Vass
2019-04-18 20:11:28 -07:00
committed by GitHub
10 changed files with 153 additions and 48 deletions

View File

@@ -62,7 +62,7 @@ type Inputs struct {
type DriverInfo struct {
Driver driver.Driver
Name string
Platform []string // TODO: specs.Platform
Platform []specs.Platform
Err error
}

View File

@@ -1,32 +0,0 @@
package build
import (
"strings"
"github.com/containerd/containerd/platforms"
specs "github.com/opencontainers/image-spec/specs-go/v1"
)
func ParsePlatformSpecs(platformsStr []string) ([]specs.Platform, error) {
if len(platformsStr) == 0 {
return nil, nil
}
out := make([]specs.Platform, 0, len(platformsStr))
for _, s := range platformsStr {
parts := strings.Split(s, ",")
if len(parts) > 1 {
p, err := ParsePlatformSpecs(parts)
if err != nil {
return nil, err
}
out = append(out, p...)
continue
}
p, err := platforms.Parse(s)
if err != nil {
return nil, err
}
out = append(out, platforms.Normalize(p))
}
return out, nil
}