Develop and test¶
Build¶
You need Go, Task, and the PAM headers (libpam-dev on Debian and Ubuntu).
git clone https://github.com/srl-labs/clab-api-server.git
cd clab-api-server
task deps # libpam-dev, swag, test tools
cp .env.example .env # set JWT_SECRET
task # tidy, generate the OpenAPI spec, build
sudo ./dist/clab-api-server-linux-amd64 -env-file .env
| Task | Does |
|---|---|
task build |
Build dist/clab-api-server-linux-<arch>. |
task swag |
Regenerate the OpenAPI spec in docs/ from handler annotations. |
task test |
Run the integration tests and write an HTML report to test-reports/. |
task docs |
Preview this site. |
task docs:build |
Build this site into site/. |
Test¶
The tests in tests_go/ call a running server. Configure them in tests_go/.env (API URL, users, and GOTEST_SIMPLE_TOPOLOGY_CONTENT, a topology with a {lab_name} placeholder), then:
The test users must exist on the host, in API_USER_GROUP and SUPERUSER_GROUP.
These docs¶
The site is built with Zensical from docs-site/. You need uv.
- Pages are Markdown in
docs-site/; the navigation is inzensical.toml. - The API reference is ReDoc reading
docs/swagger.json. Runtask swagafter changing handler annotations. -
Topology diagrams are
clabfences, rendered by the Containerlab topology viewer. Reference a file fromdocs-site/diagrams/, and its.annotations.jsonfor a fixed layout: -
Every push to
mainpublishes the site to GitHub Pages.