rdkcentral / ut-control

Control & KVP Module to support vDevice
Apache License 2.0
2 stars 0 forks source link

ut_control: ut_kvp: upgrade to support yaml validation #8

Open Ulrond opened 4 months ago

Ulrond commented 4 months ago

Using this as an example is it possible to validate input yaml files?

hdmicec:
  device_type: &device_type # List of allowed values
    - TV
    - STB_1
    - STB_2 
    - DVR_1
    - DVR_2
    - Chromecast
    - HomeTheatre
    - GamingConsole_1
    - GamingConsole_2
    - DVDPlayer_1
    - DVDPlayer_2
    - AVR_1
    - AVR_2
    - Switcher_1
    - Switcher_2
    - Camera_1
    - Camera_2
    - SpecialPurpose_1
    - SpecialPurpose_2
    - Unregistered_1
    - Unregistered_2

  port_id: &port_id # List of allowed types
    !!int
  port_type: &port_type # List of allowed values
    - in
    - out

  vendor: &vendor # List of allowed values
    - [TOSHIBA, 0x000039]
    - [SAMSUNG, 0x0000F0]
    - [DENON, 0x0005CD]
    - [MARANTZ, 0x000678]
    - [LOEWE, 0x000982]
    - [ONKYO, 0x0009B0]
    - [MEDION, 0x000CB8]
    - [TOSHIBA2, 0x000CE7]
    - [APPLE, 0x0010FA]
    - [HARMAN_KARDON2, 0x001950]
    - [GOOGLE, 0x001A11]
    - [AKAI, 0x0020C7]
    - [AOC, 0x002467]
    - [PANASONIC, 0x008045]
    - [PHILIPS, 0x00903E]
    - [DAEWOO, 0x009053]
    - [YAMAHA, 0x00A0DE]
    - [GRUNDIG, 0x00D0D5]
    - [PIONEER, 0x00E036]
    - [LG, 0x00E091]
    - [SHARP, 0x08001F]
    - [SONY, 0x080046]
    - [BROADCOM, 0x18C086]
    - [SHARP2, 0x534850]
    - [VIZIO, 0x6B746D]
    - [BENQ, 0x8065E9]
    - [HARMAN_KARDON, 0x9C645E]
    - [UNKNOWN, 0]

  cec_version: &cec_version # List of allowed values
    - 0  #Unknown
    - 1  rdkcentral/ut-core#1.2
    - 2  rdkcentral/ut-core#1.2A
    - 3  rdkcentral/ut-core#1.3
    - 4  rdkcentral/ut-core#1.3A
    - 5  rdkcentral/ut-core#1.4
    - 6  rdkcentral/ut-core#2.0

  power_status: &power_status # List of allowed values
    - on
    - off
    - standby

  endpoint: &endpoint
    name: !!str
    id: *port_id # One option must be selected from the list
    type: *port_type # One option must be selected from the list

  link: &link
    - *endpoint
    - *endpoint  

  version: *cec_version
  type: *device_type # One option must be selected from the list
  active_source: !!bool
  vendor_info: *vendor # One option must be selected from the list
  pwr_status: *power_status # One option must be selected from the list
  name: !!str
  number_ports: !!int
  ports:
    - id: *port_id
      type: *port_type  # One option must be selected from the list
      cec_supported: !!bool
      arc_supported: !!bool
    - id: *port_id # One option must be selected from the list
      type: *port_type # One option must be selected from the list
      cec_supported: !!bool
      arc_supported: !!bool
  number_devices: !!int
  devices:
    - type: *device_type # One option must be selected from the list
      version: *cec_version # One option must be selected from the list
      active_source: !!bool
      vendor_info: *vendor # One option must be selected from the list
      pwr_status: *power_status # One option must be selected from the list
      name: !!str

    - type: *device_type
      version: *cec_version # One option must be selected from the list
      active_source: !!bool
      vendor_info: *vendor # One option must be selected from the list
      pwr_status: *power_status # One option must be selected from the list
      name: !!str

    - type: *device_type
      version: *cec_version # One option must be selected from the list
      active_source: !!bool
      vendor_info: *vendor # One option must be selected from the list
      pwr_status: *power_status # One option must be selected from the list
      name: !!str

    - type: *device_type
      version: *cec_version # One option must be selected from the list
      active_source: !!bool
      vendor_info: *vendor # One option must be selected from the list
      pwr_status: *power_status # One option must be selected from the list
      name: !!str

Here's a discussion topic on the subject. https://blog.picnic.nl/how-to-use-yaml-schema-to-validate-your-yaml-files-c82c049c2097

Ulrond commented 3 months ago