From 02a34314fcc283259235082c49f427bc95fc6ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Mon, 7 Mar 2022 12:13:28 +0100 Subject: [PATCH 1/2] fixed issue that images cause problems with setup scripts --- runners/katacoda/index.ts | 6 +++--- runners/katacoda/katacodaAssetManager.ts | 18 ++++++++++-------- runners/katacoda/katacodaTools.ts | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index b941d40b..3fdbe227 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -75,11 +75,11 @@ export class Katacoda extends Runner { let imageDirectory = path.join(this.playbookPath, "images"); if(fs.existsSync(imageDirectory)) { - this.assetManager.registerDirectory(imageDirectory, "", "", true); + this.assetManager.registerDirectory(imageDirectory, "", "", true, false); } // copy all assets from temp/setup in assets folder - this.assetManager.registerDirectory(path.join(this.tempPathTutorial, "setup"), "setup", "/root/setup", true); + this.assetManager.registerDirectory(path.join(this.tempPathTutorial, "setup"), "setup", "/root/setup", true, true); this.assetManager.copyAssets(); // write index file, required for katacoda to load the tutorial @@ -478,7 +478,7 @@ export class Katacoda extends Runner { fs.appendFileSync(setupFile, "##########\n"); } - this.assetManager.registerFile(setupFile, "setup/setup.txt", "/root/setup", false); + this.assetManager.registerFile(setupFile, "setup/setup.txt", "/root/setup", false, true); } private changeCurrentDir(targetDir:string, terminalId?: number, isRunning?: boolean):string{ diff --git a/runners/katacoda/katacodaAssetManager.ts b/runners/katacoda/katacodaAssetManager.ts index 868363fd..9b5f824a 100644 --- a/runners/katacoda/katacodaAssetManager.ts +++ b/runners/katacoda/katacodaAssetManager.ts @@ -11,7 +11,7 @@ export class KatacodaAssetManager { this.assetDirectory = assetDir; } - registerFile(filepathSource: string, filepathTarget: string, katacodaDirectory: string, copyFile: boolean) { + registerFile(filepathSource: string, filepathTarget: string, katacodaDirectory: string, copyFile: boolean, copyIntoKatacodaEnvironment: boolean) { this.assetData.push({ sourcePath: filepathSource, targetPath: filepathTarget, @@ -19,19 +19,21 @@ export class KatacodaAssetManager { copyFile: copyFile }); - this.katacodaAssets.push({ - file: filepathTarget.replace(/\\/g, "/"), - target: katacodaDirectory.replace(/\\/g, "/") - }) + if(copyIntoKatacodaEnvironment) { + this.katacodaAssets.push({ + file: filepathTarget.replace(/\\/g, "/"), + target: katacodaDirectory.replace(/\\/g, "/") + }) + } } - registerDirectory(directorySource: string, filepathTarget: string, katacodaDirectory: string, copyFile: boolean) { + registerDirectory(directorySource: string, filepathTarget: string, katacodaDirectory: string, copyFile: boolean, copyIntoKatacodaEnvironment: boolean) { let dir = fs.readdirSync(directorySource); dir.forEach(file => { if(fs.lstatSync(path.join(directorySource, file)).isDirectory()) { - this.registerDirectory(path.join(directorySource, file), filepathTarget, katacodaDirectory, copyFile); + this.registerDirectory(path.join(directorySource, file), filepathTarget, katacodaDirectory, copyFile, copyIntoKatacodaEnvironment); } else { - this.registerFile(path.join(directorySource, file), path.join(filepathTarget, file), katacodaDirectory, copyFile); + this.registerFile(path.join(directorySource, file), path.join(filepathTarget, file), katacodaDirectory, copyFile, copyIntoKatacodaEnvironment); } }); } diff --git a/runners/katacoda/katacodaTools.ts b/runners/katacoda/katacodaTools.ts index 543244a0..795a8f0b 100644 --- a/runners/katacoda/katacodaTools.ts +++ b/runners/katacoda/katacodaTools.ts @@ -24,7 +24,7 @@ export class KatacodaTools { }, "environment": environment, "backend": { - "imageid": "ubuntu:1804" + "imageid": "ubuntu:2004" } } return indexJsonObject; From 6840a0aa37762250280e93f3f6b7294fda4e3d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Tue, 8 Mar 2022 10:00:38 +0100 Subject: [PATCH 2/2] removed unnecessary boolean variable --- runners/katacoda/index.ts | 6 +++--- runners/katacoda/katacodaAssetManager.ts | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 3fdbe227..b941d40b 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -75,11 +75,11 @@ export class Katacoda extends Runner { let imageDirectory = path.join(this.playbookPath, "images"); if(fs.existsSync(imageDirectory)) { - this.assetManager.registerDirectory(imageDirectory, "", "", true, false); + this.assetManager.registerDirectory(imageDirectory, "", "", true); } // copy all assets from temp/setup in assets folder - this.assetManager.registerDirectory(path.join(this.tempPathTutorial, "setup"), "setup", "/root/setup", true, true); + this.assetManager.registerDirectory(path.join(this.tempPathTutorial, "setup"), "setup", "/root/setup", true); this.assetManager.copyAssets(); // write index file, required for katacoda to load the tutorial @@ -478,7 +478,7 @@ export class Katacoda extends Runner { fs.appendFileSync(setupFile, "##########\n"); } - this.assetManager.registerFile(setupFile, "setup/setup.txt", "/root/setup", false, true); + this.assetManager.registerFile(setupFile, "setup/setup.txt", "/root/setup", false); } private changeCurrentDir(targetDir:string, terminalId?: number, isRunning?: boolean):string{ diff --git a/runners/katacoda/katacodaAssetManager.ts b/runners/katacoda/katacodaAssetManager.ts index 9b5f824a..ac265681 100644 --- a/runners/katacoda/katacodaAssetManager.ts +++ b/runners/katacoda/katacodaAssetManager.ts @@ -11,7 +11,7 @@ export class KatacodaAssetManager { this.assetDirectory = assetDir; } - registerFile(filepathSource: string, filepathTarget: string, katacodaDirectory: string, copyFile: boolean, copyIntoKatacodaEnvironment: boolean) { + registerFile(filepathSource: string, filepathTarget: string, katacodaDirectory: string, copyFile: boolean) { this.assetData.push({ sourcePath: filepathSource, targetPath: filepathTarget, @@ -19,7 +19,7 @@ export class KatacodaAssetManager { copyFile: copyFile }); - if(copyIntoKatacodaEnvironment) { + if(filepathTarget && katacodaDirectory) { this.katacodaAssets.push({ file: filepathTarget.replace(/\\/g, "/"), target: katacodaDirectory.replace(/\\/g, "/") @@ -27,13 +27,13 @@ export class KatacodaAssetManager { } } - registerDirectory(directorySource: string, filepathTarget: string, katacodaDirectory: string, copyFile: boolean, copyIntoKatacodaEnvironment: boolean) { + registerDirectory(directorySource: string, filepathTarget: string, katacodaDirectory: string, copyFile: boolean) { let dir = fs.readdirSync(directorySource); dir.forEach(file => { if(fs.lstatSync(path.join(directorySource, file)).isDirectory()) { - this.registerDirectory(path.join(directorySource, file), filepathTarget, katacodaDirectory, copyFile, copyIntoKatacodaEnvironment); + this.registerDirectory(path.join(directorySource, file), filepathTarget, katacodaDirectory, copyFile); } else { - this.registerFile(path.join(directorySource, file), path.join(filepathTarget, file), katacodaDirectory, copyFile, copyIntoKatacodaEnvironment); + this.registerFile(path.join(directorySource, file), path.join(filepathTarget, file), katacodaDirectory, copyFile); } }); }