github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/pkg/steampipeconfig/dependency_path.go (about) 1 package steampipeconfig 2 3 import "strings" 4 5 const pathSeparator = " -> " 6 7 // DependencyPathKey is a string representation of a dependency path 8 // - a set of mod dependencyPath values separated by '->' 9 // 10 // e.g. local -> github.com/kaidaguerre/steampipe-mod-m1@v3.1.1 -> github.com/kaidaguerre/steampipe-mod-m2@v5.1.1 11 type DependencyPathKey string 12 13 func newDependencyPathKey(dependencyPath ...string) DependencyPathKey { 14 return DependencyPathKey(strings.Join(dependencyPath, pathSeparator)) 15 } 16 17 func (k DependencyPathKey) GetParent() DependencyPathKey { 18 elements := strings.Split(string(k), pathSeparator) 19 if len(elements) == 1 { 20 return "" 21 } 22 return newDependencyPathKey(elements[:len(elements)-2]...) 23 } 24 25 // how long is the depdency path 26 func (k DependencyPathKey) PathLength() int { 27 return len(strings.Split(string(k), pathSeparator)) 28 }