예제 #1
0
파일: term.go 프로젝트: cfstras/pcm
func filterTreeDescend(pathPrefix string, node *types.Container, distances map[string]int) {
	newContainers := []types.Container{}
	for _, c := range node.Containers { // this implicitly copies the struct
		nextPathPrefix := pathPrefix + c.Name + "/"
		if pathPrefixInDistances(nextPathPrefix, distances) {
			newContainers = append(newContainers, c)
			nc := &newContainers[len(newContainers)-1]
			nc.Expanded = true
			filterTreeDescend(nextPathPrefix, nc, distances)
		}
	}
	newConnections := []types.Connection{}
	for _, c := range node.Connections {
		if pathPrefixInDistances(pathPrefix+c.Name, distances) {
			newConnections = append(newConnections, c)
		}
	}

	node.Containers = newContainers
	node.Connections = newConnections
}
예제 #2
0
파일: tree.go 프로젝트: cfstras/pcm
// Recursively descend through connections tree, writing paths->connection mappings
// into the conns map. Start with prefix ""
func descendConnections(prefix string, node *types.Container,
	conns map[string]*types.Connection, includeDescription bool) {
	node.Path_ = prefix
	for i := range node.Connections {
		c := &node.Connections[i]
		key := prefix + "/" + c.Name
		if includeDescription {
			key += "  " + c.Info.Description
		}
		conns[key] = c
		c.Path_ = key
	}
	for i := range node.Containers {
		n := &node.Containers[i]
		descendConnections(prefix+"/"+n.Name, n, conns,
			includeDescription)
	}
}