Sitelet https://github.com/Netis/cloud-probe/issues/298
Skip to content

cpctl: cpctl config (REFACTOR-CPCTL.md §6.4) is not implemented; unknown subcommands log text on stderr under -f jsonl #298

Description

@vaderyang

Summary

docs/REFACTOR-CPCTL.md opens with "Sections 5.3 and 6 are the contract for --format jsonl output". §6 lists cpctl config, and §6.4 defines its behaviour: call info, read config_path, dump the file; in jsonl, emit {"path":"...","content":<parsed-json>}. §8 and §9 say the refactor is complete and no decisions are open.

On 0.9.x (d302572) the command does not exist. cpctl/cmd/ registers only info, ping, stats and version, plus cobra's completion:

$ cpctl config -u w.sock -f jsonl; echo exit=$?
time=2026-10-03T19:20:51.597+08:00 level=ERROR source=.../cpctl/cmd/base.go:92 msg="command failed" err="unknown command \"config\" for \"cpctl\""
exit=1

That output also shows a second deviation from §5.3 ("every line cpctl writes to stderr is also a JSON object"). With -f jsonl, an unknown subcommand is reported as a text slog line. Cobra rejects the command before it parses --format, so the logger never switches to JSON. Unknown flags and bad flag values on a known command are reported as JSON correctly.

If config was dropped on purpose, §6 and §6.4 should say so, as §7 does for the other dropped commands. A useful detail for implementing it: info returns config_path as given on the command line (here the relative w.json) together with working_dir, so config has to resolve the path against working_dir.

中文原文

REFACTOR-CPCTL.md 开头写明 §5.3 和 §6 是 --format jsonl 的输出契约,§6 列出 cpctl config,§6.4 规定其行为(调用 info 取 config_path 并输出文件;jsonl 下输出 {"path":...,"content":...}),§8/§9 称重构已完成、没有未决事项。但 0.9.x 上没有这个命令,cpctl/cmd 只注册了 info、ping、stats、version(以及 cobra 的 completion),运行报 unknown command。该输出同时违反 §5.3“stderr 的每一行都是 JSON”:-f jsonl 下未知子命令以文本 slog 行报告,因为 cobra 在解析 --format 之前就拒绝了命令(已知命令上的未知参数、错误参数值都能正确输出 JSON)。如果 config 是有意舍弃的,§6/§6.4 应像 §7 那样说明。另:info 返回的 config_path 是命令行原样传入的(这里是相对路径 w.json),同时返回 working_dir,config 需要据此解析路径。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions