Repository navigation
Conversation
问题:login() 与 ListConfigs() 已实现 v3→v1 自动回退,但 GetConfig() 与 PublishConfig() 漏掉了 v1 分支,硬编码走 v3 路径 (/nacos/v3/client/cs/config、/nacos/v3/admin/cs/config)。 Nacos 2.x 服务端不存在这些 v3 路径,导致 config-get/config-set 直接 404。 修复:当 authLoginVersion == "v1" 时回退到 v1 实现,与 listConfigsV1 保持一致的协议差异: - 路径:/nacos/v1/cs/configs - 参数:group(非 groupName)、tenant(非 namespaceId) - 鉴权:accessToken 表单字段(非 Authorization: Bearer 头) - 响应:config-set 为字面量 true,config-get 为原始内容 验证:对 Nacos 2.5.1 standalone 服务端,config-set/config-get 均成功, 原始 push.sh 无需改动即可正常工作。
参考上游 PR nacos-group#89(liupengfei-pagepop,Open 未合并),给 config-set 增加 --type/-t flag,解决 issue nacos-group#72(config-set 缺少类型设置参数)。 与上游 PR 的差异:本 fork 已为 Nacos 2.x 增加 v1 回退(publishConfigV1), 故 type 参数同时透传到 v1 路径,确保 2.x/3.x 服务端都能正确存储配置类型。 改动: - cmd/set_config.go: 新增 --type/-t flag,调用 PublishConfigWithOptions - internal/client/nacos_client.go: 新增 PublishConfigOptions 与 PublishConfigWithOptions;PublishConfig 保留为包装器;publishConfigV1 接收 opts 并透传 type 字段 验证:对 Nacos 2.5.1 服务端,-t yaml→存 yaml,-t xml→存 xml, 不带 -t→存 text(向后兼容)。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动内容
1. config-get 支持
--output输出格式新增
--outputflag,支持三种输出格式:{dataId, group, content}结构化输出,适合脚本消费2. GetConfig/PublishConfig v1 回退(Nacos 2.x 兼容)
修复 Nacos 2.x 上
GetConfig和PublishConfig缺失 v3→v1 API 回退的问题。3. config-set 支持
--type参数基于 issue #72,给
config-set增加--type/-tflag。涉及文件
cmd/get_config.go— 新增--outputflag + 三种 render 函数cmd/get_config_test.go— 新增测试用例internal/help/help.go— 更新 Examplescmd/set_config.go—--typeflaginternal/client/nacos_client.go— v1 回退验证