如何从 check-yaml git hook 中排除 !Ref 标签?

Che*_*rry 5 python git yaml pre-commit-hook

有一个serverless.yaml文件包含这样的行:

VpcId: !Ref MyVpc
Run Code Online (Sandbox Code Playgroud)

Yaml 文件check-yaml gitpre-commit命令调用的钩子验证。所以pre-commit run --all-files运行失败并出现错误:

could not determine a constructor for the tag '!Ref'
  in "serverless.yml", line 172, column 29
Run Code Online (Sandbox Code Playgroud)

有没有办法配置check-yaml跳过这个错误?

fly*_*lyx 6

hooks:
- id: check-yaml
  args: ['--unsafe']
Run Code Online (Sandbox Code Playgroud)

应该做的伎俩。它只是检查语法而不是尝试加载 YAML。

  • 然而,这是有效的,“使用此选项将消除对其他 yaml 实现的可移植性的所有保证”。 (2认同)