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

@@ -18,7 +18,6 @@ package main
import (
"context"
"encoding/json"
"fmt"
"os"
"path/filepath"
@@ -35,8 +34,6 @@ import (
)
const (
ociConfigFilename = "config.json"
failpointPrefixKey = "io.containerd.runtime.v2.shim.failpoint."
)
@@ -113,15 +110,10 @@ func newFailpointFromOCIAnnotation() (map[string]*failpoint.Failpoint, error) {
return nil, fmt.Errorf("failed to get current working dir: %w", err)
}
configPath := filepath.Join(cwd, ociConfigFilename)
data, err := os.ReadFile(configPath)
configPath := filepath.Join(cwd, oci.ConfigFilename)
spec, err := oci.ReadSpec(configPath)
if err != nil {
return nil, fmt.Errorf("failed to read %v: %w", configPath, err)
}
var spec oci.Spec
if err := json.Unmarshal(data, &spec); err != nil {
return nil, fmt.Errorf("failed to parse oci.Spec(%v): %w", string(data), err)
return nil, err
}
res := make(map[string]*failpoint.Failpoint)