本文整理汇总了Golang中github.com/openshift/origin/pkg/api/graph.Graph.PredecessorEdges方法的典型用法代码示例。如果您正苦于以下问题:Golang Graph.PredecessorEdges方法的具体用法?Golang Graph.PredecessorEdges怎么用?Golang Graph.PredecessorEdges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/openshift/origin/pkg/api/graph.Graph
的用法示例。
在下文中一共展示了Graph.PredecessorEdges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ServiceAndDeploymentGroups
// ServiceAndDeploymentGroups breaks the provided graph of API relationships into ServiceGroup objects,
// ordered consistently. Groups are organized so that overlapping Services and DeploymentConfigs are
// part of the same group, Deployment Configs are each in their own group, and then BuildConfigs are
// part of the last service group.
func ServiceAndDeploymentGroups(g osgraph.Graph) []ServiceGroup {
deploys, covered := DeploymentPipelines(g)
other := g.Subgraph(UncoveredDeploymentFlowNodes(covered), UncoveredDeploymentFlowEdges(covered))
components := search.Tarjan(other)
serviceGroups := []ServiceGroup{}
for _, c := range components {
group := ServiceGroup{}
matches := osgraph.NodesByKind(other, c, kubegraph.ServiceNodeKind, deploygraph.DeploymentConfigNodeKind)
svcs, dcs, _ := matches[0], matches[1], matches[2]
for _, n := range svcs {
coveredDCs := []*deploygraph.DeploymentConfigNode{}
coveredRCs := []*kubegraph.ReplicationControllerNode{}
coveredPods := []*kubegraph.PodNode{}
for _, neighbor := range other.Neighbors(n) {
switch other.EdgeKind(g.EdgeBetween(neighbor, n)) {
case kubeedges.ExposedThroughServiceEdgeKind:
containerNode := osgraph.GetTopLevelContainerNode(g, neighbor)
switch castCoveredNode := containerNode.(type) {
case *deploygraph.DeploymentConfigNode:
coveredDCs = append(coveredDCs, castCoveredNode)
case *kubegraph.ReplicationControllerNode:
coveredRCs = append(coveredRCs, castCoveredNode)
case *kubegraph.PodNode:
coveredPods = append(coveredPods, castCoveredNode)
}
}
}
group.Services = append(group.Services, ServiceReference{
Service: n.(*kubegraph.ServiceNode),
CoveredDCs: coveredDCs,
CoveredRCs: coveredRCs,
CoveredPods: coveredPods,
})
}
sort.Sort(SortedServiceReferences(group.Services))
for _, n := range dcs {
d := n.(*deploygraph.DeploymentConfigNode)
group.Deployments = append(group.Deployments, DeploymentFlow{
Deployment: d,
Images: deploys[d],
})
}
sort.Sort(SortedDeploymentPipelines(group.Deployments))
if len(dcs) == 0 || len(svcs) == 0 {
unknown := g.SubgraphWithNodes(c, osgraph.ExistingDirectEdge)
for _, n := range unknown.NodeList() {
g.PredecessorEdges(n, osgraph.AddGraphEdgesTo(unknown), buildedges.BuildOutputEdgeKind)
}
unknown = unknown.EdgeSubgraph(osgraph.ReverseGraphEdge)
for _, n := range unknown.RootNodes() {
if flow, ok := ImagePipelineFromNode(unknown, n, make(osgraph.NodeSet)); ok {
group.Builds = append(group.Builds, flow)
}
}
}
sort.Sort(SortedImagePipelines(group.Builds))
serviceGroups = append(serviceGroups, group)
}
sort.Sort(SortedServiceGroups(serviceGroups))
return serviceGroups
}