list

package
v0.4.2-alpha3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Default_KclYaml     = "kcl.yaml"
	Default_ProjectYaml = "project.yaml"
)
View Source
const KCL_MOD_PATH_ENV = "${KCL_MOD}"

Variables

This section is empty.

Functions

func FindPkgInfo

func FindPkgInfo(workDir string) (pkgroot, pkgpath string, err error)

FindPkgInfo find the pkg information(1. the pkg root 2. the pkg path of current workdir)

func ListDepFiles

func ListDepFiles(workDir string, opt *Option) (files []string, err error)

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

func ListDownStreamFiles(workDir string, opt *DepOption) ([]string, error)

ListDownStreamFiles return a list of downstream depend files from the given changed path list.

func ListUpStreamFiles

func ListUpStreamFiles(workDir string, opt *DepOption) (deps []string, err error)

ListUpStreamFiles return a list of upstream depend files from the given 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 NewDepParser(root string, opt ...Option) *DepParser

func NewDepParserWithFS

func NewDepParserWithFS(vfs fs.FS, opts ...Option) *DepParser

func (*DepParser) GetAppFiles

func (p *DepParser) GetAppFiles(pkgpath string, includeDependFiles bool) []string

func (*DepParser) GetAppPkgs

func (p *DepParser) GetAppPkgs(pkgpath string, includeDependFiles bool) []string

func (*DepParser) GetDepPkgList

func (p *DepParser) GetDepPkgList(pkgpath string) []string

func (*DepParser) GetImportMap

func (p *DepParser) GetImportMap() map[string][]string

func (*DepParser) GetImportMapString

func (p *DepParser) GetImportMapString() string

func (*DepParser) GetKList

func (p *DepParser) GetKList() []string

func (*DepParser) GetMainKList

func (p *DepParser) GetMainKList() []string

func (*DepParser) GetPkgFileList

func (p *DepParser) GetPkgFileList(pkgpath string) []string

func (*DepParser) GetPkgList

func (p *DepParser) GetPkgList() []string

func (*DepParser) GetTouchedApps

func (p *DepParser) GetTouchedApps(touchedFiles ...string) (touchedApps, untouchedApps []string)

func (*DepParser) IsApp

func (p *DepParser) IsApp(pkgpath string) bool

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

func (*DepsEdge) Id

func (e *DepsEdge) Id() string

func (*DepsEdge) Source

func (e *DepsEdge) Source() Vertex

func (*DepsEdge) Target

func (e *DepsEdge) Target() Vertex

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

func (g *Graph) AddEdge(edge Edge)

AddEdge adds an edge with the given source and target and records it in the inbound edges and the outbound edges

func (*Graph) AddVertex

func (g *Graph) AddVertex(vertex Vertex) Vertex

AddVertex inserts a node to the graph

func (*Graph) ContainsEdge

func (g *Graph) ContainsEdge(source, target string) bool

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

func (g *Graph) ContainsVertex(id string) bool

ContainsVertex check if a vertex is contained in the graph by id

func (*Graph) DeleteEdge

func (g *Graph) DeleteEdge(edge Edge) error

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

func (g *Graph) DeleteVertex(id string) error

DeleteVertex remove a node from the graph by vertex id. The edges that are related to the node will be removed in the meanwhile

func (*Graph) Draw

func (g *Graph) Draw() string

Draw generates a visual representation of the graph

func (*Graph) Edges

func (g *Graph) Edges() []Edge

Edges returns the list of all the edges in the graph

func (*Graph) Size

func (g *Graph) Size() int

Size returns the number of the vertices in the graph

func (*Graph) Vertices

func (g *Graph) Vertices() []Vertex

Vertices returns the list of all the vertices in the graph

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 Option

type Option struct {
	KclYaml     string // default: Default_KclYaml
	ProjectYaml string // default: Default_ProjectYaml
	FlagAll     bool
	UseAbsPath  bool
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL