Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ func GetRuntimeClient(clicontext *cli.Context, hostname string) runtime.Client {
return runtime.NewContainerdClient(
context.Background(),
clicontext.GlobalDuration("timeout"),
clicontext.GlobalString("containerd"),
clicontext.String("containerd-snapshotter"),
clicontext.GlobalString("containerd"),
hostname,
)
}
Expand Down
10 changes: 10 additions & 0 deletions examples/devices.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
metadata:
name: "test"
spec:
containers:
- name: "busybox"
image: "docker.io/library/busybox:latest"
devices:
- DeviceType: "c"
MajorId: 555
MinorId: 0
12 changes: 12 additions & 0 deletions pkg/api/mapping/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func MapContainerToInternalModel(containers []*containers.Container) (result []m
Args: container.Args,
Env: container.Env,
WorkingDir: container.WorkingDir,
Devices: mapDeviceToInternalModel(container.Devices),
Mounts: mapMountsToInternalModel(container.Mounts),
Pipe: mapPipeToInternalModel(container.Pipe),
})
Expand Down Expand Up @@ -71,3 +72,14 @@ func mapMountsToInternalModel(mounts []*containers.Mount) (result []model.Mount)
}
return result
}

func mapDeviceToInternalModel(devices []*containers.Device) (result []model.Device) {
for _, device := range devices {
result = append(result, model.Device{
DeviceType: device.DeviceType,
MinorId: device.Minorid,
MajorId: device.Majorid,
})
}
return result
}
12 changes: 12 additions & 0 deletions pkg/api/mapping/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,25 @@ func MapContainersToAPIModel(source []model.Container) (result []*containers.Con
WorkingDir: container.WorkingDir,
Args: container.Args,
Env: container.Env,
Devices: mapDevicesToAPIModel(container.Devices),
Mounts: mapMountsToAPIModel(container.Mounts),
Pipe: mapPipeToAPIModel(container.Pipe),
})
}
return result
}

func mapDevicesToAPIModel(devices []model.Device) (result []*containers.Device) {
for _, device := range devices {
result = append(result, &containers.Device{
DeviceType: device.DeviceType,
Minorid: device.MinorId,
Majorid: device.MajorId,
})
}
return result
}

func mapMountsToAPIModel(mounts []model.Mount) (result []*containers.Mount) {
for _, mount := range mounts {
result = append(result, &containers.Mount{
Expand Down
Loading