Fix usage of oci in other packages.

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
Daniel Nephin
2017-11-22 15:45:47 -05:00
parent 081f8c7ce0
commit cdf62f69a1
13 changed files with 80 additions and 68 deletions

View File

@@ -65,20 +65,20 @@ If we want to make a `SpecOpt` to setup a container to monitor the host system w
package monitor
import (
"github.com/containerd/containerd"
"github.com/containerd/containerd/oci"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
// WithHtop configures a container to monitor the host system via `htop`
func WithHtop(s *specs.Spec) error {
// make sure we are in the host pid namespace
if err := containerd.WithHostNamespace(specs.PIDNamespace)(s); err != nil {
if err := oci.WithHostNamespace(specs.PIDNamespace)(s); err != nil {
return err
}
// make sure we set htop as our arg
s.Process.Args = []string{"htop"}
// make sure we have a tty set for htop
if err := containerd.WithTTY(s); err != nil {
if err := oci.WithTTY(s); err != nil {
return err
}
return nil
@@ -91,7 +91,7 @@ Adding your new option to spec generation is as easy as importing your new packa
import "github.com/crosbymichael/monitor"
container, err := client.NewContainer(ctx, id,
containerd.WithNewSpec(containerd.WithImageConfig(image), monitor.WithHtop),
containerd.WithNewSpec(oci.WithImageConfig(image), monitor.WithHtop),
)
```

View File

@@ -149,7 +149,7 @@ The container will be based off of the image, use the runtime information in the
ctx,
"redis-server",
containerd.WithNewSnapshot("redis-server-snapshot", image),
containerd.WithNewSpec(containerd.WithImageConfig(image)),
containerd.WithNewSpec(oci.WithImageConfig(image)),
)
if err != nil {
return err
@@ -173,6 +173,7 @@ import (
"log"
"github.com/containerd/containerd"
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/namespaces"
)
@@ -200,7 +201,7 @@ func redisExample() error {
ctx,
"redis-server",
containerd.WithNewSnapshot("redis-server-snapshot", image),
containerd.WithNewSpec(containerd.WithImageConfig(image)),
containerd.WithNewSpec(oci.WithImageConfig(image)),
)
if err != nil {
return err
@@ -317,6 +318,7 @@ import (
"time"
"github.com/containerd/containerd"
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/namespaces"
)
@@ -349,7 +351,7 @@ func redisExample() error {
"redis-server",
containerd.WithImage(image),
containerd.WithNewSnapshot("redis-server-snapshot", image),
containerd.WithNewSpec(containerd.WithImageConfig(image)),
containerd.WithNewSpec(oci.WithImageConfig(image)),
)
if err != nil {
return err