Allow `include` keyword to be customised

In order to implement https://gitlab.com/gitlab-org/gitlab-ce/issues/52679 we would like to be able to have the following configuration options added to the include keyword:

  • ignore_if_missing
  • merge_after
  • deep_merge

So you could do something like:

include:
  path: '/my-include.yml'
  ignore_if_missing: true # Simply skip if this file does not exist
  merge_after: true # This included file should override the current one and not the other way round
  deep_merge: false # Do not deep merge just overwrite keys

Why ignore_if_missing?

The use case is hard to imagine for normal users but with Auto DevOps the pipeline is defined outside your repo and this would allow the Auto DevOps template to include files inside your repo but not all projects will have this file. I'm not sure it generalises well outside of Auto DevOps though.

Why merge_after?

Because in the case of Auto DevOps it will include a file inside your repo so it would be useful if the included file could override auto devops defaults.

Why deep_merge?

Because sometimes you want to override a whole job like test but if we deep merge like we do by default then there is no way to delete keys you don't need like variables. We started out not using deep merge and deep merge is useful sometimes when you want to override only parts of a job but when you want to override a whole job it is limiting and you may need to explicitly add keys and null things out somehow.

Edited by Dylan Griffith