aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go
diff options
context:
space:
mode:
authorEvan Lezar <elezar@nvidia.com>2022-01-12 14:22:29 +0100
committerEvan Lezar <elezar@nvidia.com>2022-01-14 13:35:22 +0100
commit968deb7c2cd2e4fab7edf03f2a73fb62bb652171 (patch)
treeea0349b4a36a44625e5f6dda891034986da8417f /vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go
parent2c510146aa03c74fb00a15bcf81c62b14df9c7ea (diff)
downloadpodman-968deb7c2cd2e4fab7edf03f2a73fb62bb652171.tar.gz
podman-968deb7c2cd2e4fab7edf03f2a73fb62bb652171.tar.bz2
podman-968deb7c2cd2e4fab7edf03f2a73fb62bb652171.zip
Use new CDI API
This change updates the CDI API to commit 46367ec063fda9da931d050b308ccd768e824364 which addresses some inconistencies in the previous implementation. Signed-off-by: Evan Lezar <elezar@nvidia.com>
Diffstat (limited to 'vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go')
-rw-r--r--vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go/config.go21
-rw-r--r--vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go/oci.go42
2 files changed, 38 insertions, 25 deletions
diff --git a/vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go/config.go b/vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go/config.go
index 0223bb703..20914e5b6 100644
--- a/vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go/config.go
+++ b/vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go/config.go
@@ -1,20 +1,20 @@
package specs
+import "os"
+
// Spec is the base configuration for CDI
type Spec struct {
Version string `json:"cdiVersion"`
Kind string `json:"kind"`
- KindShort []string `json:"kindShort,omitempty"`
ContainerRuntime []string `json:"containerRuntime,omitempty"`
- Devices []Devices `json:"devices"`
+ Devices []Device `json:"devices"`
ContainerEdits ContainerEdits `json:"containerEdits,omitempty"`
}
-// Devices is a "Device" a container runtime can add to a container
-type Devices struct {
+// Device is a "Device" a container runtime can add to a container
+type Device struct {
Name string `json:"name"`
- NameShort []string `json:"nameShort"`
ContainerEdits ContainerEdits `json:"containerEdits"`
}
@@ -28,9 +28,14 @@ type ContainerEdits struct {
// DeviceNode represents a device node that needs to be added to the OCI spec.
type DeviceNode struct {
- HostPath string `json:"hostPath"`
- ContainerPath string `json:"containerPath"`
- Permissions []string `json:"permissions,omitempty"`
+ Path string `json:"path"`
+ Type string `json:"type,omitempty"`
+ Major int64 `json:"major,omitempty"`
+ Minor int64 `json:"minor,omitempty"`
+ FileMode *os.FileMode `json:"fileMode,omitempty"`
+ Permissions string `json:"permissions,omitempty"`
+ UID *uint32 `json:"uid,omitempty"`
+ GID *uint32 `json:"gid,omitempty"`
}
// Mount represents a mount that needs to be added to the OCI spec.
diff --git a/vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go/oci.go b/vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go/oci.go
index c59cda55d..10bc9fa23 100644
--- a/vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go/oci.go
+++ b/vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go/oci.go
@@ -37,20 +37,21 @@ func ApplyEditsToOCISpec(config *spec.Spec, edits *ContainerEdits) error {
}
if len(edits.Env) > 0 {
-
if config.Process == nil {
config.Process = &spec.Process{}
}
-
config.Process.Env = append(config.Process.Env, edits.Env...)
}
for _, d := range edits.DeviceNodes {
- config.Mounts = append(config.Mounts, toOCIDevice(d))
+ if config.Linux == nil {
+ config.Linux = &spec.Linux{}
+ }
+ config.Linux.Devices = append(config.Linux.Devices, d.ToOCI())
}
for _, m := range edits.Mounts {
- config.Mounts = append(config.Mounts, toOCIMount(m))
+ config.Mounts = append(config.Mounts, m.ToOCI())
}
for _, h := range edits.Hooks {
@@ -59,17 +60,17 @@ func ApplyEditsToOCISpec(config *spec.Spec, edits *ContainerEdits) error {
}
switch h.HookName {
case "prestart":
- config.Hooks.Prestart = append(config.Hooks.Prestart, toOCIHook(h))
+ config.Hooks.Prestart = append(config.Hooks.Prestart, h.ToOCI())
case "createRuntime":
- config.Hooks.CreateRuntime = append(config.Hooks.CreateRuntime, toOCIHook(h))
+ config.Hooks.CreateRuntime = append(config.Hooks.CreateRuntime, h.ToOCI())
case "createContainer":
- config.Hooks.CreateContainer = append(config.Hooks.CreateContainer, toOCIHook(h))
+ config.Hooks.CreateContainer = append(config.Hooks.CreateContainer, h.ToOCI())
case "startContainer":
- config.Hooks.StartContainer = append(config.Hooks.StartContainer, toOCIHook(h))
+ config.Hooks.StartContainer = append(config.Hooks.StartContainer, h.ToOCI())
case "poststart":
- config.Hooks.Poststart = append(config.Hooks.Poststart, toOCIHook(h))
+ config.Hooks.Poststart = append(config.Hooks.Poststart, h.ToOCI())
case "poststop":
- config.Hooks.Poststop = append(config.Hooks.Poststop, toOCIHook(h))
+ config.Hooks.Poststop = append(config.Hooks.Poststop, h.ToOCI())
default:
fmt.Printf("CDI: Unknown hook %q\n", h.HookName)
}
@@ -78,7 +79,8 @@ func ApplyEditsToOCISpec(config *spec.Spec, edits *ContainerEdits) error {
return nil
}
-func toOCIHook(h *Hook) spec.Hook {
+// ToOCI returns the opencontainers runtime Spec Hook for this Hook.
+func (h *Hook) ToOCI() spec.Hook {
return spec.Hook{
Path: h.Path,
Args: h.Args,
@@ -87,7 +89,8 @@ func toOCIHook(h *Hook) spec.Hook {
}
}
-func toOCIMount(m *Mount) spec.Mount {
+// ToOCI returns the opencontainers runtime Spec Mount for this Mount.
+func (m *Mount) ToOCI() spec.Mount {
return spec.Mount{
Source: m.HostPath,
Destination: m.ContainerPath,
@@ -95,10 +98,15 @@ func toOCIMount(m *Mount) spec.Mount {
}
}
-func toOCIDevice(d *DeviceNode) spec.Mount {
- return spec.Mount{
- Source: d.HostPath,
- Destination: d.ContainerPath,
- Options: d.Permissions,
+// ToOCI returns the opencontainers runtime Spec LinuxDevice for this DeviceNode.
+func (d *DeviceNode) ToOCI() spec.LinuxDevice {
+ return spec.LinuxDevice{
+ Path: d.Path,
+ Type: d.Type,
+ Major: d.Major,
+ Minor: d.Minor,
+ FileMode: d.FileMode,
+ UID: d.UID,
+ GID: d.GID,
}
}