-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: add support for deployments in oc status
- Loading branch information
Showing
12 changed files
with
302 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package graphview | ||
|
||
import ( | ||
osgraph "github.com/openshift/origin/pkg/oc/graph/genericgraph" | ||
kubeedges "github.com/openshift/origin/pkg/oc/graph/kubegraph" | ||
kubegraph "github.com/openshift/origin/pkg/oc/graph/kubegraph/nodes" | ||
) | ||
|
||
type Deployment struct { | ||
Deployment *kubegraph.DeploymentNode | ||
|
||
OwnedPods []*kubegraph.PodNode | ||
CreatedPods []*kubegraph.PodNode | ||
|
||
Images []ImagePipeline | ||
|
||
// TODO: handle conflicting once controller refs are present, not worth it yet | ||
} | ||
|
||
// AllDeployments returns all the Deployments that aren't in the excludes set and the set of covered NodeIDs | ||
func AllDeployments(g osgraph.Graph, excludeNodeIDs IntSet) ([]Deployment, IntSet) { | ||
covered := IntSet{} | ||
views := []Deployment{} | ||
|
||
for _, uncastNode := range g.NodesByKind(kubegraph.DeploymentNodeKind) { | ||
if excludeNodeIDs.Has(uncastNode.ID()) { | ||
continue | ||
} | ||
|
||
view, covers := NewDeployment(g, uncastNode.(*kubegraph.DeploymentNode)) | ||
covered.Insert(covers.List()...) | ||
views = append(views, view) | ||
} | ||
|
||
return views, covered | ||
} | ||
|
||
// NewDeployment returns the Deployment and a set of all the NodeIDs covered by the Deployment | ||
func NewDeployment(g osgraph.Graph, node *kubegraph.DeploymentNode) (Deployment, IntSet) { | ||
covered := IntSet{} | ||
covered.Insert(node.ID()) | ||
|
||
view := Deployment{} | ||
view.Deployment = node | ||
|
||
for _, uncastPodNode := range g.PredecessorNodesByEdgeKind(node, kubeedges.ManagedByControllerEdgeKind) { | ||
podNode := uncastPodNode.(*kubegraph.PodNode) | ||
covered.Insert(podNode.ID()) | ||
view.OwnedPods = append(view.OwnedPods, podNode) | ||
} | ||
|
||
for _, istNode := range g.PredecessorNodesByEdgeKind(node, kubeedges.TriggersDeploymentEdgeKind) { | ||
imagePipeline, covers := NewImagePipelineFromImageTagLocation(g, istNode, istNode.(ImageTagLocation)) | ||
covered.Insert(covers.List()...) | ||
view.Images = append(view.Images, imagePipeline) | ||
} | ||
|
||
return view, covered | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.