Fix loading multi-doc YAMLs for CI configurations
What does this MR do and why?
Related to Multi document YAML doesn't work with leading a... (#396846 - closed)
In this MR we fixes 2 bugs:
Fix 1
job:
script: echo hello world
--- # start of the 2nd document
something: ignored
If the YAML contains multiple documents, before the multi-doc YAML we were only loading the first document. After multi-doc YAML changes we started loading multiple documents and assumed that the 1st document, when multiple docs present in the file, is always the config Header defining spec:inputs:.
The error users were seeing errors such Included file <PATH/TO/YML> does not have valid YAML syntax! because we were considering the 2nd document as the config content.
Fix 2
job:
script: echo hello world
--- # start of the 2nd document
After fixing the 1st bug, when the 2nd document is empty we started raising a NotHashError. We needed a way to reject empty documents in order to maintain backwards compatibility.
Since whether to reject documents is not the Loader::MultiDocYaml responsibility, we now pass a reject_empty: true option from CI code (Gitlab::Ci::Config::Yaml).
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.