diff --git a/services/clsi/app/coffee/RequestParser.coffee b/services/clsi/app/coffee/RequestParser.coffee index 596b52995c..d375e9e331 100644 --- a/services/clsi/app/coffee/RequestParser.coffee +++ b/services/clsi/app/coffee/RequestParser.coffee @@ -1,3 +1,5 @@ +settings = require("settings-sharelatex") + module.exports = RequestParser = VALID_COMPILERS: ["pdflatex", "latex", "xelatex", "lualatex"] MAX_TIMEOUT: 300 @@ -67,6 +69,10 @@ module.exports = RequestParser = sanitizedRootResourcePath = RequestParser._sanitizePath(rootResourcePath) response.rootResourcePath = RequestParser._checkPath(sanitizedRootResourcePath) + if settings.texliveImageNameOveride? + tag = compile.options.imageName.split(":")[1] + response.imageName = "#{settings.texliveImageNameOveride}:#{tag}" + for resource in response.resources if resource.path == originalRootResourcePath resource.path = sanitizedRootResourcePath diff --git a/services/clsi/config/settings.defaults.coffee b/services/clsi/config/settings.defaults.coffee index 081ded81a2..1f3fe8be02 100644 --- a/services/clsi/config/settings.defaults.coffee +++ b/services/clsi/config/settings.defaults.coffee @@ -33,6 +33,7 @@ module.exports = project_cache_length_ms: 1000 * 60 * 60 * 24 parallelFileDownloads:1 filestoreDomainOveride: process.env["FILESTORE_DOMAIN_OVERRIDE"] + texliveImageNameOveride: process.env["TEX_LIVE_IMAGE_NAME_OVERRIDE"] if process.env["DOCKER_RUNNER"] diff --git a/services/clsi/test/unit/coffee/RequestParserTests.coffee b/services/clsi/test/unit/coffee/RequestParserTests.coffee index 0b420b362d..04405ac6a3 100644 --- a/services/clsi/test/unit/coffee/RequestParserTests.coffee +++ b/services/clsi/test/unit/coffee/RequestParserTests.coffee @@ -16,10 +16,12 @@ describe "RequestParser", -> compile: token: "token-123" options: + imageName: "basicImageName/here:2017-1" compiler: "pdflatex" timeout: 42 resources: [] - @RequestParser = SandboxedModule.require modulePath + @RequestParser = SandboxedModule.require modulePath, requires: + "settings-sharelatex": @settings = {} afterEach -> tk.reset() @@ -57,6 +59,21 @@ describe "RequestParser", -> it "should set the compiler to pdflatex by default", -> @data.compiler.should.equal "pdflatex" + describe "with imageName set", -> + beforeEach -> + @RequestParser.parse @validRequest, (error, @data) => + + it "should set the imageName", -> + @data.imageName.should.equal "basicImageName/here:2017-1" + + describe "with texliveImageNameOveride set", -> + beforeEach -> + @settings.texliveImageNameOveride = "usethisoveride/overhere" + @RequestParser.parse @validRequest, (error, @data) => + + it "should override the image path", -> + @data.imageName.should.equal "usethisoveride/overhere:2017-1" + describe "without a timeout specified", -> beforeEach -> delete @validRequest.compile.options.timeout