-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathnodes.go
More file actions
26 lines (21 loc) · 850 Bytes
/
nodes.go
File metadata and controls
26 lines (21 loc) · 850 Bytes
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
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)
rcSpecNode := kubegraph.EnsureReplicationControllerSpecNode(g, &dc.Template.ControllerTemplate, dcName)
g.AddEdge(dcNode, rcSpecNode, osgraph.ContainsEdgeKind)
return dcNode
}