Package dev.zucca_ops.kustomtrace.model
Class KustomGraph
java.lang.Object
dev.zucca_ops.kustomtrace.model.KustomGraph
Represents the complete graph of Kustomize resources and their relationships.
It maintains an index of all discovered
GraphNodes (Kustomizations and KustomFiles).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleancontainsNode(Path path) Checks if a node with the given path exists in the graph.getAllAppFiles(Path appPath) Retrieves all file dependencies for a given application path.getKustomFile(Path path) Retrieves aKustomFilefrom the graph, ensuring type safety.getKustomization(Path path) Retrieves aKustomizationfrom the graph, ensuring type safety.Retrieves aGraphNodefrom the graph by its path.Gets all Kustomizations in the graph that are considered "root" applications (i.e., not depended upon by any other Kustomization).getRootAppsWithFile(Path path) Gets all root Kustomizations that directly or indirectly reference the given file path.
-
Constructor Details
-
KustomGraph
public KustomGraph()
-
-
Method Details
-
addNode
Adds aGraphNode(like aKustomizationorKustomFile) to the graph. The node is indexed by its absolute, normalized path. If a node with the same path already exists, it will be replaced.- Parameters:
node- TheGraphNodeto add. Must not be null and must have a valid path.
-
getNode
Retrieves aGraphNodefrom the graph by its path.- Parameters:
path- The path of the node to retrieve.- Returns:
- The
GraphNodeif found, ornullif no node exists for the given path.
-
containsNode
Checks if a node with the given path exists in the graph.- Parameters:
path- The path to check.- Returns:
trueif a node with the path exists,falseotherwise.
-
getRootApps
Gets all Kustomizations in the graph that are considered "root" applications (i.e., not depended upon by any other Kustomization).- Returns:
- A list of root
Kustomizations.
-
getRootAppsWithFile
Gets all root Kustomizations that directly or indirectly reference the given file path.- Parameters:
path- The file path to check for references.- Returns:
- A list of root
Kustomizations that depend on the given file. - Throws:
UnreferencedFileException- if the given path is not found as a node in the graph.
-
getAllAppFiles
Retrieves all file dependencies for a given application path. The input path can be a directory containing a kustomization file or a direct path to a kustomization file.- Parameters:
appPath- The path representing the application.- Returns:
- A list of all unique
Paths that the application depends on, including itself. - Throws:
KustomException- If the appPath is not a valid Kustomize application or other processing errors occur.IllegalArgumentException- if appPath is null.
-
getKustomFile
Retrieves aKustomFilefrom the graph, ensuring type safety.- Parameters:
path- The path of the KustomFile to retrieve.- Returns:
- The
KustomFileif found and is of the correct type, ornullotherwise.
-
getKustomization
Retrieves aKustomizationfrom the graph, ensuring type safety.- Parameters:
path- The path of the Kustomization to retrieve.- Returns:
- The
Kustomizationif found and is of the correct type, ornullotherwise.
-