$ show grafana/xk6
xk6 is a command-line tool and Go library for building custom k6 binaries with extensions, enabling developers to create, test, and distribute k6 extensions. The tool provides scaffolding for new extensions, a build system that integrates with k6's module system and automatically resolves the correct k6 major version, a linter for extension compliance (including security, licensing, and quality checks), a test runner for k6 scripts, and a dependency synchronizer to keep extension dependencies aligned with k6. It also ships as a Docker image and a Dev Container feature. The codebase is a well-structured Go application using cobra for CLI, with clean separation of concerns across internal packages for linting, scaffolding, sync, and testing. It demonstrates high craftsmanship with proper error handling, logging, and test coverage.
The LLM identified 3 files worth highlighting for reuse:
Provides a pluggable linter for k6 extension compliance, with individual checkers (security, license, module, build, etc.) implemented as simple functions returning a CheckResult. The checker runner selects checkers based on presets or manual enable/disable, and the state object caches expensive computations (module parsing, build, version output) across checks. This pattern is highly reusable for any project that needs extensible validation with predefined presets and custom overrides.
Implements a dependency synchronizer that aligns Go module versions with those in a target project (k6). It fetches the target's go.mod from the Go proxy, compares requires, and runs `go get` to match versions. Includes robust Go proxy interaction with retry, backoff, and proper handling of major-version module paths (v1, v2, v3…). The logic is generic and could be extracted to synchronize any Go module's dependencies against a reference project.
A standalone utility that adjusts container UID/GID to match the host user's, enabling correct file ownership on mounted volumes. It recursively chowns files owned by the container user to the runtime UID/GID, handles mount points, and then execs the target command. This is a direct adaptation of the popular fixuid tool, packaged as a minimal Go binary with setuid bit. It is completely self-contained and can be used in any Docker image that needs to run as a non-root user with host-volume compatibility.