Merge pull request #2899 from fuweid/proposal-add-Add-method-in-PlatformRuntime
runtime: add Add/Delete method in PlatformRuntime interface
This commit is contained in:
commit
35582cb7a3
@ -69,4 +69,8 @@ type PlatformRuntime interface {
|
|||||||
// Tasks returns all the current tasks for the runtime.
|
// Tasks returns all the current tasks for the runtime.
|
||||||
// Any container runs at most one task at a time.
|
// Any container runs at most one task at a time.
|
||||||
Tasks(context.Context, bool) ([]Task, error)
|
Tasks(context.Context, bool) ([]Task, error)
|
||||||
|
// Add adds a task into runtime.
|
||||||
|
Add(context.Context, Task) error
|
||||||
|
// Delete remove a task.
|
||||||
|
Delete(context.Context, string)
|
||||||
}
|
}
|
||||||
|
@ -309,6 +309,16 @@ func (r *Runtime) Get(ctx context.Context, id string) (runtime.Task, error) {
|
|||||||
return r.tasks.Get(ctx, id)
|
return r.tasks.Get(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a runtime task
|
||||||
|
func (r *Runtime) Add(ctx context.Context, task runtime.Task) error {
|
||||||
|
return r.tasks.Add(ctx, task)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete a runtime task
|
||||||
|
func (r *Runtime) Delete(ctx context.Context, id string) {
|
||||||
|
r.tasks.Delete(ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
|
func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
|
||||||
dir, err := ioutil.ReadDir(filepath.Join(r.state, ns))
|
dir, err := ioutil.ReadDir(filepath.Join(r.state, ns))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -130,6 +130,16 @@ func (m *TaskManager) Get(ctx context.Context, id string) (runtime.Task, error)
|
|||||||
return m.tasks.Get(ctx, id)
|
return m.tasks.Get(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a runtime task
|
||||||
|
func (m *TaskManager) Add(ctx context.Context, task runtime.Task) error {
|
||||||
|
return m.tasks.Add(ctx, task)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete a runtime task
|
||||||
|
func (m *TaskManager) Delete(ctx context.Context, id string) {
|
||||||
|
m.tasks.Delete(ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
// Tasks lists all tasks
|
// Tasks lists all tasks
|
||||||
func (m *TaskManager) Tasks(ctx context.Context, all bool) ([]runtime.Task, error) {
|
func (m *TaskManager) Tasks(ctx context.Context, all bool) ([]runtime.Task, error) {
|
||||||
return m.tasks.GetAll(ctx, all)
|
return m.tasks.GetAll(ctx, all)
|
||||||
|
@ -153,6 +153,14 @@ func (r *windowsRuntime) Tasks(ctx context.Context, all bool) ([]runtime.Task, e
|
|||||||
return r.tasks.GetAll(ctx, all)
|
return r.tasks.GetAll(ctx, all)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *windowsRuntime) Add(ctx context.Context, task runtime.Task) error {
|
||||||
|
return r.tasks.Add(ctx, task)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *windowsRuntime) Delete(ctx context.Context, id string) {
|
||||||
|
r.tasks.Delete(ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *windowsRuntime) newTask(ctx context.Context, namespace, id string, rootfs []mount.Mount, spec *runtimespec.Spec, io runtime.IO, createOpts *hcsshimtypes.CreateOptions) (*task, error) {
|
func (r *windowsRuntime) newTask(ctx context.Context, namespace, id string, rootfs []mount.Mount, spec *runtimespec.Spec, io runtime.IO, createOpts *hcsshimtypes.CreateOptions) (*task, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
|
Loading…
Reference in New Issue
Block a user