Repository: containerd/containerd
File: client/task.go (Go)

Code before:
	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

	// runtimeOptions is the runtime options for the container, and it will be used
	// as the default taskOptions when taskOptions is modified.
	// https://github.com/containerd/containerd/issues/11568
	runtimeOptions typeurl.Any
}

// Runtime name for the container
func (i *TaskInfo) Runtime() string {
	return i.runtime
}

func (i *TaskInfo) getRuncOptions() (*options.Options, error) {
	if i.Options != nil {
		opts, ok := i.Options.(*options.Options)
		if !ok {
			return nil, errors.New("invalid runtime v2 options format")
		}
		return opts, nil
	}

	opts := &options.Options{}
	if i.runtimeOptions != nil && i.runtimeOptions.GetValue() != nil {
		if err := typeurl.UnmarshalTo(i.runtimeOptions, opts); err != nil {
			return nil, err
		}
	}
	i.Options = opts
	return opts, nil
}

// Task is the executable object within containerd
type Task interface {
	Process

	// Pause suspends the execution of the task
	Pause(context.Context) error
	// Resume the execution of the task
	Resume(context.Context) error
	// Exec creates a new process inside the task
	Exec(context.Context, string, *specs.Process, cio.Creator) (Process, error)
	// Pids returns a list of system specific process ids inside the task

Review comment (suggestion):
```suggestion
// returns a reference to the runtime options for use by the task, if the set of options is not set by the opts passed into the NewTask creation this function first attempts to initialize the runtime options with a copy of the runtimeOptions, otherwise an empty set of options is assigned and returned
func (i *TaskInfo) getRuntimeOptions() (*options.Options, error) {
```

Code after:
	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

	// runtimeOptions is the runtime options for the container, and when task options are set,
	// they will be based on the runtimeOptions.
	// https://github.com/containerd/containerd/issues/11568
	runtimeOptions typeurl.Any
}

// Runtime name for the container
func (i *TaskInfo) Runtime() string {
	return i.runtime
}

// getRuncOptions returns a reference to the runtime options for use by the task.
// If the set of options is not set by the opts passed into the NewTask creation
// this function first attempts to initialize the runtime options with a copy of the runtimeOptions,
// otherwise an empty set of options is assigned and returned
func (i *TaskInfo) getRuncOptions() (*options.Options, error) {
	if i.Options != nil {
		opts, ok := i.Options.(*options.Options)
		if !ok {
			return nil, errors.New("invalid runtime v2 options format")
		}
		return opts, nil
	}

	opts := &options.Options{}
	if i.runtimeOptions != nil && i.runtimeOptions.GetValue() != nil {
		if err := typeurl.UnmarshalTo(i.runtimeOptions, opts); err != nil {
			return nil, fmt.Errorf("failed to get runtime v2 options: %w", err)
		}
	}
	i.Options = opts
	return opts, nil
}

// Task is the executable object within containerd
type Task interface {
	Process

	// Pause suspends the execution of the task
	Pause(context.Context) error
	// Resume the execution of the task