added texliveImageNameOveride

This commit is contained in:
Henry Oswald 2018-07-13 10:37:22 +01:00
parent 6825285b02
commit 4ec8a423cb
3 changed files with 25 additions and 1 deletions

View file

@ -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

View file

@ -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"]

View file

@ -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