Enum Class ReferenceType

java.lang.Object
java.lang.Enum<ReferenceType>
dev.zucca_ops.kustomtrace.parser.ReferenceType
All Implemented Interfaces:
Serializable, Comparable<ReferenceType>, Constable

public enum ReferenceType extends Enum<ReferenceType>
Defines the different types of Kustomize fields that can contain references to other resources or Kustomization files.

Each enum constant is associated with a specific YAML key found in Kustomization files and a ReferenceExtractor strategy responsible for parsing the value of that key to extract and resolve file paths.

  • Enum Constant Details

  • Method Details

    • values

      public static ReferenceType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ReferenceType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getYamlKey

      public String getYamlKey()
      Gets the YAML key string associated with this reference type (e.g., "resources", "bases").
      Returns:
      The YAML key.
    • extract

      public Stream<Path> extract(Object yamlValue, Path baseDir)
      Extracts and resolves file paths from the given YAML value using the ReferenceExtractor associated with this reference type. Handles InvalidReferenceException from the extractor by logging and returning an empty stream.
      Parameters:
      yamlValue - The raw value associated with this reference type's key, obtained from the parsed Kustomization YAML content.
      baseDir - The base directory for resolving relative paths found in the yamlValue.
      Returns:
      A Stream of resolved Path objects. Returns an empty stream if extraction fails or no valid references are found.
    • getRawReferences

      public Stream<Object> getRawReferences(Map<String,Object> kustomizationContentMap)
      Retrieves raw reference values from a Kustomization content map for this reference type. Expects the value associated with getYamlKey() to be a List.
      Parameters:
      kustomizationContentMap - The parsed content of a Kustomization file.
      Returns:
      A stream of objects from the list, or an empty stream if the key is absent or its value is not a list.
    • fromYamlKey

      public static ReferenceType fromYamlKey(String key)
      Retrieves a ReferenceType enum constant based on its YAML key.
      Parameters:
      key - The YAML key string (e.g., "resources", "bases").
      Returns:
      The corresponding ReferenceType, or null if no match is found.
    • isReferenceKey

      public static Boolean isReferenceKey(String key)
      Checks if a given YAML key corresponds to a known ReferenceType.
      Parameters:
      key - The YAML key string.
      Returns:
      True if the key is a known reference type, false otherwise.