本文整理匯總了Golang中github.com/openshift/origin/pkg/api/graph.MutableUniqueGraph.AddEdge方法的典型用法代碼示例。如果您正苦於以下問題:Golang MutableUniqueGraph.AddEdge方法的具體用法?Golang MutableUniqueGraph.AddEdge怎麽用?Golang MutableUniqueGraph.AddEdge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/openshift/origin/pkg/api/graph.MutableUniqueGraph
的用法示例。
在下文中一共展示了MutableUniqueGraph.AddEdge方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AddTriggerEdges
// AddTriggerEdges creates edges that point to named Docker image repositories for each image used in the deployment.
func AddTriggerEdges(g osgraph.MutableUniqueGraph, node *deploygraph.DeploymentConfigNode) *deploygraph.DeploymentConfigNode {
podTemplate := node.DeploymentConfig.Spec.Template
if podTemplate == nil {
return node
}
deployapi.EachTemplateImage(
&podTemplate.Spec,
deployapi.DeploymentConfigHasTrigger(node.DeploymentConfig),
func(image deployapi.TemplateImage, err error) {
if err != nil {
return
}
if image.From != nil {
if len(image.From.Name) == 0 {
return
}
name, tag, _ := imageapi.SplitImageStreamTag(image.From.Name)
in := imagegraph.FindOrCreateSyntheticImageStreamTagNode(g, imagegraph.MakeImageStreamTagObjectMeta(image.From.Namespace, name, tag))
g.AddEdge(in, node, TriggersDeploymentEdgeKind)
return
}
tag := image.Ref.Tag
image.Ref.Tag = ""
in := imagegraph.EnsureDockerRepositoryNode(g, image.Ref.String(), tag)
g.AddEdge(in, node, UsedInDeploymentEdgeKind)
})
return node
}
示例2: AddOutputEdges
// AddOutputEdges links the build config to its output image node.
func AddOutputEdges(g osgraph.MutableUniqueGraph, node *buildgraph.BuildConfigNode) {
if node.BuildConfig.Spec.Output.To == nil {
return
}
out := imageRefNode(g, node.BuildConfig.Spec.Output.To, node.BuildConfig)
g.AddEdge(node, out, BuildOutputEdgeKind)
}
示例3: AddTriggerEdges
// AddTriggerEdges creates edges that point to named Docker image repositories for each image used in the deployment.
func AddTriggerEdges(g osgraph.MutableUniqueGraph, node *deploygraph.DeploymentConfigNode) *deploygraph.DeploymentConfigNode {
rcTemplate := node.DeploymentConfig.Template.ControllerTemplate.Template
if rcTemplate == nil {
return node
}
EachTemplateImage(
&rcTemplate.Spec,
DeploymentConfigHasTrigger(node.DeploymentConfig),
func(image TemplateImage, err error) {
if err != nil {
return
}
if image.From != nil {
if len(image.From.Name) == 0 {
return
}
in := imagegraph.EnsureImageStreamTagNode(g, image.From.Namespace, image.From.Name, image.FromTag)
g.AddEdge(in, node, TriggersDeploymentEdgeKind)
return
}
tag := image.Ref.Tag
image.Ref.Tag = ""
in := imagegraph.EnsureDockerRepositoryNode(g, image.Ref.String(), tag)
g.AddEdge(in, node, UsedInDeploymentEdgeKind)
})
return node
}
示例4: AddRouteEdges
// AddRouteEdges adds an edge that connect a service to a route in the given graph
func AddRouteEdges(g osgraph.MutableUniqueGraph, node *routegraph.RouteNode) {
syntheticService := &kapi.Service{}
syntheticService.Namespace = node.Namespace
syntheticService.Name = node.Spec.To.Name
serviceNode := kubegraph.FindOrCreateSyntheticServiceNode(g, syntheticService)
g.AddEdge(node, serviceNode, ExposedThroughRouteEdgeKind)
}
示例5: AddBuildEdges
// AddBuildEdges adds edges that connect a BuildConfig to Builds to the given graph
func AddBuildEdges(g osgraph.MutableUniqueGraph, node *buildgraph.BuildConfigNode) {
for _, n := range g.(graph.Graph).Nodes() {
if buildNode, ok := n.(*buildgraph.BuildNode); ok {
if belongsToBuildConfig(node.BuildConfig, buildNode.Build) {
g.AddEdge(node, buildNode, BuildEdgeKind)
}
}
}
}
示例6: AddInputEdges
// AddInputEdges links the build config to its input image and source nodes.
func AddInputEdges(g osgraph.MutableUniqueGraph, node *buildgraph.BuildConfigNode) {
if in := buildgraph.EnsureSourceRepositoryNode(g, node.BuildConfig.Spec.Source); in != nil {
g.AddEdge(in, node, BuildInputEdgeKind)
}
inputImage := buildutil.GetImageStreamForStrategy(node.BuildConfig.Spec.Strategy)
if input := imageRefNode(g, inputImage, node.BuildConfig); input != nil {
g.AddEdge(input, node, BuildInputImageEdgeKind)
}
}
示例7: AddImageStreamImageRefEdge
// AddImageStreamImageRefEdge ensures that a directed edge exists between an ImageStreamImage Node and the IS it references
func AddImageStreamImageRefEdge(g osgraph.MutableUniqueGraph, node *imagegraph.ImageStreamImageNode) {
dockImgRef, _ := imageapi.ParseDockerImageReference(node.Name)
imageStream := &imageapi.ImageStream{}
imageStream.Namespace = node.Namespace
imageStream.Name = dockImgRef.Name
imageStreamNode := imagegraph.FindOrCreateSyntheticImageStreamNode(g, imageStream)
g.AddEdge(node, imageStreamNode, ReferencedImageStreamImageGraphEdgeKind)
}
示例8: AddImageStreamRefEdge
// AddImageStreamRefEdge ensures that a directed edge exists between an IST Node and the IS it references
func AddImageStreamRefEdge(g osgraph.MutableUniqueGraph, node *imagegraph.ImageStreamTagNode) {
isName, _, _ := imageapi.SplitImageStreamTag(node.Name)
imageStream := &imageapi.ImageStream{}
imageStream.Namespace = node.Namespace
imageStream.Name = isName
imageStreamNode := imagegraph.FindOrCreateSyntheticImageStreamNode(g, imageStream)
g.AddEdge(node, imageStreamNode, ReferencedImageStreamGraphEdgeKind)
}
示例9: AddDeploymentEdges
func AddDeploymentEdges(g osgraph.MutableUniqueGraph, node *deploygraph.DeploymentConfigNode) *deploygraph.DeploymentConfigNode {
for _, n := range g.(graph.Graph).Nodes() {
if rcNode, ok := n.(*kubegraph.ReplicationControllerNode); ok {
if BelongsToDeploymentConfig(node.DeploymentConfig, rcNode.ReplicationController) {
g.AddEdge(node, rcNode, DeploymentEdgeKind)
}
}
}
return node
}
示例10: AddTriggerEdges
// AddTriggerEdges links the build config to its trigger input image nodes.
func AddTriggerEdges(g osgraph.MutableUniqueGraph, node *buildgraph.BuildConfigNode) {
for _, trigger := range node.BuildConfig.Spec.Triggers {
if trigger.Type != buildapi.ImageChangeBuildTriggerType {
continue
}
from := trigger.ImageChange.From
if trigger.ImageChange.From == nil {
from = buildutil.GetImageStreamForStrategy(node.BuildConfig.Spec.Strategy)
}
triggerNode := imageRefNode(g, from, node.BuildConfig)
g.AddEdge(triggerNode, node, BuildTriggerImageEdgeKind)
}
}
示例11: AddManagedByRCPodEdges
// AddManagedByRCPodEdges ensures that a directed edge exists between an RC and all the pods
// in the graph that match the label selector
func AddManagedByRCPodEdges(g osgraph.MutableUniqueGraph, rcNode *kubegraph.ReplicationControllerNode) {
if rcNode.Spec.Selector == nil {
return
}
query := labels.SelectorFromSet(rcNode.Spec.Selector)
for _, n := range g.(graph.Graph).Nodes() {
switch target := n.(type) {
case *kubegraph.PodNode:
if query.Matches(labels.Set(target.Labels)) {
g.AddEdge(target, rcNode, ManagedByRCEdgeKind)
}
}
}
}
示例12: AddExposedPodEdges
// AddExposedPodEdges ensures that a directed edge exists between a service and all the pods
// in the graph that match the service selector
func AddExposedPodEdges(g osgraph.MutableUniqueGraph, node *kubegraph.ServiceNode) {
if node.Service.Spec.Selector == nil {
return
}
query := labels.SelectorFromSet(node.Service.Spec.Selector)
for _, n := range g.(graph.Graph).Nodes() {
switch target := n.(type) {
case *kubegraph.PodNode:
if query.Matches(labels.Set(target.Labels)) {
g.AddEdge(target, node, ExposedThroughServiceEdgeKind)
}
}
}
}
示例13: EnsurePetSetSpecNode
func EnsurePetSetSpecNode(g osgraph.MutableUniqueGraph, spec *kapps.PetSetSpec, namespace string, ownerName osgraph.UniqueName) *PetSetSpecNode {
specName := PetSetSpecNodeName(spec, ownerName)
specNode := osgraph.EnsureUnique(g,
specName,
func(node osgraph.Node) graph.Node {
return &PetSetSpecNode{node, spec, namespace, ownerName}
},
).(*PetSetSpecNode)
ptSpecNode := EnsurePodTemplateSpecNode(g, &spec.Template, namespace, specName)
g.AddEdge(specNode, ptSpecNode, osgraph.ContainsEdgeKind)
return specNode
}
示例14: EnsurePetSetNode
func EnsurePetSetNode(g osgraph.MutableUniqueGraph, petset *kapps.PetSet) *PetSetNode {
nodeName := PetSetNodeName(petset)
node := osgraph.EnsureUnique(g,
nodeName,
func(node osgraph.Node) graph.Node {
return &PetSetNode{node, petset}
},
).(*PetSetNode)
specNode := EnsurePetSetSpecNode(g, &petset.Spec, petset.Namespace, nodeName)
g.AddEdge(node, specNode, osgraph.ContainsEdgeKind)
return node
}
示例15: EnsureReplicationControllerNode
// EnsureReplicationControllerNode adds a graph node for the ReplicationController if it does not already exist.
func EnsureReplicationControllerNode(g osgraph.MutableUniqueGraph, rc *kapi.ReplicationController) *ReplicationControllerNode {
rcNodeName := ReplicationControllerNodeName(rc)
rcNode := osgraph.EnsureUnique(g,
rcNodeName,
func(node osgraph.Node) graph.Node {
return &ReplicationControllerNode{node, rc}
},
).(*ReplicationControllerNode)
rcSpecNode := EnsureReplicationControllerSpecNode(g, &rc.Spec, rcNodeName)
g.AddEdge(rcNode, rcSpecNode, osgraph.ContainsEdgeKind)
return rcNode
}