如何从 check-yaml git 钩子中排除 !Ref 标签?
How exclude !Ref tag from check-yaml git hook?
有一个 serverless.yaml
文件,其中包含如下行:
VpcId: !Ref MyVpc
Yaml 文件由 check-yaml
git
挂钩验证,该挂钩由 pre-commit
命令调用。所以 pre-commit run --all-files
运行 失败并出现错误:
could not determine a constructor for the tag '!Ref'
in "serverless.yml", line 172, column 29
有没有办法配置check-yaml
跳过这个错误?
hooks:
- id: check-yaml
args: ['--unsafe']
应该可以解决问题。它只是检查语法而不是尝试加载 YAML。
在上面的具体示例中,建议使用 CloudFormation 模板,您还可以考虑 cfn-python-lint's pre-commit hook。
有一个 serverless.yaml
文件,其中包含如下行:
VpcId: !Ref MyVpc
Yaml 文件由 check-yaml
git
挂钩验证,该挂钩由 pre-commit
命令调用。所以 pre-commit run --all-files
运行 失败并出现错误:
could not determine a constructor for the tag '!Ref'
in "serverless.yml", line 172, column 29
有没有办法配置check-yaml
跳过这个错误?
hooks:
- id: check-yaml
args: ['--unsafe']
应该可以解决问题。它只是检查语法而不是尝试加载 YAML。
在上面的具体示例中,建议使用 CloudFormation 模板,您还可以考虑 cfn-python-lint's pre-commit hook。