Skip to content

Commit

Permalink
Enable parsing the OCI linux configuration on non-linux platforms
Browse files Browse the repository at this point in the history
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 <jiangshanlai@gmail.com>
  • Loading branch information
laijs committed Sep 9, 2015
1 parent ac52bee commit 7dd3a6c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
8 changes: 5 additions & 3 deletions config_linux.go → linux/config.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// +build linux
package linux

package specs
import (
"github.com/opencontainers/specs"
)

// LinuxSpec is the full specification for linux containers.
type LinuxSpec struct {
Spec
specs.Spec
// Linux is platform specific configuration for linux based containers.
Linux Linux `json:"linux"`
}
Expand Down
File renamed without changes.
10 changes: 7 additions & 3 deletions runtime_config_linux.go → linux/runtime-config.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package specs
package linux

import "os"
import (
"os"

"github.com/opencontainers/specs"
)

// LinuxStateDirectory holds the container's state information
const LinuxStateDirectory = "/run/opencontainer/containers"

// LinuxRuntimeSpec is the full specification for linux containers.
type LinuxRuntimeSpec struct {
RuntimeSpec
specs.RuntimeSpec
// LinuxRuntime is platform specific configuration for linux based containers.
Linux LinuxRuntime `json:"linux"`
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 7dd3a6c

Please sign in to comment.