Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ var bundleValidateCommand = cli.Command{
var spec rspec.Spec
if err = json.NewDecoder(sf).Decode(&spec); err != nil {
logrus.Fatal(err)
} else {
if spec.Platform.OS != "linux" {
logrus.Fatalf("Operation system '%s' of the bundle is not supported yet.", spec.Platform.OS)
}
}

rootfsPath := path.Join(inputPath, spec.Root.Path)
Expand All @@ -75,6 +71,7 @@ var bundleValidateCommand = cli.Command{
} else if !fi.IsDir() {
logrus.Fatalf("Rootfs: %v is not a directory.", spec.Root.Path)
}

bundleValidate(spec, rootfsPath)
logrus.Infof("Bundle validation succeeded.")
},
Expand All @@ -83,6 +80,7 @@ var bundleValidateCommand = cli.Command{
func bundleValidate(spec rspec.Spec, rootfs string) {
checkMandatoryField(spec)
checkSemVer(spec.Version)
checkPlatform(spec.Platform)
checkProcess(spec.Process, rootfs)
checkMounts(spec.Mounts, rootfs)
checkLinux(spec.Linux, rootfs)
Expand All @@ -106,6 +104,30 @@ func checkMounts(mounts []rspec.Mount, rootfs string) {
}
}

func checkPlatform(platform rspec.Platform) {
validCombins := map[string][]string{
"darwin": {"386", "amd64", "arm", "arm64"},
"dragonfly": {"amd64"},
"freebsd": {"386", "amd64", "arm"},
"linux": {"386", "amd64", "arm", "arm64", "ppc64", "ppc64le", "mips64", "mips64le"},
"netbsd": {"386", "amd64", "arm"},
"openbsd": {"386", "amd64", "arm"},
"plan9": {"386", "amd64"},
"solaris": {"amd64"},
"windows": {"386", "amd64"}}
for os, archs := range validCombins {
if os == platform.OS {
for _, arch := range archs {
if arch == platform.Arch {
return
}
}
logrus.Fatalf("Combination of '%s' and '%s' is invalid.", platform.OS, platform.Arch)
}
}
logrus.Fatalf("Operation system '%s' of the bundle is not supported yet.", platform.OS)
}

func checkProcess(process rspec.Process, rootfs string) {
for index := 0; index < len(process.Capabilities); index++ {
capability := process.Capabilities[index]
Expand Down