# The class this operator's own pod claims through. It ships with
# the base because the claim template in operator.yaml names it
# literally: it is wiring, not policy, and the operator cannot
# start without it. The classes your workloads claim through, such
# as an output class, are the cluster owner's vocabulary to create,
# and the install guide gives the YAML.
---
# Any device that supports a sound server. Today that is the sound
# card liken publishes and the media bus the Bluetooth operator
# publishes for each adapter. The operator's own pod claims every such
# device on its node, and the claim does two jobs. It places the
# pod, because only a machine with such a device publishes one, so
# no node selector has to name the machine with the speakers. And it
# arbitrates, because each device allocates once, so the claim
# holder is the only sound server on it. ALSA gives each PCM
# subdevice to one opener and refuses a second open with EBUSY, and
# two claims sharing a card have no contract over which claim gets
# which output, so that refusal would arrive at play time on
# whichever pod opened second.
#
# The selector names no driver. supportsSound is a qualified
# attribute in a domain no single driver owns: liken stamps it on
# the sound card, and the Bluetooth operator stamps it on the media
# bus, so the pod's allocationMode: All claim takes the card and
# the bus together, and a future driver joins by stamping the one
# field. The has() guard is what keeps an unguarded read from
# aborting the allocation on a device that does not carry the
# attribute.
apiVersion: resource.k8s.io/v1
kind: DeviceClass
metadata:
  name: sound-card
spec:
  selectors:
    - cel:
        expression: |
          has(device.attributes["sound.liken.sh"].supportsSound) &&
          device.attributes["sound.liken.sh"].supportsSound
