Skip to content

Commit cd8c885

Browse files
committed
Enable parsing the OCI linux configuration on non-linux platforms
What does this patch do? * Make the LinuxSpec be visible by golang on non-linux platforms when “go build” What did this patch change? * Add linux/ * Rename config_linux.go to linux/config.go * Rename config-linux.md to linux/config.md * Rename runtime_config_linux.go to linux/runtime-config.go * Rename runtime-config-linux.md to linux/runtime-config.md * Rename runtime-linux.md -> linux/runtime.md * Remove the “// +build linux” from linux/config.go * The package name of linux/*.go is changed to “linux” * Add import of the “specs” in the linux/*.go The type LinuxSpec (or say the OCI linux configuration) is a structure describing some information, there is no executable code bound to the linux, so the LinuxSpec should be naturally usable by any platform when needed. But the file names (ended with “_linux.go”) and the build tag disallow us to do so. The patch changes it. Removing the “_linux” and the build tag makes `go build` accept the LinuxSpec on any platform. The linux related files are also moved to the linux/ to eliminate the future possible name clashing (include the file names and the type names). After making the LinuxSpec be visible on non-linux platforms, anyone can do anything of the following in any platforms. (They are also the useful usecases) * 1) parse the OCI linux configuration (config.json & runtime.json) * 2) verify the OCI linux configuration or the bundle * 3) check or test the OCI linux configuration or even the bundle * 4) discover/build/deliver linux OCI bundle * 5) Run the container via the hypervisor-based runtime on non-linux platforms * etc.) The 5) is one thing of what we are focusing on. After this patch applied, anyone can build the runv[1] and run linux container on darwin. (Also after we update the opencontainers/spec under Godeps/ in our runv.git[1] project.) [1]: https://github.com/hyperhq/runv Signed-off-by: Lai Jiangshan <[email protected]>
1 parent 7050f8b commit cd8c885

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

config_linux.go renamed to linux/config.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
// +build linux
1+
package linux
22

3-
package specs
3+
import (
4+
"github.com/opencontainers/specs"
5+
)
46

57
// LinuxSpec is the full specification for linux containers.
68
type LinuxSpec struct {
7-
Spec
9+
specs.Spec
810
// Linux is platform specific configuration for linux based containers.
911
Linux Linux `json:"linux"`
1012
}
File renamed without changes.

runtime_config_linux.go renamed to linux/runtime-config.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
package specs
1+
package linux
22

3-
import "os"
3+
import (
4+
"os"
5+
6+
"github.com/opencontainers/specs"
7+
)
48

59
// LinuxRuntimeSpec is the full specification for linux containers.
610
type LinuxRuntimeSpec struct {
7-
RuntimeSpec
11+
specs.RuntimeSpec
812
// LinuxRuntime is platform specific configuration for linux based containers.
913
Linux LinuxRuntime `json:"linux"`
1014
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)