public IActionResult VerifyUploadedTemplate([FromForm] Dictionary <string, string> dict, [FromForm] String templateName) { templateName = templateName + ".yml"; String tempPath = Path.Combine(Program.ComposeTemporaryDir, templateName); String fileString = System.IO.File.ReadAllText(tempPath); String writeStatus = ""; string finalComposeString = ComposerNew.ReplaceParams(fileString, dict); var filename = ComposeFileOperationsNew.WriteFileToReadyFolder(finalComposeString, templateName, "test"); bool verificationResult = false; if (filename != "ERR_UNABLE_TO_WRITE_TO_FILE") { verificationResult = ComposerNew.VerifyContainer(filename); } if (!verificationResult) { ComposeFileOperationsNew.RemoveFileFromReadyFolder(filename); ComposeFileOperationsNew.RemoveFromReadyList(filename); return(View("ErrorPage")); } else { ComposeFileOperationsNew.AddToTemplatesFromFile(Path.Combine(Program.ComposeTemporaryDir, templateName), templateName, out writeStatus); return(View("SuccessPage")); } }
public IActionResult CreateCustom([FromForm] Dictionary <string, string> dict, [FromForm] String templateName, [FromForm] String instanceName) { String tempPath = Path.Combine(Directory.GetCurrentDirectory(), @"data\templates\" + templateName); String fileString = System.IO.File.ReadAllText(tempPath); string finalComposeString = ComposerNew.ReplaceParams(fileString, dict); var filename = ComposeFileOperationsNew.WriteFileToReadyFolder(finalComposeString, templateName, instanceName); ComposerNew.StartService(filename); return(View("RunComposeFile")); }