config.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package specs
  2. import "os"
  3. // CurrentVersion is the current version of the Spec.
  4. const CurrentVersion = "0.6.0"
  5. // Spec is the base configuration for CDI
  6. type Spec struct {
  7. Version string `json:"cdiVersion"`
  8. Kind string `json:"kind"`
  9. // Annotations add meta information per CDI spec. Note these are CDI-specific and do not affect container metadata.
  10. Annotations map[string]string `json:"annotations,omitempty"`
  11. Devices []Device `json:"devices"`
  12. ContainerEdits ContainerEdits `json:"containerEdits,omitempty"`
  13. }
  14. // Device is a "Device" a container runtime can add to a container
  15. type Device struct {
  16. Name string `json:"name"`
  17. // Annotations add meta information per device. Note these are CDI-specific and do not affect container metadata.
  18. Annotations map[string]string `json:"annotations,omitempty"`
  19. ContainerEdits ContainerEdits `json:"containerEdits"`
  20. }
  21. // ContainerEdits are edits a container runtime must make to the OCI spec to expose the device.
  22. type ContainerEdits struct {
  23. Env []string `json:"env,omitempty"`
  24. DeviceNodes []*DeviceNode `json:"deviceNodes,omitempty"`
  25. Hooks []*Hook `json:"hooks,omitempty"`
  26. Mounts []*Mount `json:"mounts,omitempty"`
  27. }
  28. // DeviceNode represents a device node that needs to be added to the OCI spec.
  29. type DeviceNode struct {
  30. Path string `json:"path"`
  31. HostPath string `json:"hostPath,omitempty"`
  32. Type string `json:"type,omitempty"`
  33. Major int64 `json:"major,omitempty"`
  34. Minor int64 `json:"minor,omitempty"`
  35. FileMode *os.FileMode `json:"fileMode,omitempty"`
  36. Permissions string `json:"permissions,omitempty"`
  37. UID *uint32 `json:"uid,omitempty"`
  38. GID *uint32 `json:"gid,omitempty"`
  39. }
  40. // Mount represents a mount that needs to be added to the OCI spec.
  41. type Mount struct {
  42. HostPath string `json:"hostPath"`
  43. ContainerPath string `json:"containerPath"`
  44. Options []string `json:"options,omitempty"`
  45. Type string `json:"type,omitempty"`
  46. }
  47. // Hook represents a hook that needs to be added to the OCI spec.
  48. type Hook struct {
  49. HookName string `json:"hookName"`
  50. Path string `json:"path"`
  51. Args []string `json:"args,omitempty"`
  52. Env []string `json:"env,omitempty"`
  53. Timeout *int `json:"timeout,omitempty"`
  54. }