// EnsureDockerRepositoryNode adds the named Docker repository tag reference to the graph if it does // not already exist. If the reference is invalid, the Name field of the graph will be used directly. func EnsureDockerRepositoryNode(g osgraph.MutableUniqueGraph, name, tag string) graph.Node { ref, err := imageapi.ParseDockerImageReference(name) if err == nil { if len(tag) != 0 { ref.Tag = tag } if len(ref.Tag) == 0 { ref.Tag = imageapi.DefaultImageTag } if len(ref.Registry) == 0 { ref.Registry = "docker.io" } if len(ref.Namespace) == 0 { ref.Namespace = imageapi.DockerDefaultNamespace } } else { ref = imageapi.DockerImageReference{Name: name} } return osgraph.EnsureUnique(g, DockerImageRepositoryNodeName(ref), func(node osgraph.Node) graph.Node { return &DockerImageRepositoryNode{node, ref} }, ) }
func FindOrCreateSyntheticReplicationControllerNode(g osgraph.MutableUniqueGraph, rc *kapi.ReplicationController) *ReplicationControllerNode { return osgraph.EnsureUnique(g, ReplicationControllerNodeName(rc), func(node osgraph.Node) graph.Node { return &ReplicationControllerNode{node, rc, false} }, ).(*ReplicationControllerNode) }
// EnsureImageStreamNode adds a graph node for the Image Stream if it does not already exist. func EnsureImageStreamNode(g osgraph.MutableUniqueGraph, stream *imageapi.ImageStream) graph.Node { return osgraph.EnsureUnique(g, ImageStreamNodeName(stream), func(node osgraph.Node) graph.Node { return &ImageStreamNode{node, stream} }, ) }
func FindOrCreateSyntheticPVCNode(g osgraph.MutableUniqueGraph, pvc *kapi.PersistentVolumeClaim) *PersistentVolumeClaimNode { return osgraph.EnsureUnique(g, PersistentVolumeClaimNodeName(pvc), func(node osgraph.Node) graph.Node { return &PersistentVolumeClaimNode{Node: node, PersistentVolumeClaim: pvc, IsFound: false} }, ).(*PersistentVolumeClaimNode) }
func EnsurePersistentVolumeClaimNode(g osgraph.MutableUniqueGraph, pvc *kapi.PersistentVolumeClaim) *PersistentVolumeClaimNode { return osgraph.EnsureUnique(g, PersistentVolumeClaimNodeName(pvc), func(node osgraph.Node) graph.Node { return &PersistentVolumeClaimNode{Node: node, PersistentVolumeClaim: pvc, IsFound: true} }, ).(*PersistentVolumeClaimNode) }
func EnsureHorizontalPodAutoscalerNode(g osgraph.MutableUniqueGraph, hpa *autoscaling.HorizontalPodAutoscaler) *HorizontalPodAutoscalerNode { return osgraph.EnsureUnique(g, HorizontalPodAutoscalerNodeName(hpa), func(node osgraph.Node) graph.Node { return &HorizontalPodAutoscalerNode{Node: node, HorizontalPodAutoscaler: hpa} }, ).(*HorizontalPodAutoscalerNode) }
func EnsureSecretNode(g osgraph.MutableUniqueGraph, o *kapi.Secret) *SecretNode { return osgraph.EnsureUnique(g, SecretNodeName(o), func(node osgraph.Node) graph.Node { return &SecretNode{node, o, true} }, ).(*SecretNode) }
// EnsureImageStreamTagNode adds a graph node for the specific tag in an Image Stream if it does not already exist. func EnsureImageStreamTagNode(g osgraph.MutableUniqueGraph, ist *imageapi.ImageStreamTag) *ImageStreamTagNode { return osgraph.EnsureUnique(g, ImageStreamTagNodeName(ist), func(node osgraph.Node) graph.Node { return &ImageStreamTagNode{node, ist, true} }, ).(*ImageStreamTagNode) }
// EnsureBuildNode adds a graph node for the build if it does not already exist. func EnsureBuildNode(g osgraph.MutableUniqueGraph, build *buildapi.Build) *BuildNode { return osgraph.EnsureUnique(g, BuildNodeName(build), func(node osgraph.Node) graph.Node { return &BuildNode{node, build} }, ).(*BuildNode) }
// EnsureImageStreamNode adds a graph node for the Image Stream if it does not already exist. func EnsureImageStreamNode(g osgraph.MutableUniqueGraph, is *imageapi.ImageStream) graph.Node { return osgraph.EnsureUnique(g, ImageStreamNodeName(is), func(node osgraph.Node) graph.Node { return &ImageStreamNode{node, is, true} }, ) }
func EnsureImageNode(g osgraph.MutableUniqueGraph, img *imageapi.Image) graph.Node { return osgraph.EnsureUnique(g, ImageNodeName(img), func(node osgraph.Node) graph.Node { return &ImageNode{node, img} }, ) }
func EnsurePodSpecNode(g osgraph.MutableUniqueGraph, podSpec *kapi.PodSpec, ownerName osgraph.UniqueName) *PodSpecNode { return osgraph.EnsureUnique(g, PodSpecNodeName(podSpec, ownerName), func(node osgraph.Node) graph.Node { return &PodSpecNode{node, podSpec, ownerName} }, ).(*PodSpecNode) }
func FindOrCreateSyntheticSecretNode(g osgraph.MutableUniqueGraph, o *kapi.Secret) *SecretNode { return osgraph.EnsureUnique(g, SecretNodeName(o), func(node osgraph.Node) graph.Node { return &SecretNode{node, o, false} }, ).(*SecretNode) }
// EnsureServiceNode adds the provided service to the graph if it does not already exist. func EnsureServiceNode(g osgraph.MutableUniqueGraph, svc *kapi.Service) *ServiceNode { return osgraph.EnsureUnique(g, ServiceNodeName(svc), func(node osgraph.Node) graph.Node { return &ServiceNode{node, svc} }, ).(*ServiceNode) }
// FindOrCreateSyntheticImageStreamNode returns the existing ISNode or creates a synthetic node in its place func FindOrCreateSyntheticImageStreamNode(g osgraph.MutableUniqueGraph, is *imageapi.ImageStream) *ImageStreamNode { return osgraph.EnsureUnique(g, ImageStreamNodeName(is), func(node osgraph.Node) graph.Node { return &ImageStreamNode{node, is, false} }, ).(*ImageStreamNode) }
// EnsureImageLayerNode adds a graph node for the layer if it does not already exist. func EnsureImageLayerNode(g osgraph.MutableUniqueGraph, layer string) graph.Node { return osgraph.EnsureUnique(g, ImageLayerNodeName(layer), func(node osgraph.Node) graph.Node { return &ImageLayerNode{node, layer} }, ) }
// FindOrCreateSyntheticServiceNode returns the existing service node or creates a synthetic node in its place func FindOrCreateSyntheticServiceNode(g osgraph.MutableUniqueGraph, svc *kapi.Service) *ServiceNode { return osgraph.EnsureUnique(g, ServiceNodeName(svc), func(node osgraph.Node) graph.Node { return &ServiceNode{node, svc, false} }, ).(*ServiceNode) }
func FindOrCreateSyntheticDeploymentConfigNode(g osgraph.MutableUniqueGraph, dc *depoyapi.DeploymentConfig) *DeploymentConfigNode { return osgraph.EnsureUnique( g, DeploymentConfigNodeName(dc), func(node osgraph.Node) graph.Node { return &DeploymentConfigNode{Node: node, DeploymentConfig: dc, IsFound: false} }, ).(*DeploymentConfigNode) }
func EnsureSecretNode(g osgraph.MutableUniqueGraph, o *kapi.Secret) *SecretNode { return osgraph.EnsureUnique(g, SecretNodeName(o), func(node osgraph.Node) graph.Node { return &SecretNode{ Node: node, Secret: o, IsFound: true, } }, ).(*SecretNode) }
// EnsureBuildConfigNode adds a graph node for the specific build config if it does not exist func EnsureBuildConfigNode(g osgraph.MutableUniqueGraph, config *buildapi.BuildConfig) *BuildConfigNode { return osgraph.EnsureUnique( g, BuildConfigNodeName(config), func(node osgraph.Node) graph.Node { return &BuildConfigNode{ Node: node, BuildConfig: config, } }, ).(*BuildConfigNode) }
// EnsureRouteNode adds a graph node for the specific route if it does not exist func EnsureRouteNode(g osgraph.MutableUniqueGraph, route *routeapi.Route) *RouteNode { return osgraph.EnsureUnique( g, RouteNodeName(route), func(node osgraph.Node) graph.Node { return &RouteNode{ Node: node, Route: route, } }, ).(*RouteNode) }
// EnsureSourceRepositoryNode adds the specific BuildSource to the graph if it does not already exist. func EnsureSourceRepositoryNode(g osgraph.MutableUniqueGraph, source buildapi.BuildSource) *SourceRepositoryNode { switch { case source.Git != nil: default: return nil } return osgraph.EnsureUnique(g, SourceRepositoryNodeName(source), func(node osgraph.Node) graph.Node { return &SourceRepositoryNode{node, source} }, ).(*SourceRepositoryNode) }
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 }
func EnsurePodNode(g osgraph.MutableUniqueGraph, pod *kapi.Pod) *PodNode { podNodeName := PodNodeName(pod) podNode := osgraph.EnsureUnique(g, podNodeName, func(node osgraph.Node) graph.Node { return &PodNode{node, pod} }, ).(*PodNode) podSpecNode := EnsurePodSpecNode(g, &pod.Spec, podNodeName) g.AddEdge(podNode, podSpecNode, osgraph.ContainsEdgeKind) return podNode }
func EnsurePodTemplateSpecNode(g osgraph.MutableUniqueGraph, ptSpec *kapi.PodTemplateSpec, ownerName osgraph.UniqueName) *PodTemplateSpecNode { ptSpecName := PodTemplateSpecNodeName(ptSpec, ownerName) ptSpecNode := osgraph.EnsureUnique(g, ptSpecName, func(node osgraph.Node) graph.Node { return &PodTemplateSpecNode{node, ptSpec, ownerName} }, ).(*PodTemplateSpecNode) podSpecNode := EnsurePodSpecNode(g, &ptSpec.Spec, ptSpecName) g.AddEdge(ptSpecNode, podSpecNode, osgraph.ContainsEdgeKind) return ptSpecNode }
// 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 }
// EnsureImageStreamImageNode adds a graph node for the specific ImageStreamImage if it // does not already exist. func EnsureImageStreamImageNode(g osgraph.MutableUniqueGraph, namespace, name string) graph.Node { isi := &imageapi.ImageStreamImage{ ObjectMeta: kapi.ObjectMeta{ Namespace: namespace, Name: name, }, } return osgraph.EnsureUnique(g, ImageStreamImageNodeName(isi), func(node osgraph.Node) graph.Node { return &ImageStreamImageNode{node, isi, true} }, ) }
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 }
// 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 }
func EnsureReplicationControllerSpecNode(g osgraph.MutableUniqueGraph, rcSpec *kapi.ReplicationControllerSpec, ownerName osgraph.UniqueName) *ReplicationControllerSpecNode { rcSpecName := ReplicationControllerSpecNodeName(rcSpec, ownerName) rcSpecNode := osgraph.EnsureUnique(g, rcSpecName, func(node osgraph.Node) graph.Node { return &ReplicationControllerSpecNode{node, rcSpec, ownerName} }, ).(*ReplicationControllerSpecNode) if rcSpec.Template != nil { ptSpecNode := EnsurePodTemplateSpecNode(g, rcSpec.Template, rcSpecName) g.AddEdge(rcSpecNode, ptSpecNode, osgraph.ContainsEdgeKind) } return rcSpecNode }