forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodes.go
28 lines (23 loc) · 892 Bytes
/
nodes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package nodes
import (
"github.com/gonum/graph"
osgraph "github.com/openshift/origin/pkg/api/graph"
kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes"
depoyapi "github.com/openshift/origin/pkg/deploy/api"
)
// EnsureDeploymentConfigNode adds the provided deployment config to the graph if it does not exist
func EnsureDeploymentConfigNode(g osgraph.MutableUniqueGraph, dc *depoyapi.DeploymentConfig) *DeploymentConfigNode {
dcName := DeploymentConfigNodeName(dc)
dcNode := osgraph.EnsureUnique(
g,
dcName,
func(node osgraph.Node) graph.Node {
return &DeploymentConfigNode{Node: node, DeploymentConfig: dc}
},
).(*DeploymentConfigNode)
if dc.Spec.Template != nil {
podTemplateSpecNode := kubegraph.EnsurePodTemplateSpecNode(g, dc.Spec.Template, dc.Namespace, dcName)
g.AddEdge(dcNode, podTemplateSpecNode, osgraph.ContainsEdgeKind)
}
return dcNode
}