From: Ward Vandewege Date: Mon, 11 Nov 2013 21:38:03 +0000 (-0500) Subject: Allow up to 10 levels of nesting for variable substitution in config.rb X-Git-Tag: 1.1.0~2963^2~1^2~2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/e02fdd5490c3fcf24281f0fedc6ad4a0a12577c4 Allow up to 10 levels of nesting for variable substitution in config.rb --- diff --git a/docker/config.rb b/docker/config.rb index 49004dad82..c96819e506 100755 --- a/docker/config.rb +++ b/docker/config.rb @@ -29,14 +29,24 @@ end # ============================================================ # For each *.in file in the docker directories, substitute any # @@variables@@ found in the file with the appropriate config -# variable. +# variable. Support up to 10 levels of nesting. Dir.glob('*/*.in') do |template_file| output_path = template_file.sub(/\.in$/, '') output = File.open(output_path, "w") File.open(template_file) do |input| input.each_line do |line| - output.write(line.gsub(/@@(.*?)@@/) { |var| config[$1] || var }) + + @count = 0 + while @count < 10 + @out = line.gsub!(/@@(.*?)@@/) do |var| + config[Regexp.last_match[1]] || var.gsub!(/@@/, '@_NOT_FOUND_@') + end + break if @out.nil? + @count += 1 + end + + output.write(line) end end output.close