diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 01c17a04..8d669821 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,12 +20,6 @@ jobs: steps: - uses: actions/checkout@v6 - - name: Checkout unifi (when go.mod replace => ../unifi) - run: | - if grep -q 'replace github.com/unpoller/unifi/v5 => ../unifi' go.mod; then - git clone --depth 1 https://github.com/brngates98/unifi.git ../unifi -b discover-flag - fi - - name: Set up Go uses: actions/setup-go@v6 with: @@ -45,13 +39,6 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v6 - - - name: Checkout unifi (when go.mod replace => ../unifi) - run: | - if grep -q 'replace github.com/unpoller/unifi/v5 => ../unifi' go.mod; then - git clone --depth 1 https://github.com/brngates98/unifi.git ../unifi -b discover-flag - fi - - name: Set up Go uses: actions/setup-go@v6 with: diff --git a/docs/PR_936_REPLACEMENT.md b/docs/PR_936_REPLACEMENT.md index 37a0cc11..601b0d67 100644 --- a/docs/PR_936_REPLACEMENT.md +++ b/docs/PR_936_REPLACEMENT.md @@ -1,8 +1,6 @@ -# Replacement for PR #936: Endpoint discovery via `--discover` (Go) +# Endpoint discovery via `--discover` (Go) -**Supersedes:** [PR #936](https://github.com/unpoller/unpoller/pull/936) (Python endpoint-discovery tool in `tools/endpoint-discovery/`). - -PR #936 added a Python/Playwright tool to discover API endpoints by driving a headless browser. This replacement implements the same goal **inside unpoller** using the unifi library: no Python, no Playwright, same config as normal polling. +The [unpoller](https://github.com/unpoller/unpoller) repo has a Python/Playwright endpoint-discovery tool in `tools/endpoint-discovery/` (browser-based; discovers unknown endpoints; more support currently). This doc describes the Go-based discovery: it lives in [unpoller/unifi](https://github.com/unpoller/unifi) and unpoller, probes a fixed list of known API paths, and discovers/confirms known endpoints only. --- @@ -11,7 +9,7 @@ PR #936 added a Python/Playwright tool to discover API endpoints by driving a he - **Feature:** `--discover` flag on unpoller that probes known API endpoints on the controller and writes a shareable markdown report. - **Credentials:** Uses the same config file (and first unifi controller) as normal unpoller runs. - **Output:** Markdown file (default `api_endpoints_discovery.md`) with method, path, and HTTP status for each endpoint. Users can share this when reporting API/404 issues (e.g. [issue #935](https://github.com/unpoller/unpoller/issues/935)). -- **Dependency:** Requires [unpoller/unifi](https://github.com/unpoller/unifi) with `DiscoverEndpoints` and `Probe` (unifi PR/branch with discovery support). +- **Dependency:** Requires [unpoller/unifi](https://github.com/unpoller/unifi) with `DiscoverEndpoints` and `Probe` merged. --- @@ -26,8 +24,6 @@ PR #936 added a Python/Playwright tool to discover API endpoints by driving a he | `pkg/inputunifi/discover.go` | **New file.** Implement `Discoverer`: first controller, authenticate, get sites, call `c.Unifi.DiscoverEndpoints(site, outputPath)`. | | `.gitignore` | Add `up.discover-test.json`, `api_endpoints_discovery.md`. | -**Removed (vs PR #936):** No `tools/endpoint-discovery/` (no Python, no Playwright). - --- ## Usage @@ -45,15 +41,15 @@ unpoller --discover --discover-output api_endpoints_discovery.md --- -## PR title (for replacement PR) +## PR title -**Add `--discover` to probe API endpoints and write shareable report (replaces #936)** +**Add `--discover` to probe API endpoints and write shareable report** --- ## PR description (suggested) -**Replaces #936** (Python endpoint-discovery tool). Implements endpoint discovery inside unpoller using the unifi library; no Python or Playwright. +Go-based endpoint discovery: probes known API paths on the controller and writes a shareable report. Uses the [unifi](https://github.com/unpoller/unifi) library; same config as normal polling. The Python tool in `tools/endpoint-discovery/` remains for browser-based discovery (more coverage). **What it does** - `unpoller --discover` uses the first unifi controller from your config, authenticates, and probes a set of known API paths. @@ -65,6 +61,6 @@ unpoller --discover --discover-output api_endpoints_discovery.md unpoller --discover --config /path/to/up.conf --discover-output api_endpoints_discovery.md ``` -**Requires** unpoller/unifi with `DiscoverEndpoints` (and `Probe`) merged or a compatible unifi version. +**Requires** [unpoller/unifi](https://github.com/unpoller/unifi) with `DiscoverEndpoints` (and `Probe`) merged. -**Closes #936** (replaced by this approach). +**CI:** Merge unifi first, then this PR (or update go.mod to require the new unifi release). For local testing, use `replace github.com/unpoller/unifi/v5 => ../unifi` with the unifi repo checked out. diff --git a/go.mod b/go.mod index 24983dee..4ee34dd5 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/prometheus/common v0.67.5 github.com/spf13/pflag v1.0.10 github.com/stretchr/testify v1.11.1 - github.com/unpoller/unifi/v5 v5.11.0 + github.com/unpoller/unifi/v5 v5.13.0 golang.org/x/crypto v0.47.0 golang.org/x/term v0.39.0 golift.io/cnfg v0.2.3 @@ -46,6 +46,3 @@ require ( golang.org/x/sys v0.40.0 // indirect google.golang.org/protobuf v1.36.11 // indirect ) - -// Use local unifi with DiscoverEndpoints until unpoller/unifi#xx is merged and released. -replace github.com/unpoller/unifi/v5 => ../unifi diff --git a/go.sum b/go.sum index 94c731da..b7a03e77 100644 --- a/go.sum +++ b/go.sum @@ -77,8 +77,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/unpoller/unifi/v5 v5.11.0 h1:QNt/RgwOkBWFjiUyHfIGs7OCuz2Me3gmZH92FVOzTnU= -github.com/unpoller/unifi/v5 v5.11.0/go.mod h1:vSIXIclPG9dpKxUp+pavfgENHWaTZXvDg7F036R1YCo= +github.com/unpoller/unifi/v5 v5.13.0 h1:0pdMckXzGoH0Lg8+WGV4p6ZJeMQsmqmfkdZLtumdIao= +github.com/unpoller/unifi/v5 v5.13.0/go.mod h1:vSIXIclPG9dpKxUp+pavfgENHWaTZXvDg7F036R1YCo= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=