Uncopypaste parsing of OCI Bundle spec file

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
This commit is contained in:
Marat Radchenko
2023-07-11 13:44:15 +03:00
parent d5ec7286ae
commit 9e34b8b441
6 changed files with 48 additions and 34 deletions

View File

@@ -32,6 +32,7 @@ import (
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/pkg/process"
"github.com/containerd/containerd/pkg/schedcore"
"github.com/containerd/containerd/runtime/v2/runc"
@@ -58,7 +59,11 @@ var groupLabels = []string{
"io.kubernetes.cri.sandbox-id",
}
// spec is a shallow version of [oci.Spec] containing only the
// fields we need for the hook. We use a shallow struct to reduce
// the overhead of unmarshaling.
type spec struct {
// Annotations contains arbitrary metadata for the container.
Annotations map[string]string `json:"annotations,omitempty"`
}
@@ -97,7 +102,7 @@ func newCommand(ctx context.Context, id, containerdAddress, containerdTTRPCAddre
}
func readSpec() (*spec, error) {
f, err := os.Open("config.json")
f, err := os.Open(oci.ConfigFilename)
if err != nil {
return nil, err
}