...

Package v1

import "edge-infra.dev/pkg/sds/devices/k8s/apis/v1"
Overview
Index

Overview ▾

+kubebuilder:object:generate=true +groupName=device-system.edge.ncr.com

Index ▾

Constants
Variables
func ListFromClient(ctx context.Context, c client.Client, o ...ListOption) (map[string]*DeviceClass, error)
func WatchFromClient(ctx context.Context, c client.Client, config *rest.Config, deviceClassChan chan *DeviceClass, options ...ListOption) (dynamicinformer.DynamicSharedInformerFactory, error)
type Blocking
    func (in *Blocking) DeepCopy() *Blocking
    func (in *Blocking) DeepCopyInto(out *Blocking)
type DeviceClass
    func FromClient(ctx context.Context, c client.Client, name string) (*DeviceClass, error)
    func (dc *DeviceClass) AddDeviceIfMatched(sysPath string) (bool, error)
    func (dc *DeviceClass) ClassName() string
    func (in *DeviceClass) DeepCopy() *DeviceClass
    func (in *DeviceClass) DeepCopyInto(out *DeviceClass)
    func (in *DeviceClass) DeepCopyObject() runtime.Object
    func (dc *DeviceClass) DeviceExistsInClass(sysPath string) bool
    func (dc *DeviceClass) DeviceGet(sysPath string) devices.Device
    func (dc *DeviceClass) DeviceIter() iter.Seq2[string, devices.Device]
    func (dc *DeviceClass) Name() string
    func (dc *DeviceClass) RemoveDevice(sysPath string) bool
    func (dc *DeviceClass) Validate() error
    func (dc *DeviceClass) WillBlock() (bool, string)
type DeviceClassList
    func (in *DeviceClassList) DeepCopy() *DeviceClassList
    func (in *DeviceClassList) DeepCopyInto(out *DeviceClassList)
    func (in *DeviceClassList) DeepCopyObject() runtime.Object
type DeviceClassSpec
    func (in *DeviceClassSpec) DeepCopy() *DeviceClassSpec
    func (in *DeviceClassSpec) DeepCopyInto(out *DeviceClassSpec)
type DeviceRef
    func (in *DeviceRef) DeepCopy() *DeviceRef
    func (in *DeviceRef) DeepCopyInto(out *DeviceRef)
type DeviceSet
    func (ds *DeviceSet) AddIfMatched(sysPath string) (bool, error)
    func (in *DeviceSet) DeepCopy() *DeviceSet
    func (in *DeviceSet) DeepCopyInto(out *DeviceSet)
    func (in *DeviceSet) DeepCopyObject() runtime.Object
    func (ds *DeviceSet) Exists(sysPath string) bool
    func (ds *DeviceSet) Get(sysPath string) devices.Device
    func (ds *DeviceSet) Iter() iter.Seq2[string, devices.Device]
    func (ds *DeviceSet) Name() string
    func (ds *DeviceSet) Remove(sysPath string) bool
    func (ds *DeviceSet) Validate() error
    func (ds *DeviceSet) WillBlock() (bool, string)
type DeviceSetList
    func (in *DeviceSetList) DeepCopy() *DeviceSetList
    func (in *DeviceSetList) DeepCopyInto(out *DeviceSetList)
    func (in *DeviceSetList) DeepCopyObject() runtime.Object
type DeviceSetReference
    func (in *DeviceSetReference) DeepCopy() *DeviceSetReference
    func (in *DeviceSetReference) DeepCopyInto(out *DeviceSetReference)
type DeviceSpec
    func (in *DeviceSpec) DeepCopy() *DeviceSpec
    func (in *DeviceSpec) DeepCopyInto(out *DeviceSpec)
type DeviceState
    func (in *DeviceState) DeepCopy() *DeviceState
    func (in *DeviceState) DeepCopyInto(out *DeviceState)
type DeviceStatuses
    func (in *DeviceStatuses) DeepCopy() *DeviceStatuses
    func (in *DeviceStatuses) DeepCopyInto(out *DeviceStatuses)
    func (in *DeviceStatuses) DeepCopyObject() runtime.Object
type DeviceStatusesList
    func (in *DeviceStatusesList) DeepCopy() *DeviceStatusesList
    func (in *DeviceStatusesList) DeepCopyInto(out *DeviceStatusesList)
    func (in *DeviceStatusesList) DeepCopyObject() runtime.Object
type DeviceStatusesSpec
    func (in *DeviceStatusesSpec) DeepCopy() *DeviceStatusesSpec
    func (in *DeviceStatusesSpec) DeepCopyInto(out *DeviceStatusesSpec)
type ListOption
    func WithPersistence(enabled bool) ListOption
    func WithPersistencePath(path string) ListOption
    func (in *ListOption) DeepCopy() *ListOption
    func (in *ListOption) DeepCopyInto(out *ListOption)
type Logging
    func (in *Logging) DeepCopy() *Logging
    func (in *Logging) DeepCopyInto(out *Logging)
    func (l *Logging) LogLevel() slog.Level
type Rule
    func (in *Rule) DeepCopy() *Rule
    func (in *Rule) DeepCopyInto(out *Rule)

Package files

cache.go client.go conversion.go deviceclass_types.go devicesets_types.go devicestatuses_types.go groupversion_info.go zz_generated.deepcopy.go

Constants

const (
    MarkDeletedAnn = "device-system/mark-deleted"
)

Variables

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

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

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

type Blocking struct{}

func (*Blocking) DeepCopy

func (in *Blocking) DeepCopy() *Blocking

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Blocking.

func (*Blocking) DeepCopyInto

func (in *Blocking) DeepCopyInto(out *Blocking)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type DeviceClass

+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

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 (*DeviceClass) AddDeviceIfMatched

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 (*DeviceClass) ClassName

func (dc *DeviceClass) ClassName() string

ClassName returns the formatted class name for device class

func (*DeviceClass) DeepCopy

func (in *DeviceClass) DeepCopy() *DeviceClass

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceClass.

func (*DeviceClass) DeepCopyInto

func (in *DeviceClass) DeepCopyInto(out *DeviceClass)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*DeviceClass) DeepCopyObject

func (in *DeviceClass) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*DeviceClass) DeviceExistsInClass

func (dc *DeviceClass) DeviceExistsInClass(sysPath string) bool

DeviceExistsInClass checks to see if the device sys path exists in the device class

func (*DeviceClass) DeviceGet

func (dc *DeviceClass) DeviceGet(sysPath string) devices.Device

DeviceGet will return a device from device status given sys path

func (*DeviceClass) DeviceIter

func (dc *DeviceClass) DeviceIter() iter.Seq2[string, devices.Device]

DeviceIter returns an iterator over the device map

func (*DeviceClass) Name

func (dc *DeviceClass) Name() string

Name returns the class name

func (*DeviceClass) RemoveDevice

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 (*DeviceClass) Validate

func (dc *DeviceClass) Validate() error

Validate will validate the device class CR and return any validation errors

func (*DeviceClass) WillBlock

func (dc *DeviceClass) WillBlock() (bool, string)

WillBlock iterates through device sets and determines if the device class needs to block

type DeviceClassList

+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 (*DeviceClassList) DeepCopy

func (in *DeviceClassList) DeepCopy() *DeviceClassList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceClassList.

func (*DeviceClassList) DeepCopyInto

func (in *DeviceClassList) DeepCopyInto(out *DeviceClassList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*DeviceClassList) DeepCopyObject

func (in *DeviceClassList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type DeviceClassSpec

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 (*DeviceClassSpec) DeepCopy

func (in *DeviceClassSpec) DeepCopy() *DeviceClassSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceClassSpec.

func (*DeviceClassSpec) DeepCopyInto

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

type DeviceRef struct {
    // Name is the name of a Device CR
    Name string `json:"name"`
}

func (*DeviceRef) DeepCopy

func (in *DeviceRef) DeepCopy() *DeviceRef

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceRef.

func (*DeviceRef) DeepCopyInto

func (in *DeviceRef) DeepCopyInto(out *DeviceRef)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type DeviceSet

+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 (*DeviceSet) AddIfMatched

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 (*DeviceSet) DeepCopy

func (in *DeviceSet) DeepCopy() *DeviceSet

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceSet.

func (*DeviceSet) DeepCopyInto

func (in *DeviceSet) DeepCopyInto(out *DeviceSet)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*DeviceSet) DeepCopyObject

func (in *DeviceSet) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*DeviceSet) Exists

func (ds *DeviceSet) Exists(sysPath string) bool

DeviceExists checks to see if the device sys path exists in the device list

func (*DeviceSet) Get

func (ds *DeviceSet) Get(sysPath string) devices.Device

DeviceGet will return a device from device status given sys path

func (*DeviceSet) Iter

func (ds *DeviceSet) Iter() iter.Seq2[string, devices.Device]

Iter returns an iterator over the device map

func (*DeviceSet) Name

func (ds *DeviceSet) Name() string

Name returns the device set name

func (*DeviceSet) Remove

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 (*DeviceSet) Validate

func (ds *DeviceSet) Validate() error

Validate will validate the device CR and return any validation errors

func (*DeviceSet) WillBlock

func (ds *DeviceSet) WillBlock() (bool, string)

WillBlock iterates through device sets and determines if the device needs to block

type DeviceSetList

+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 (*DeviceSetList) DeepCopy

func (in *DeviceSetList) DeepCopy() *DeviceSetList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceSetList.

func (*DeviceSetList) DeepCopyInto

func (in *DeviceSetList) DeepCopyInto(out *DeviceSetList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*DeviceSetList) DeepCopyObject

func (in *DeviceSetList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type DeviceSetReference

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 (*DeviceSetReference) DeepCopy

func (in *DeviceSetReference) DeepCopy() *DeviceSetReference

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceSetReference.

func (*DeviceSetReference) DeepCopyInto

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

type DeviceSpec struct {
    // DeviceSets contains a list of matchers based on device properties and attributes (udev)
    DeviceSets []DeviceSetReference `json:"deviceSets"`
}

func (*DeviceSpec) DeepCopy

func (in *DeviceSpec) DeepCopy() *DeviceSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceSpec.

func (*DeviceSpec) DeepCopyInto

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

type DeviceState struct {
    Name string `json:"name"`
}

func (*DeviceState) DeepCopy

func (in *DeviceState) DeepCopy() *DeviceState

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceState.

func (*DeviceState) DeepCopyInto

func (in *DeviceState) DeepCopyInto(out *DeviceState)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type DeviceStatuses

+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 (*DeviceStatuses) DeepCopy

func (in *DeviceStatuses) DeepCopy() *DeviceStatuses

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceStatuses.

func (*DeviceStatuses) DeepCopyInto

func (in *DeviceStatuses) DeepCopyInto(out *DeviceStatuses)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*DeviceStatuses) DeepCopyObject

func (in *DeviceStatuses) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type DeviceStatusesList

+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 (*DeviceStatusesList) DeepCopy

func (in *DeviceStatusesList) DeepCopy() *DeviceStatusesList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceStatusesList.

func (*DeviceStatusesList) DeepCopyInto

func (in *DeviceStatusesList) DeepCopyInto(out *DeviceStatusesList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*DeviceStatusesList) DeepCopyObject

func (in *DeviceStatusesList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type DeviceStatusesSpec

type DeviceStatusesSpec struct {
    Devices      map[string][]DeviceState `json:"devices,omitempty"`
    DeviceGroups map[string][]int64       `json:"deviceGroups,omitempty"`
}

func (*DeviceStatusesSpec) DeepCopy

func (in *DeviceStatusesSpec) DeepCopy() *DeviceStatusesSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeviceStatusesSpec.

func (*DeviceStatusesSpec) DeepCopyInto

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

type ListOption func(*opts)

func WithPersistence

func WithPersistence(enabled bool) ListOption

WithPersistence uses the local persistent cache if API server is unavailable

func WithPersistencePath

func WithPersistencePath(path string) ListOption

WithPersistencePath sets the path to cache file

func (*ListOption) DeepCopy

func (in *ListOption) DeepCopy() *ListOption

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ListOption.

func (*ListOption) DeepCopyInto

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

type Logging struct {
    // +optional
    Level string `json:"level"`
}

func (*Logging) DeepCopy

func (in *Logging) DeepCopy() *Logging

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Logging.

func (*Logging) DeepCopyInto

func (in *Logging) DeepCopyInto(out *Logging)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Logging) LogLevel

func (l *Logging) LogLevel() slog.Level

type Rule

type Rule struct {
    Name       string `json:"name"`
    RegexValue string `json:"value"`
}

func (*Rule) DeepCopy

func (in *Rule) DeepCopy() *Rule

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Rule.

func (*Rule) DeepCopyInto

func (in *Rule) DeepCopyInto(out *Rule)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.