summaryrefslogtreecommitdiff
path: root/vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-01-14 15:17:21 +0100
committerGitHub <noreply@github.com>2022-01-14 15:17:21 +0100
commit7ab99227e63bfec734bf2372e80ef5a93dc2ef54 (patch)
tree4d5cc90840d8a13717891aecadf170533830d117 /vendor/github.com/container-orchestrated-devices/container-device-interface/specs-go
parent9686216f9d44e1d6b4fa60a5c0866746d1afa60b (diff)
parent72ab66d88622eadcf7c603aa5e6c0751d72214dc (diff)
downloadpodman-7ab99227e63bfec734bf2372e80ef5a93dc2ef54.tar.gz
podman-7ab99227e63bfec734bf2372e80ef5a93dc2ef54.tar.bz2
podman-7ab99227e63bfec734bf2372e80ef5a93dc2ef54.zip
Merge pull request #12825 from elezar/update-cdi
Update use of CDI API
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,
}
}