From d2d9eedb1d1b2d047fbdd847ce7c67724f27bde4 Mon Sep 17 00:00:00 2001 From: Iceber Gu Date: Mon, 6 Mar 2023 15:03:58 +0800 Subject: [PATCH] WithRuntimePath uses the TaskInfo.RuntimePath field Signed-off-by: Iceber Gu (cherry picked from commit 97064b0772af58f770a48276d0a0bb3746a92378) Signed-off-by: Iceber Gu --- container.go | 1 + task.go | 5 +++++ task_opts.go | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/container.go b/container.go index 2890bfdc4344..7863b742bce6 100644 --- a/container.go +++ b/container.go @@ -281,6 +281,7 @@ func (c *container) NewTask(ctx context.Context, ioCreate cio.Creator, opts ...N }) } } + request.RuntimePath = info.RuntimePath if info.Options != nil { any, err := typeurl.MarshalAny(info.Options) if err != nil { diff --git a/task.go b/task.go index be35611e7d43..eecc99f854ca 100644 --- a/task.go +++ b/task.go @@ -140,6 +140,11 @@ type TaskInfo struct { RootFS []mount.Mount // Options hold runtime specific settings for task creation Options interface{} + // RuntimePath is an absolute path that can be used to overwrite path + // to a shim runtime binary. + RuntimePath string + + // runtime is the runtime name for the container, and cannot be changed. runtime string } diff --git a/task_opts.go b/task_opts.go index e372ca4451e0..da269016e456 100644 --- a/task_opts.go +++ b/task_opts.go @@ -49,7 +49,7 @@ func WithRootFS(mounts []mount.Mount) NewTaskOpts { // instead of resolving it from runtime name. func WithRuntimePath(absRuntimePath string) NewTaskOpts { return func(ctx context.Context, client *Client, info *TaskInfo) error { - info.runtime = absRuntimePath + info.RuntimePath = absRuntimePath return nil } }