forked from ironoa/polkadot-k8s-payouts
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgitConfigLoaderFactory.ts
35 lines (29 loc) · 1.08 KB
/
gitConfigLoaderFactory.ts
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
33
34
35
import { InputConfig } from "../types"
import { Disabled } from "./disabled"
import { GitConfigLoader } from "./gitConfigLoaderInterface"
import { GitHub1kv } from "./gitHub1kv"
import { GitLabPrivate } from "./gitLabPrivate"
import { GitConfigVersion } from "../constants"
export class GitConfigLoaderFactory {
constructor(private readonly cfg: InputConfig){}
makeGitConfigLoaders = (): Array<GitConfigLoader> => {
const gitConfig = this.cfg.targetsFromGit
if(!gitConfig?.enabled)
return [new Disabled()]
const version = gitConfig?.configVersion ? gitConfig.configVersion : GitConfigVersion.V1
const result: Array<GitConfigLoader> = []
for (const target of gitConfig.targets) {
switch (target.platform.toLowerCase()) {
case "github1kv":
result.push(new GitHub1kv(target.url,version))
break;
case "gitlab":
result.push(new GitLabPrivate(target.url,target.private.apiToken,target.network,version))
break;
default:
result.push(new Disabled())
}
}
return result
}
}