Browse Source

added texliveImageNameOveride

Henry Oswald 8 năm trước cách đây
mục cha
commit
4ec8a423cb

+ 6 - 0
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

+ 1 - 0
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"]

+ 18 - 1
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