mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-23 16:24:19 +01:00
Fixes: #2023 CompatOCISpec is used to gurantee backward compatbility for old runtime specs, after we convert CompatOCISpec to standard specs.Spec, we should use specs.Spec instead of CompatOCISpec, and CompatOCISpec should be useless from then. Spread usage of CompatOCISpec can make code structure confusing and making the runtime spec usage non-standard. Besides, this can be the very first step of removing CompatOCISpec from config's Annotations field. Signed-off-by: Wei Zhang <weizhang555.zw@gmail.com>
65 lines
1.4 KiB
Go
65 lines
1.4 KiB
Go
// Copyright (c) 2018 HyperHQ Inc.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package containerdshim
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/containerd/containerd/api/types/task"
|
|
"github.com/containerd/containerd/errdefs"
|
|
taskAPI "github.com/containerd/containerd/runtime/v2/task"
|
|
"github.com/opencontainers/runtime-spec/specs-go"
|
|
|
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
|
)
|
|
|
|
type container struct {
|
|
s *service
|
|
ttyio *ttyIO
|
|
spec *specs.Spec
|
|
exitTime time.Time
|
|
execs map[string]*exec
|
|
exitIOch chan struct{}
|
|
exitCh chan uint32
|
|
id string
|
|
stdin string
|
|
stdout string
|
|
stderr string
|
|
bundle string
|
|
cType vc.ContainerType
|
|
exit uint32
|
|
status task.Status
|
|
terminal bool
|
|
}
|
|
|
|
func newContainer(s *service, r *taskAPI.CreateTaskRequest, containerType vc.ContainerType, spec *specs.Spec) (*container, error) {
|
|
if r == nil {
|
|
return nil, errdefs.ToGRPCf(errdefs.ErrInvalidArgument, " CreateTaskRequest points to nil")
|
|
}
|
|
|
|
// in order to avoid deferencing a nil pointer in test
|
|
if spec == nil {
|
|
spec = &specs.Spec{}
|
|
}
|
|
|
|
c := &container{
|
|
s: s,
|
|
spec: spec,
|
|
id: r.ID,
|
|
bundle: r.Bundle,
|
|
stdin: r.Stdin,
|
|
stdout: r.Stdout,
|
|
stderr: r.Stderr,
|
|
terminal: r.Terminal,
|
|
cType: containerType,
|
|
execs: make(map[string]*exec),
|
|
status: task.StatusCreated,
|
|
exitIOch: make(chan struct{}),
|
|
exitCh: make(chan uint32, 1),
|
|
}
|
|
return c, nil
|
|
}
|