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

Code before:
// Runtime name for the container
func (i *CheckpointTaskInfo) Runtime() string {
	return i.runtime
}

// CheckpointTaskOpts allows the caller to set checkpoint options
type CheckpointTaskOpts func(*CheckpointTaskInfo) error

// TaskInfo sets options for task creation
type TaskInfo struct {
	// Checkpoint is the Descriptor for an existing checkpoint that can be used
	// to restore a task's runtime and memory state
	Checkpoint *types.Descriptor
	// RootFS is a list of mounts to use as the task's root filesystem
	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

Review comment (suggestion):
```suggestion
	// as the default task Options if task Options are not set.
```


Code after:
// Runtime name for the container
func (i *CheckpointTaskInfo) Runtime() string {
	return i.runtime
}

// CheckpointTaskOpts allows the caller to set checkpoint options
type CheckpointTaskOpts func(*CheckpointTaskInfo) error

// TaskInfo sets options for task creation
type TaskInfo struct {
	// Checkpoint is the Descriptor for an existing checkpoint that can be used
	// to restore a task's runtime and memory state
	Checkpoint *types.Descriptor
	// RootFS is a list of mounts to use as the task's root filesystem
	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 {