-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cluster clients are created as needed
- Loading branch information
1 parent
b40b603
commit 4e734f6
Showing
2 changed files
with
25 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
'use strict'; | ||
"use strict"; | ||
|
||
const gke = require('./gke.js') | ||
const kubeception = require('./kubeception.js') | ||
const gke = require("./gke.js"); | ||
const kubeception = require("./kubeception.js"); | ||
|
||
const CLUSTER_NAME = 'CLUSTER_NAME' | ||
const clusterZone = 'us-central1-b' | ||
const CLUSTER_NAME = "CLUSTER_NAME"; | ||
const clusterZone = "us-central1-b"; | ||
|
||
const distributions = { | ||
"gke": new gke.Client(clusterZone), | ||
"kubeception": new kubeception.Client(kubeception.getHttpClient()) | ||
} | ||
const DistributionType = { | ||
GKE: "gke", | ||
KUBECEPTION: "kubeception", | ||
}; | ||
|
||
function getProvider(distribution) { | ||
let result = distributions[distribution.toLowerCase()] | ||
if (typeof result === typeof undefined) { | ||
throw new Error(`unknown distribution: ${distribution}`) | ||
const lowerCaseDistribution = distribution.toLowerCase(); | ||
|
||
switch (lowerCaseDistribution) { | ||
case DistributionType.GKE: | ||
return new gke.Client(clusterZone); | ||
case DistributionType.KUBECEPTION: | ||
return new kubeception.Client(kubeception.getHttpClient()); | ||
default: | ||
throw new Error(`unknown distribution: ${distribution}`); | ||
} | ||
return result | ||
} | ||
|
||
module.exports = { | ||
getProvider, | ||
CLUSTER_NAME | ||
} | ||
CLUSTER_NAME, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters