const (
MarkDeletedAnn = "device-system/mark-deleted"
)
var ( ErrInvalidMissingSubsystem = errors.New("invalid resource: missing subsystem in device sets") ErrInvalidName = errors.New("invalid resource name: name can only contain lowercase characters and hyphens") )
var ( // GroupVersion is group version used to register these objects GroupVersion = schema.GroupVersion{Group: "device-system.edge.ncr.com", Version: "v1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} // AddToScheme adds the types in this group-version to the given scheme. AddToScheme = SchemeBuilder.AddToScheme )
func ListFromClient(ctx context.Context, c client.Client, o ...ListOption) (map[string]*DeviceClass, error)
ListFromClient fetches and populates all device classes by parsing sys fs. It is recommended to use this class method to fetch the device classes from kubernetes API.
func WatchFromClient(ctx context.Context, c client.Client, config *rest.Config, deviceClassChan chan *DeviceClass, options ...ListOption) (dynamicinformer.DynamicSharedInformerFactory, error)
WatchFromClient will return an informer to watch for device class updates and send them to the device class channel
type Blocking struct{}
func (in *Blocking) DeepCopy() *Blocking
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Blocking.
func (in *Blocking) DeepCopyInto(out *Blocking)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+kubebuilder:object:root=true +kubebuilder:subresource:status +kubebuilder:resource:path=deviceclasses,scope=Cluster,shortName=dc
type DeviceClass struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` Spec DeviceClassSpec `json:"spec,omitempty"` DeviceStatus deviceStatus DeviceList []*DeviceSet }
func FromClient(ctx context.Context, c client.Client, name string) (*DeviceClass, error)
FromClient fetches and populates a device class by parsing sys fs. It is recommended to use this class method to fetch the device classes from kubernetes API.
func (dc *DeviceClass) AddDeviceIfMatched(sysPath string) (bool, error)
AddDeviceIfMatched will take a given path and determine whether to add it to the device class. If the device has an ascendant or matches a device set it will be added. If a device is added, the method will return true.
func (dc *DeviceClass) ClassName() string
ClassName returns the formatted class name for device class
func (in *DeviceClass) DeepCopy() *DeviceClass
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceClass.
func (in *DeviceClass) DeepCopyInto(out *DeviceClass)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DeviceClass) DeepCopyObject() runtime.Object
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (dc *DeviceClass) DeviceExistsInClass(sysPath string) bool
DeviceExistsInClass checks to see if the device sys path exists in the device class
func (dc *DeviceClass) DeviceGet(sysPath string) devices.Device
DeviceGet will return a device from device status given sys path
func (dc *DeviceClass) DeviceIter() iter.Seq2[string, devices.Device]
DeviceIter returns an iterator over the device map
func (dc *DeviceClass) Name() string
Name returns the class name
func (dc *DeviceClass) RemoveDevice(sysPath string) bool
RemoveDevice will attempt to remove the device from the class. Returns true if the device was truly deleted from the device class struct.
func (dc *DeviceClass) Validate() error
Validate will validate the device class CR and return any validation errors
func (dc *DeviceClass) WillBlock() (bool, string)
WillBlock iterates through device sets and determines if the device class needs to block
+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type DeviceClassList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` Items []DeviceClass `json:"items"` }
func (in *DeviceClassList) DeepCopy() *DeviceClassList
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceClassList.
func (in *DeviceClassList) DeepCopyInto(out *DeviceClassList)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DeviceClassList) DeepCopyObject() runtime.Object
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
type DeviceClassSpec struct { // +optional Logging `json:"logging"` // DeviceSets contains a list of matchers based on device properties and attributes (udev) // +optional DeviceSets []DeviceSetReference `json:"deviceSets"` // Devices contains a list of Device CRs to assign to this class // +optional Devices []DeviceRef `json:"devices"` }
func (in *DeviceClassSpec) DeepCopy() *DeviceClassSpec
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceClassSpec.
func (in *DeviceClassSpec) DeepCopyInto(out *DeviceClassSpec)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type DeviceRef struct { // Name is the name of a Device CR Name string `json:"name"` }
func (in *DeviceRef) DeepCopy() *DeviceRef
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceRef.
func (in *DeviceRef) DeepCopyInto(out *DeviceRef)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+kubebuilder:object:root=true +kubebuilder:resource:path=devicesets,scope=Cluster
type DeviceSet struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` Spec DeviceSpec `json:"spec,omitempty"` DeviceStatus deviceStatus }
func (ds *DeviceSet) AddIfMatched(sysPath string) (bool, error)
AddDeviceIfMatched will take a given path and determine whether to add it to the device. If the device has an ascendant or matches a device set it will be added. If a device is added, the method will return true.
func (in *DeviceSet) DeepCopy() *DeviceSet
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceSet.
func (in *DeviceSet) DeepCopyInto(out *DeviceSet)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DeviceSet) DeepCopyObject() runtime.Object
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (ds *DeviceSet) Exists(sysPath string) bool
DeviceExists checks to see if the device sys path exists in the device list
func (ds *DeviceSet) Get(sysPath string) devices.Device
DeviceGet will return a device from device status given sys path
func (ds *DeviceSet) Iter() iter.Seq2[string, devices.Device]
Iter returns an iterator over the device map
func (ds *DeviceSet) Name() string
Name returns the device set name
func (ds *DeviceSet) Remove(sysPath string) bool
RemoveDevice will attempt to remove the device. Returns true if the device was truly deleted from the device struct.
func (ds *DeviceSet) Validate() error
Validate will validate the device CR and return any validation errors
func (ds *DeviceSet) WillBlock() (bool, string)
WillBlock iterates through device sets and determines if the device needs to block
+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type DeviceSetList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` Items []DeviceSet `json:"items"` }
func (in *DeviceSetList) DeepCopy() *DeviceSetList
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceSetList.
func (in *DeviceSetList) DeepCopyInto(out *DeviceSetList)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DeviceSetList) DeepCopyObject() runtime.Object
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
type DeviceSetReference struct { Name string `json:"name"` // Block will prevent containers from starting if a device in the device cr is not ready // +optional Blocking *Blocking `json:"blocking"` // +optional Attributes []Rule `json:"attributes"` // +optional Properties []Rule `json:"properties"` }
func (in *DeviceSetReference) DeepCopy() *DeviceSetReference
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceSetReference.
func (in *DeviceSetReference) DeepCopyInto(out *DeviceSetReference)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type DeviceSpec struct { // DeviceSets contains a list of matchers based on device properties and attributes (udev) DeviceSets []DeviceSetReference `json:"deviceSets"` }
func (in *DeviceSpec) DeepCopy() *DeviceSpec
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceSpec.
func (in *DeviceSpec) DeepCopyInto(out *DeviceSpec)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type DeviceState struct { Name string `json:"name"` }
func (in *DeviceState) DeepCopy() *DeviceState
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceState.
func (in *DeviceState) DeepCopyInto(out *DeviceState)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+kubebuilder:object:root=true +kubebuilder:resource:path=devicestatuses,scope=Cluster
type DeviceStatuses struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` Spec DeviceStatusesSpec `json:"spec,omitempty"` }
func (in *DeviceStatuses) DeepCopy() *DeviceStatuses
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceStatuses.
func (in *DeviceStatuses) DeepCopyInto(out *DeviceStatuses)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DeviceStatuses) DeepCopyObject() runtime.Object
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type DeviceStatusesList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` Items []DeviceStatuses `json:"items"` }
func (in *DeviceStatusesList) DeepCopy() *DeviceStatusesList
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceStatusesList.
func (in *DeviceStatusesList) DeepCopyInto(out *DeviceStatusesList)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DeviceStatusesList) DeepCopyObject() runtime.Object
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
type DeviceStatusesSpec struct { Devices map[string][]DeviceState `json:"devices,omitempty"` DeviceGroups map[string][]int64 `json:"deviceGroups,omitempty"` }
func (in *DeviceStatusesSpec) DeepCopy() *DeviceStatusesSpec
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceStatusesSpec.
func (in *DeviceStatusesSpec) DeepCopyInto(out *DeviceStatusesSpec)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ListOption func(*opts)
func WithPersistence(enabled bool) ListOption
WithPersistence uses the local persistent cache if API server is unavailable
func WithPersistencePath(path string) ListOption
WithPersistencePath sets the path to cache file
func (in *ListOption) DeepCopy() *ListOption
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ListOption.
func (in *ListOption) DeepCopyInto(out *ListOption)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Logging struct { // +optional Level string `json:"level"` }
func (in *Logging) DeepCopy() *Logging
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Logging.
func (in *Logging) DeepCopyInto(out *Logging)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (l *Logging) LogLevel() slog.Level
type Rule struct { Name string `json:"name"` RegexValue string `json:"value"` }
func (in *Rule) DeepCopy() *Rule
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Rule.
func (in *Rule) DeepCopyInto(out *Rule)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.