Package dev.zucca_ops.kustomtrace.parser
Class ReferenceExtractors
java.lang.Object
dev.zucca_ops.kustomtrace.parser.ReferenceExtractors
Provides various strategies (
ReferenceExtractor instances) for extracting
and resolving file path references from different fields within Kustomization files.
Each factory method returns a functional interface that takes the reference value
(e.g., a string or a list from the Kustomization map) and the base directory
of the current Kustomization file, and returns a Stream of resolved Paths.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ReferenceExtractorDeprecated.static ReferenceExtractorReturns aReferenceExtractorfor Kustomize fields (e.g., 'bases', 'components') that must reference directories.static ReferenceExtractorReturns aReferenceExtractorfor extracting file paths from theenvsandfilesfields of generator entries such asconfigMapGeneratorandsecretGenerator.static ReferenceExtractorinlinePathValue(String pathField) Returns aReferenceExtractorfor resolving a file path found within an inline map structure, typically used in Kustomize patches (e.g., the 'path' field in a patch definition that points to a YAML fragment file).static ReferenceExtractorresource()Returns aReferenceExtractorspecifically for resolving references that must be direct Kubernetes resource files (not directories).static ReferenceExtractorExtractor for Kustomize 'resources' field entries.
-
Constructor Details
-
ReferenceExtractors
public ReferenceExtractors()
-
-
Method Details
-
directory
Returns aReferenceExtractorfor Kustomize fields (e.g., 'bases', 'components') that must reference directories.The returned extractor expects the resolved path to be a directory and will then attempt to find a kustomization definition file (e.g., "kustomization.yaml") within it.
- Returns:
- A
ReferenceExtractor. Itsextractmethod returns a stream with a singlePathto the resolved kustomization definition file. Theextractmethod may throw anInvalidReferenceExceptionif the input path is not a directory, if no valid kustomization definition is found, or if a self-reference is detected.
-
resourceOrDirectory
Extractor for Kustomize 'resources' field entries.Attempts to resolve the path as a Kustomization target first. If that fails, it treats the path as a direct Kubernetes resource file.
- Returns:
- A stream containing the resolved
Pathto either a kustomization definition file or a validated Kubernetes resource file. method may throw anInvalidReferenceExceptionif the input path is not a directory, target nor a valid, existing Kubernetes resource file.
-
resource
Returns aReferenceExtractorspecifically for resolving references that must be direct Kubernetes resource files (not directories). -
inlinePathValue
Returns aReferenceExtractorfor resolving a file path found within an inline map structure, typically used in Kustomize patches (e.g., the 'path' field in a patch definition that points to a YAML fragment file).- Parameters:
pathField- The key within the referenceValue map (which represents the patch data) that holds the string value of the path to be resolved.- Returns:
- A stream containing the resolved
Pathto the Kubernetes resource, or an empty stream if the pathField is not found or the referenceValue is not a map.
-
generatorFiles
Returns aReferenceExtractorfor extracting file paths from theenvsandfilesfields of generator entries such asconfigMapGeneratorandsecretGenerator. Handles parsing ofkey=pathformat in thefileslist. -
configMapGeneratorFiles
Deprecated.UsegeneratorFiles().
-
generatorFiles().