Documentation
¶
Index ¶
- Constants
- func FindPkgInfo(workDir string) (pkgroot, pkgpath string, err error)
- func ListDepFiles(workDir string, opt *Option) (files []string, err error)
- func ListDownStreamFiles(workDir string, opt *DepOption) ([]string, error)
- func ListUpStreamFiles(workDir string, opt *DepOption) (deps []string, err error)
- type DepOption
- type DepParser
- func (p *DepParser) GetAppFiles(pkgpath string, includeDependFiles bool) []string
- func (p *DepParser) GetAppPkgs(pkgpath string, includeDependFiles bool) []string
- func (p *DepParser) GetDepPkgList(pkgpath string) []string
- func (p *DepParser) GetImportMap() map[string][]string
- func (p *DepParser) GetImportMapString() string
- func (p *DepParser) GetKList() []string
- func (p *DepParser) GetMainKList() []string
- func (p *DepParser) GetPkgFileList(pkgpath string) []string
- func (p *DepParser) GetPkgList() []string
- func (p *DepParser) GetTouchedApps(touchedFiles ...string) (touchedApps, untouchedApps []string)
- func (p *DepParser) IsApp(pkgpath string) bool
- type DepsEdge
- type DirectedAcyclicGraph
- type Edge
- type EdgeUnknownError
- type FileVertex
- type Graph
- func (g *Graph) AddEdge(edge Edge)
- func (g *Graph) AddVertex(vertex Vertex) Vertex
- func (g *Graph) ContainsEdge(source, target string) bool
- func (g *Graph) ContainsVertex(id string) bool
- func (g *Graph) DeleteEdge(edge Edge) error
- func (g *Graph) DeleteVertex(id string) error
- func (g *Graph) Draw() string
- func (g *Graph) Edges() []Edge
- func (g *Graph) Size() int
- func (g *Graph) Vertices() []Vertex
- type Grapher
- type Identifier
- type ImportDepParser
- type Option
- type SingleAppDepParser
- type Vertex
- type VertexUnknownError
Constants ¶
const ( Default_KclYaml = "kcl.yaml" Default_ProjectYaml = "project.yaml" )
const KCL_MOD_PATH_ENV = "${KCL_MOD}"
Variables ¶
This section is empty.
Functions ¶
func FindPkgInfo ¶
FindPkgInfo find the pkg information(1. the pkg root 2. the pkg path of current workdir)
func ListDepFiles ¶
ListDepFiles return the depend files from the given path. It will scan and parse the kusion applications within the workdir, then list depend files of the applications.
func ListDownStreamFiles ¶
ListDownStreamFiles return a list of downstream depend files from the given changed path list.
Types ¶
type DepOption ¶
type DepOption struct { // Files is a list of relative file paths. The deps parser will parse the import information starting from these files Files []string // ChangedPaths is a list of relative file paths whose content are changed. // The deps parser can filter the Files by the ChangedPaths to distinguish the downstream Files of the ChangedPaths ChangedPaths []string }
DepOption defines the option to parse dependency info
type DepParser ¶
type DepParser struct {
// contains filtered or unexported fields
}
func NewDepParser ¶
func (*DepParser) GetAppFiles ¶
func (*DepParser) GetAppPkgs ¶
func (*DepParser) GetDepPkgList ¶
func (*DepParser) GetImportMap ¶
func (*DepParser) GetImportMapString ¶
func (*DepParser) GetMainKList ¶
func (*DepParser) GetPkgFileList ¶
func (*DepParser) GetPkgList ¶
func (*DepParser) GetTouchedApps ¶
type DepsEdge ¶
type DepsEdge struct {
// contains filtered or unexported fields
}
DepsEdge defines the dependency relation in the dependency graph. The target FileVertex depends on the source FileVertex, Put it another way, the content of the target FileVertex defines an import statement to the source FileVertex
type DirectedAcyclicGraph ¶
type DirectedAcyclicGraph struct {
Graph
}
DirectedAcyclicGraph defines a directed graph with no directed cycles
func NewDirectedAcyclicGraph ¶
func NewDirectedAcyclicGraph() *DirectedAcyclicGraph
NewDirectedAcyclicGraph creates an empty DAG without any vertices and edges
type Edge ¶
type Edge interface { Identifier Source() Vertex Target() Vertex }
Edge defines the directed connection between two nodes in a graph with a unique id for index
type EdgeUnknownError ¶
type EdgeUnknownError struct {
// contains filtered or unexported fields
}
EdgeUnknownError is the error type when the given edge does not exist in the graph
func (EdgeUnknownError) Error ¶
func (e EdgeUnknownError) Error() string
type FileVertex ¶
type FileVertex struct {
// contains filtered or unexported fields
}
FileVertex defines the file path in the dependency graph
func (*FileVertex) Id ¶
func (v *FileVertex) Id() string
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is a structure that defines a directed graph that contains vertices and directed edges
func NewGraph ¶
func NewGraph() *Graph
NewGraph creates an empty graph without any vertices and edges
func (*Graph) AddEdge ¶
AddEdge adds an edge with the given source and target and records it in the inbound edges and the outbound edges
func (*Graph) ContainsEdge ¶
ContainsEdge checks if the edge is contained in the graph The graph contains the edge if there's already an edge which has the same source and target vertex with the given edge
func (*Graph) ContainsVertex ¶
ContainsVertex check if a vertex is contained in the graph by id
func (*Graph) DeleteEdge ¶
DeleteEdge will delete the edge which connects a source vertex to the target. The related inbound and outbound edges will be deleted in the meanwhile
func (*Graph) DeleteVertex ¶
DeleteVertex remove a node from the graph by vertex id. The edges that are related to the node will be removed in the meanwhile
type Grapher ¶
type Grapher interface { // AddVertex inserts a node to the graph AddVertex(vertex Vertex) Vertex // DeleteVertex remove a node from the graph by vertex id. The edges that are related to the node will be removed in the meanwhile DeleteVertex(id string) error // AddEdge connects two nodes (the source and the target node) in the graph AddEdge(edge Edge) // DeleteEdge will delete the edge which connects a source vertex to the target. The related inbound and outbound edges will be deleted in the meanwhile DeleteEdge(edge Edge) error // ContainsVertex check if a vertex exists in the graph by id ContainsVertex(id string) bool // ContainsEdge checks if there is a directed connection between two nodes in the graph ContainsEdge(sourceId string, targetId string) bool // Vertices returns the list of all the vertices in the graph. Vertices() []Vertex // Edges returns the list of all the edges in the graph. Edges() []Edge // Size returns the number of the vertices in the graph Size() int // Draw generates a visual representation of the graph Draw() string }
Grapher defines the commonly used interfaces of a graph structure
type Identifier ¶
type Identifier interface {
Id() string
}
type ImportDepParser ¶
type ImportDepParser struct {
// contains filtered or unexported fields
}
ImportDepParser parses the import statements in KCL files within the given work directory
func NewImportDepParser ¶
func NewImportDepParser(root string, opt DepOption) (*ImportDepParser, error)
NewImportDepParser initialize an import dependency parser from the given pkg root and the deps option
func NewImportDepParserWithFS ¶
func NewImportDepParserWithFS(vfs fs.FS, opt DepOption) *ImportDepParser
func (*ImportDepParser) GetRelatives ¶
func (p *ImportDepParser) GetRelatives(focusPaths []string, downStream bool) []string
GetRelatives returns a list of file paths that has import relation(directly or indirectly) with the focus paths. If the downStream is set to true, that means only the file paths that depend on the focus paths will be returned. Otherwise, only the file paths that the focus paths depend on will be returned.
func (*ImportDepParser) Inspect ¶
func (p *ImportDepParser) Inspect(path string)
Inspect will inspect current path: read the file content and parse import stmts, record the deps relation between the imported and importing. if path is a file, each file in the pkg dir containing the file will be parsed if path is a pkg path, each file in the pkg path will be parsed
func (*ImportDepParser) ListDownStreamFiles ¶
func (p *ImportDepParser) ListDownStreamFiles() []string
ListDownStreamFiles return a list of downstream depend files from the given changed path list.
func (*ImportDepParser) ListUpstreamFiles ¶
func (p *ImportDepParser) ListUpstreamFiles() []string
ListUpStreamFiles return a list of upstream depend files from the given path list.
type SingleAppDepParser ¶
type SingleAppDepParser struct {
// contains filtered or unexported fields
}
func NewSingleAppDepParser ¶
func NewSingleAppDepParser(root string, opt ...Option) *SingleAppDepParser
func NewSingleAppDepParserWithFS ¶
func NewSingleAppDepParserWithFS(vfs fs.FS, opts ...Option) *SingleAppDepParser
func (*SingleAppDepParser) GetAppFiles ¶
func (p *SingleAppDepParser) GetAppFiles(appPkgpath string, includeDependFiles bool) []string
func (*SingleAppDepParser) GetAppPkgs ¶
func (p *SingleAppDepParser) GetAppPkgs(appPkgpath string, includeDependFiles bool) []string
type Vertex ¶
type Vertex interface { Identifier }
Vertex defines the node with in a graph with a unique id for index
type VertexUnknownError ¶
type VertexUnknownError struct {
// contains filtered or unexported fields
}
VertexUnknownError is the error type when the given vertex does not exist in the graph
func (VertexUnknownError) Error ¶
func (e VertexUnknownError) Error() string