Add context and client to SpecOpts
In order to do more advanced spec generation with images, snapshots, etc, we need to inject the context and client into the spec generation code. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@@ -98,7 +98,7 @@ func test(c config) error {
|
||||
return err
|
||||
}
|
||||
logrus.Info("generating spec from image")
|
||||
spec, err := containerd.GenerateSpec(containerd.WithImageConfig(ctx, image), containerd.WithProcessArgs("true"))
|
||||
spec, err := containerd.GenerateSpec(ctx, client, containerd.WithImageConfig(image), containerd.WithProcessArgs("true"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ type killer interface {
|
||||
}
|
||||
|
||||
func withEnv(context *cli.Context) containerd.SpecOpts {
|
||||
return func(s *specs.Spec) error {
|
||||
return func(_ gocontext.Context, _ *containerd.Client, s *specs.Spec) error {
|
||||
env := context.StringSlice("env")
|
||||
if len(env) > 0 {
|
||||
s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, env)
|
||||
@@ -34,7 +34,7 @@ func withEnv(context *cli.Context) containerd.SpecOpts {
|
||||
}
|
||||
|
||||
func withMounts(context *cli.Context) containerd.SpecOpts {
|
||||
return func(s *specs.Spec) error {
|
||||
return func(_ gocontext.Context, _ *containerd.Client, s *specs.Spec) error {
|
||||
for _, mount := range context.StringSlice("mount") {
|
||||
m, err := parseMountFlag(mount)
|
||||
if err != nil {
|
||||
|
||||
@@ -90,7 +90,7 @@ func newContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
opts = append(opts, containerd.WithImageConfig(ctx, image))
|
||||
opts = append(opts, containerd.WithImageConfig(image))
|
||||
cOpts = append(cOpts, containerd.WithImage(image))
|
||||
cOpts = append(cOpts, containerd.WithSnapshotter(context.String("snapshotter")))
|
||||
if context.Bool("readonly") {
|
||||
@@ -111,7 +111,7 @@ func newContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
||||
if context.Bool("net-host") {
|
||||
opts = append(opts, setHostNetworking())
|
||||
}
|
||||
spec, err := containerd.GenerateSpec(opts...)
|
||||
spec, err := containerd.GenerateSpec(ctx, client, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user