* feat(release): add Homebrew tap support and fix artifact naming
- Fix platform naming: binaries now named core-{os}-{arch} instead of
just 'core', preventing collision when artifacts merge
- Add tar.gz archives for non-Windows builds (Homebrew requirement)
- Add update-tap job to alpha-release workflow that auto-updates
host-uk/homebrew-tap with checksums on each alpha release
- Add homebrew publisher to .core/release.yaml for formal releases
- Update install instructions to include brew install
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(unifi): add UniFi Go SDK integration and CLI commands
- Add pkg/unifi SDK wrapping unpoller/unifi with TLS, config resolution,
and typed accessors for sites, clients, devices, networks, and routes
- Add CLI commands: unifi sites, clients, devices, networks, routes, config
- Register unifi commands in full variant build
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(release): set AppVersion ldflags, git config, and tap token
- Set -X pkg/cli.AppVersion in ldflags so core --version reports the
correct version instead of "dev"
- Add git config user.name/email in update-tap job so commit succeeds
- Use HOMEBREW_TAP_TOKEN secret instead of GITHUB_TOKEN for cross-repo
push to host-uk/homebrew-tap
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(unifi): address CodeRabbit review feedback
- Reject conflicting --wired and --wireless flags in clients command
- Complete --type flag help text with bgp and ospf route types
- URL-escape site name in routes API path
- Wrap all command errors with log.E for contextual diagnostics
- Set TLS MinVersion to 1.2 on UniFi client
- Simplify redundant fmt.Sprintf in Print calls
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
74 lines
1.7 KiB
Go
74 lines
1.7 KiB
Go
package unifi
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/host-uk/core/pkg/cli"
|
|
"github.com/host-uk/core/pkg/log"
|
|
uf "github.com/host-uk/core/pkg/unifi"
|
|
)
|
|
|
|
// Devices command flags.
|
|
var (
|
|
devicesSite string
|
|
devicesType string
|
|
)
|
|
|
|
// addDevicesCommand adds the 'devices' subcommand for listing infrastructure devices.
|
|
func addDevicesCommand(parent *cli.Command) {
|
|
cmd := &cli.Command{
|
|
Use: "devices",
|
|
Short: "List infrastructure devices",
|
|
Long: "List all infrastructure devices (APs, switches, gateways) on the UniFi network.",
|
|
RunE: func(cmd *cli.Command, args []string) error {
|
|
return runDevices()
|
|
},
|
|
}
|
|
|
|
cmd.Flags().StringVar(&devicesSite, "site", "", "Filter by site name")
|
|
cmd.Flags().StringVar(&devicesType, "type", "", "Filter by device type (uap, usw, usg, udm, uxg)")
|
|
|
|
parent.AddCommand(cmd)
|
|
}
|
|
|
|
func runDevices() error {
|
|
client, err := uf.NewFromConfig("", "", "", "")
|
|
if err != nil {
|
|
return log.E("unifi.devices", "failed to initialise client", err)
|
|
}
|
|
|
|
devices, err := client.GetDeviceList(devicesSite, strings.ToLower(devicesType))
|
|
if err != nil {
|
|
return log.E("unifi.devices", "failed to fetch devices", err)
|
|
}
|
|
|
|
if len(devices) == 0 {
|
|
cli.Text("No devices found.")
|
|
return nil
|
|
}
|
|
|
|
table := cli.NewTable("Name", "IP", "MAC", "Model", "Type", "Version", "Status")
|
|
|
|
for _, d := range devices {
|
|
status := successStyle.Render("online")
|
|
if d.Status != 1 {
|
|
status = errorStyle.Render("offline")
|
|
}
|
|
|
|
table.AddRow(
|
|
valueStyle.Render(d.Name),
|
|
d.IP,
|
|
dimStyle.Render(d.Mac),
|
|
d.Model,
|
|
dimStyle.Render(d.Type),
|
|
dimStyle.Render(d.Version),
|
|
status,
|
|
)
|
|
}
|
|
|
|
cli.Blank()
|
|
cli.Print(" %d devices\n\n", len(devices))
|
|
table.Render()
|
|
|
|
return nil
|
|
}
|