fix(cli): name the P2P resource limits flag --p2p-enable-limits

kong derives a flag name from the Go field name, so the P2PEnableLimits
fields were exposed as --p-2-p-enable-limits. The docs and the help text
describe --p2p-enable-limits. Set the name on the four commands that take
it (run, explorer, and the llama.cpp and MLX P2P workers) and parse the
documented spelling in the CLI boundary test.

Assisted-by: Claude Code:claude-sonnet-5-5
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto committed 2026-11-03 09:21:07 +00:00
1 parent 52c59004ac
commit 438e52685b
5 files changed
+23 -4

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@ import (
)
type ExplorerCMD struct {
P2PEnableLimits string `env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"`
P2PEnableLimits string `name:"p2p-enable-limits" env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"`
Address string `env:"LOCALAI_ADDRESS,ADDRESS" default:":8080" help:"Bind address for the API server" group:"api"`
PoolDatabase string `env:"LOCALAI_POOL_DATABASE,POOL_DATABASE" default:"explorer.json" help:"Path to the pool database" group:"api"`
ConnectionTimeout string `env:"LOCALAI_CONNECTION_TIMEOUT,CONNECTION_TIMEOUT" default:"2m" help:"Connection timeout for the explorer" group:"api"`
+19
View File
@@ -56,4 +56,23 @@ var _ = Describe("P2P limits CLI boundary", func() {
Expect(explorer.P2PEnableLimits == "true").To(Equal(value == "true"))
}
})
It("accepts the documented --p2p-enable-limits flag at every entry point", func() {
GinkgoT().Setenv("LOCALAI_P2P_ENABLE_LIMITS", "")
run := RunCMD{}
rpc := worker.P2P{}
mlx := worker.P2PMLX{}
explorer := ExplorerCMD{}
entries := map[string]*string{
"run": &run.P2PEnableLimits, "rpc": &rpc.P2PEnableLimits,
"mlx": &mlx.P2PEnableLimits, "explorer": &explorer.P2PEnableLimits,
}
for name, entry := range map[string]any{"run": &run, "rpc": &rpc, "mlx": &mlx, "explorer": &explorer} {
parser, err := kong.New(entry, kong.Vars{"basepath": ".", "generatedcontentpath": ".", "uploadpath": ".", "galleries": config.DefaultGalleriesJSON, "backends": config.DefaultBackendGalleriesJSON, "version": "test"})
Expect(err).NotTo(HaveOccurred())
_, err = parser.Parse([]string{"--p2p-enable-limits=true"})
Expect(err).NotTo(HaveOccurred(), name)
Expect(*entries[name]).To(Equal("true"), name)
}
})
})
+1 -1
View File
@@ -40,7 +40,7 @@ import (
const workerJoinCommand = "local-ai p2p-worker p2p-llama-cpp-rpc"
type RunCMD struct {
P2PEnableLimits string `env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"`
P2PEnableLimits string `name:"p2p-enable-limits" env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"`
AddonHostPolicy string `name:"addon-host-policy" env:"LOCALAI_ADDON_HOST_POLICY" help:"Absolute path to administrator host operation policy JSON, read once at startup. Empty disables environment policy" group:"addons"`
AddonHostOps string `name:"addon-host-ops" env:"LOCALAI_ADDON_HOST_OPS" help:"Add-ons that may call host operations, as a comma list of addon-id=operation-prefix. An add-on that is not listed gets no host operation channel. Empty gives none" group:"addons"`
AddonsEnabled bool `name:"addons-enabled" env:"LOCALAI_ADDONS_ENABLED" default:"true" help:"Run the add-on owner, which installs and supervises add-ons. Turn it off with --addons-enabled=false" group:"addons"`
+1 -1
View File
@@ -17,7 +17,7 @@ import (
)
type P2P struct {
P2PEnableLimits string `env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"`
P2PEnableLimits string `name:"p2p-enable-limits" env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"`
WorkerFlags `embed:""`
Token string `env:"LOCALAI_TOKEN,LOCALAI_P2P_TOKEN,TOKEN" help:"P2P token to use"`
NoRunner bool `env:"LOCALAI_NO_RUNNER,NO_RUNNER" help:"Do not start the llama-cpp-rpc-server"`
+1 -1
View File
@@ -15,7 +15,7 @@ import (
)
type P2PMLX struct {
P2PEnableLimits string `env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"`
P2PEnableLimits string `name:"p2p-enable-limits" env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"`
WorkerFlags `embed:""`
Token string `env:"LOCALAI_TOKEN,LOCALAI_P2P_TOKEN,TOKEN" help:"P2P token to use"`
Peer2PeerNetworkID string `env:"LOCALAI_P2P_NETWORK_ID,P2P_NETWORK_ID" help:"Network ID for P2P mode" group:"p2p"`