-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcloud.factory.ts
More file actions
32 lines (27 loc) · 918 Bytes
/
Copy pathcloud.factory.ts
File metadata and controls
32 lines (27 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { ICloudProvider } from "./cloud-provider.interface";
import { AzureProvider } from "./azure.provider";
export class CloudFactory {
private static instance: ICloudProvider;
/**
* Returns a singleton instance of the active cloud provider
*/
public static getProvider(): ICloudProvider {
if (this.instance) {
return this.instance;
}
const providerName = process.env.ACTIVE_CLOUD_PROVIDER || "AZURE";
switch (providerName.toUpperCase()) {
case "AZURE":
this.instance = new AzureProvider();
break;
case "GCP":
throw new Error("GCPProvider is not yet implemented");
case "AWS":
throw new Error("AWSProvider is not yet implemented");
default:
console.warn(`Unknown ACTIVE_CLOUD_PROVIDER: ${providerName}. Falling back to AZURE.`);
this.instance = new AzureProvider();
}
return this.instance;
}
}