cnb-rs 官方 hello-world extension。最简 demo + e2e 测试样本。
这是从
extension-template实例化出来的 demo extension。如果你想写自己的 extension,请直接 fork extension-template,而不是 fork 本仓库。
cnb-rs ext install / upgrade / remove 套件指向本仓库做 happy path 验证extension-template 从 0 到 release 的全流程跑得通cnb-rs ext install wwvo/cnb-rs/cnb-hello
| 平台 | binary 来源 |
|---|---|
| linux-amd64 | ✅ CNB Pipeline 自动 build + 上传 |
| linux-arm64 | ⏳ Phase 4.x 后会补;当前缺失 |
| windows-amd64 | ⏳ 维护者本地 build 后用 cnb-rs release asset-upload 追加;当前缺失 |
| darwin-arm64 / darwin-amd64 | ⏳ 同 Windows,本地 build 上传;当前缺失 |
当前 Phase 4 MVP 仅保证 linux-amd64 happy path。其它平台用户可参考 extension-template README 的「需要 macOS / Windows binary 怎么办」节自行 build。
$ cnb-rs hello
👋 Hello from cnb-hello (extension-template demo)!
🌐 CNB host: cnb.cool
📁 当前仓库: alice/projects/myproj
🔍 调用 CNB API: GET https://api.cnb.cool/user ...
✓ 当前登录用户:
username: alice
nickname: Alice Wonderland
💡 把 src/main.rs 替换为你的业务逻辑,cnb-rs ext install 即可分发。
详见仓库 README.md。
# 看是否有新版
cnb-rs ext upgrade hello --dry-run
# 升级
cnb-rs ext upgrade hello
# 卸载
cnb-rs ext remove hello
源码就是 src/main.rs 这 60 多行 Rust:读 CNB_TOKEN env var → 用 reqwest 调 GET /user → 友好打印。零特殊技巧,可以直接当成 cnb-rs extension 的 reference impl 阅读。
bash 等价版见 examples/bash-extension.sh(30 行 shell,相同逻辑)。
本仓库不收 PR 新功能——它就是个 demo,复杂功能请去 fork extension-template 写你自己的 extension。
如果发现 demo bug(如 panic / output 错误 / build fail)欢迎提 issue / PR。
MIT