From 30f98c93398ad98c90678caaadda78d7a601ee9b Mon Sep 17 00:00:00 2001 From: Simon Emms Date: Tue, 15 Feb 2022 11:31:11 +0000 Subject: [PATCH] [server]: add replicated as a license type --- components/server/src/config.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/components/server/src/config.ts b/components/server/src/config.ts index 3b5ece134dba26..cab291abf0052e 100644 --- a/components/server/src/config.ts +++ b/components/server/src/config.ts @@ -41,6 +41,11 @@ export interface WorkspaceGarbageCollection { contentChunkLimit: number; } +enum LicenseType { + Legacy = 'legacy', + Replicated = 'replicated', +} + /** * This is the config shape as found in the configuration file, e.g. server-configmap.yaml */ @@ -57,6 +62,9 @@ export interface ConfigSerialized { license?: string; licenseFile?: string; + licenseType?: LicenseType; + LicenseTypeFile?: string; // Value written to file + workspaceHeartbeat: { intervalSeconds: number; timeoutSeconds: number, @@ -195,6 +203,18 @@ export namespace ConfigFile { if (licenseFile) { license = fs.readFileSync(filePathTelepresenceAware(licenseFile), "utf-8"); } + let licenseType = config.licenseType; + const licenseTypeFile = config.LicenseTypeFile; + if (licenseTypeFile) { + // Default to legacy + licenseType = LicenseType.Legacy; + + const licenseTypeFileData = fs.readFileSync(filePathTelepresenceAware(licenseTypeFile), "utf-8") as LicenseType; + if (Object.values(LicenseType).includes(licenseTypeFileData)) { + // Valid licensor type + licenseType = licenseTypeFileData; + } + } return { ...config, stage: translateLegacyStagename(config.stage), @@ -203,6 +223,7 @@ export namespace ConfigFile { builtinAuthProvidersConfigured, chargebeeProviderOptions, license, + licenseType, workspaceGarbageCollection: { ...config.workspaceGarbageCollection, startDate: config.workspaceGarbageCollection.startDate ? new Date(config.workspaceGarbageCollection.startDate).getTime() : Date.now(),