Skip to content

Commit 65b5f13

Browse files
Merge pull request openshift#7066 from andfasano/agent-graph-cmd
AGENT-275: Add new agent graph command to output agent internal dependency graph
2 parents 23b787c + 4dd8377 commit 65b5f13

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

cmd/openshift-install/agent.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func newAgentCmd() *cobra.Command {
2424

2525
agentCmd.AddCommand(newAgentCreateCmd())
2626
agentCmd.AddCommand(agent.NewWaitForCmd())
27+
agentCmd.AddCommand(newAgentGraphCmd())
2728
return agentCmd
2829
}
2930

@@ -105,3 +106,17 @@ func newAgentCreateCmd() *cobra.Command {
105106

106107
return cmd
107108
}
109+
110+
func newAgentGraphCmd() *cobra.Command {
111+
cmd := &cobra.Command{
112+
Use: "graph",
113+
Short: "Outputs the internal dependency graph for the agent-based installer",
114+
Long: "",
115+
Args: cobra.ExactArgs(0),
116+
RunE: func(cmd *cobra.Command, args []string) error {
117+
return runGraphCmd(cmd, args, agentTargets)
118+
},
119+
}
120+
cmd.PersistentFlags().StringVar(&graphOpts.outputFile, "output-file", "", "file where the graph is written, if empty prints the graph to Stdout.")
121+
return cmd
122+
}

cmd/openshift-install/graph.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ func newGraphCmd() *cobra.Command {
2626
Short: "Outputs the internal dependency graph for installer",
2727
Long: "",
2828
Args: cobra.ExactArgs(0),
29-
RunE: runGraphCmd,
29+
RunE: func(cmd *cobra.Command, args []string) error {
30+
return runGraphCmd(cmd, args, targets)
31+
},
3032
}
3133
cmd.PersistentFlags().StringVar(&graphOpts.outputFile, "output-file", "", "file where the graph is written, if empty prints the graph to Stdout.")
3234
return cmd
3335
}
3436

35-
func runGraphCmd(cmd *cobra.Command, args []string) error {
37+
func runGraphCmd(cmd *cobra.Command, args []string, cmdTargets []target) error {
3638
g := gographviz.NewGraph()
3739
g.SetName("G")
3840
g.SetDir(true)
@@ -42,7 +44,7 @@ func runGraphCmd(cmd *cobra.Command, args []string) error {
4244
string(gographviz.Shape): "box",
4345
string(gographviz.Style): "filled",
4446
}
45-
for _, t := range targets {
47+
for _, t := range cmdTargets {
4648
name := fmt.Sprintf("%q", fmt.Sprintf("Target %s", t.name))
4749
g.AddNode("G", name, tNodeAttr)
4850
for _, dep := range t.assets {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Verify the creation of the agent-based installer graph
2+
3+
exec openshift-install agent graph --output-file $WORK/agent.dot
4+
5+
exists $WORK/agent.dot

0 commit comments

Comments
 (0)