Skip to content

Commit

Permalink
[server]: add replicated as a license type
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Emms committed Feb 15, 2022
1 parent 3ffedc1 commit 30f98c9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions components/server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -57,6 +62,9 @@ export interface ConfigSerialized {
license?: string;
licenseFile?: string;

licenseType?: LicenseType;
LicenseTypeFile?: string; // Value written to file

workspaceHeartbeat: {
intervalSeconds: number;
timeoutSeconds: number,
Expand Down Expand Up @@ -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),
Expand All @@ -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(),
Expand Down

0 comments on commit 30f98c9

Please sign in to comment.