本文整理匯總了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
}