Skip to content

Commit

Permalink
Merge pull request #955 from jonjohnsonjr/more-dot
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh authored Nov 14, 2023
2 parents acc03e0 + 4c85512 commit 7638320
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions internal/cli/dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ apko dot --web example.yaml
# Open browser to explore example.yaml, rendering a (almost) minimum spanning tree
apko dot --web -S example.yaml
`,
Example: ` apko show-packages <config.yaml>`,
Example: ` apko dot <config.yaml>`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
archs := types.ParseArchitectures(archstrs)
Expand Down Expand Up @@ -159,7 +159,15 @@ func DotCmd(ctx context.Context, configFile string, archs []types.Architecture,
n := dot.NewNode(pkg)
out.AddNode(n)
out.AddEdge(dot.NewEdge(file, n))
deps[pkg] = struct{}{}
if before, _, ok := strings.Cut(pkg, "~"); ok {
p := dot.NewNode(before)
out.AddNode(p)
out.AddEdge(dot.NewEdge(n, p))

deps[before] = struct{}{}
} else {
deps[pkg] = struct{}{}
}
}

renderDeps := func(pkg *apk.RepositoryPackage) {
Expand All @@ -175,6 +183,9 @@ func DotCmd(ctx context.Context, configFile string, archs []types.Architecture,
out.AddNode(n)

for _, dep := range dmap[pkg.Name] {
if before, _, ok := strings.Cut(dep, "~"); ok {
dep = before
}
d := dot.NewNode(dep)
if web {
if !strings.Contains(dep, ":") {
Expand Down Expand Up @@ -232,6 +243,17 @@ func DotCmd(ctx context.Context, configFile string, archs []types.Architecture,
out.AddEdge(dot.NewEdge(p, n))
}
continue
} else if before, _, ok := strings.Cut(prov, "~"); ok {
if _, ok := deps[before]; ok {
p := dot.NewNode(before)
if err := p.Set("shape", "rect"); err != nil {
panic(err)
}
out.AddNode(p)

out.AddEdge(dot.NewEdge(p, n))
}
continue
} else {
continue
}
Expand Down

0 comments on commit 7638320

Please sign in to comment.