Class YamlConfigProvider

java.lang.Object
io.javaoperatorsdk.operator.config.loader.provider.YamlConfigProvider
All Implemented Interfaces:
ConfigProvider

public class YamlConfigProvider extends Object implements ConfigProvider
A ConfigProvider that resolves configuration values from a YAML file.

Keys use dot-separated notation to address nested YAML mappings (e.g. josdk.cache-sync.timeout maps to josdk → cache-sync → timeout in the YAML document). Leaf values are converted to the requested type via ConfigValueConverter. Supported value types are: String, Boolean, Integer, Long, Double, and Duration (ISO-8601 format, e.g. PT30S).

  • Constructor Details

    • YamlConfigProvider

      public YamlConfigProvider(String path)
      Loads YAML from the given file path.
      Throws:
      UncheckedIOException - if the file cannot be read. Does not throw an exception if the file does not exist.
    • YamlConfigProvider

      public YamlConfigProvider(Path path)
      Loads YAML from the given file path.
      Throws:
      UncheckedIOException - if the file cannot be read. Does not throw an exception if the file does not exist.
    • YamlConfigProvider

      public YamlConfigProvider(Map<String,Object> data)
      Uses the supplied map directly (useful for testing).
  • Method Details

    • getValue

      public <T> Optional<T> getValue(String key, Class<T> type)
      Description copied from interface: ConfigProvider
      Returns the value associated with key, converted to type, or an empty Optional if the key is not set.
      Specified by:
      getValue in interface ConfigProvider
      Type Parameters:
      T - the value type
      Parameters:
      key - the dot-separated configuration key, e.g. josdk.cache.sync.timeout
      type - the expected type of the value; supported types depend on the implementation
      Returns:
      an Optional containing the typed value, or empty if the key is absent