mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-03 10:33:40 +01:00
Add a canonical Go topology builder in internal/unifiedresources that derives live infrastructure nodes, networks and VLANs, exposed reverse-proxy and Kubernetes Ingress routes, and verified service dependencies from Pulse's unified presentation resources. Expose the graph through one shared read-only contract: - GET /api/agent/topology (monitoring:read) with optional filters for resourceId neighborhood, platform, network, relationshipType, anonymize, and summaryOnly - Manifest capability get_topology projected automatically to pulse-mcp with updated generated docs in cmd/pulse-mcp/README.md - pulse topology CLI subcommand supporting JSON and Markdown output
76 lines
1.6 KiB
Go
76 lines
1.6 KiB
Go
package pulsecli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
type CommandSpec struct {
|
|
Use string
|
|
Short string
|
|
Long string
|
|
Version string
|
|
VersionTemplate string
|
|
VersionPrinter func(io.Writer)
|
|
}
|
|
|
|
type RuntimeSpec struct {
|
|
Run func(context.Context) error
|
|
}
|
|
|
|
type CommandDeps struct {
|
|
Config *ConfigDeps
|
|
Bootstrap *BootstrapDeps
|
|
Mock *MockDeps
|
|
Actions *ActionsDeps
|
|
Fleet *FleetDeps
|
|
Topology *TopologyDeps
|
|
}
|
|
|
|
func NewRootCommand(command CommandSpec, runtime RuntimeSpec, deps CommandDeps) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: command.Use,
|
|
Short: command.Short,
|
|
Long: command.Long,
|
|
SilenceUsage: true,
|
|
Version: command.Version,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
if runtime.Run == nil {
|
|
return nil
|
|
}
|
|
return runtime.Run(cmd.Context())
|
|
},
|
|
}
|
|
|
|
if command.VersionTemplate != "" {
|
|
cmd.SetVersionTemplate(command.VersionTemplate)
|
|
}
|
|
|
|
cmd.AddCommand(newVersionCmd(command))
|
|
cmd.AddCommand(newConfigCmd(deps.Config))
|
|
cmd.AddCommand(newBootstrapTokenCmd(deps.Bootstrap))
|
|
cmd.AddCommand(newMockCmd(deps.Mock))
|
|
cmd.AddCommand(newActionsCmd(deps.Actions))
|
|
cmd.AddCommand(newFleetCmd(deps.Fleet))
|
|
cmd.AddCommand(newTopologyCmd(deps.Topology))
|
|
|
|
return cmd
|
|
}
|
|
|
|
func newVersionCmd(command CommandSpec) *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "version",
|
|
Short: "Print version information",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if command.VersionPrinter != nil {
|
|
command.VersionPrinter(cmd.OutOrStdout())
|
|
return
|
|
}
|
|
fmt.Fprintf(cmd.OutOrStdout(), "%s\n", command.Version)
|
|
},
|
|
}
|
|
}
|