Skip to content

Backend: Support inputs with !reference

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Details

The !reference keyword doesn’t work with input interpolation

Adding the information from Slack thread

I think the !reference doesn’t work with interpolation because we process !reference before the interpolation and it cannot understand the directive. if we were doing interpolation on the whole text blob before parsing it to yaml we could support !reference . But this means rewriting the interpolation logic.

We can support interpolation before the !reference. It is more about re-ordering the codebase

We could probably hook the interpolator in YAML tag classes, for example:

            override :_resolve                                                                                           
            def _resolve(resolver)                                                                                       
              object = config_at_location(resolver)                                                                      
              value = resolver.deep_resolve(object)   # <-- interpolate this                                                                   
                                                                                                                         
              raise MissingReferenceError, missing_ref_error_message unless value                                        
                                                                                                                         
              value                                                                                                      
            end 

Proposal

Update the CI Interpolator recursive_replace method to interpolate and replace values in Yaml::Tags::Reference objects. With this approach, all tag values will have already been interpolated by the time it is resolved.

Context (ref: !131950 (comment 1563891482)):

tags remain as Yaml::Tags::Reference objects and don't get resolved until after all the Yamls are loaded and interpolated here. GitLab doesn't need to know which key to read until then.

Edited by 🤖 GitLab Bot 🤖