使用Helm Unittest时出现“no template associated with gotpl”错误求助
问题排查与解决
问题原因
helm-unittest插件默认只会加载测试文件templates字段中明确指定的模板文件,未被列出的模板不会被预加载。你的测试仅指定了xyz-deployment.yaml,但该模板通过include引用了xyz-configmap.yaml,插件找不到这个未被加载的依赖模板,因此触发报错。
解决方案
在测试文件的templates列表中添加被依赖的xyz-configmap.yaml,确保插件加载该模板:
suite: test xyz deployment templates: - xyz-deployment.yaml - xyz-configmap.yaml # 新增该行,加入被引用的模板文件 tests: - it: will not do much yet set: image.tag: latest asserts: - isKind: of: Deployment
验证
修改完成后重新运行测试命令:
helm unittest xyz
此时插件会同时加载部署模板和配置映射模板,include语句能正常找到目标模板,测试即可正常执行。
内容的提问来源于stack exchange,提问作者Steve H
相关产品推荐
相关产品推荐

