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
()
| 169 | // this function first attempts to initialize the runtime options with a copy of the runtimeOptions, |
| 170 | // otherwise an empty set of options is assigned and returned |
| 171 | func (i *TaskInfo) getRuncOptions() (*options.Options, error) { |
| 172 | if i.Options != nil { |
| 173 | opts, ok := i.Options.(*options.Options) |
| 174 | if !ok { |
| 175 | return nil, errors.New("invalid runtime v2 options format") |
| 176 | } |
| 177 | return opts, nil |
| 178 | } |
| 179 | |
| 180 | opts := &options.Options{} |
| 181 | if i.runtimeOptions != nil && i.runtimeOptions.GetValue() != nil { |
| 182 | if err := typeurl.UnmarshalTo(i.runtimeOptions, opts); err != nil { |
| 183 | return nil, fmt.Errorf("failed to get runtime v2 options: %w", err) |
| 184 | } |
| 185 | } |
| 186 | i.Options = opts |
| 187 | return opts, nil |
| 188 | } |
| 189 | |
| 190 | // Task is the executable object within containerd |
| 191 | type Task interface { |
no test coverage detected