-
Notifications
You must be signed in to change notification settings - Fork 12
/
config.go
160 lines (139 loc) · 5.16 KB
/
config.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
Copyright (C) 2021-2023, Kubefirst
This program is licensed under MIT.
See the LICENSE file for more details.
*/
package vultr
import (
"fmt"
"os"
"runtime"
"github.com/kubefirst/runtime/pkg"
"github.com/rs/zerolog/log"
)
const (
CloudProvider = "vultr"
GithubHost = "github.com"
GitlabHost = "gitlab.com"
KubectlClientVersion = "v1.25.7"
LocalhostOS = runtime.GOOS
LocalhostArch = runtime.GOARCH
TerraformClientVersion = "1.3.8"
ArgocdHelmChartVersion = "4.10.5"
ArgocdPortForwardURL = pkg.ArgocdPortForwardURL
VaultPortForwardURL = pkg.VaultPortForwardURL
)
type VultrConfig struct {
VultrToken string
GithubToken string
GitlabToken string
ArgoWorkflowsDir string
DestinationGitopsRepoHttpsURL string
DestinationGitopsRepoGitURL string
DestinationMetaphorRepoHttpsURL string
DestinationMetaphorRepoGitURL string
GitopsDir string
GitProvider string
K1Dir string
Kubeconfig string
KubectlClient string
KubefirstBotSSHPrivateKey string
KubefirstConfig string
LogsDir string
MetaphorDir string
RegistryAppName string
RegistryYaml string
SSLBackupDir string
TerraformClient string
ToolsDir string
}
// GetConfig - load default values from kubefirst installer
func GetConfig(clusterName string, domainName string, gitProvider string, gitOwner string) *VultrConfig {
config := VultrConfig{}
homeDir, err := os.UserHomeDir()
if err != nil {
log.Fatal().Msgf("something went wrong getting home path: %s", err)
}
// cGitHost describes which git host to use depending on gitProvider
var cGitHost string
switch gitProvider {
case "github":
cGitHost = GithubHost
case "gitlab":
cGitHost = GitlabHost
}
config.DestinationGitopsRepoHttpsURL = fmt.Sprintf("https://%s/%s/gitops.git", cGitHost, gitOwner)
config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@%s:%s/gitops.git", cGitHost, gitOwner)
config.DestinationMetaphorRepoHttpsURL = fmt.Sprintf("https://%s/%s/metaphor.git", cGitHost, gitOwner)
config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@%s:%s/metaphor.git", cGitHost, gitOwner)
config.ArgoWorkflowsDir = fmt.Sprintf("%s/.k1/%s/argo-workflows", homeDir, clusterName)
config.GitopsDir = fmt.Sprintf("%s/.k1/%s/gitops", homeDir, clusterName)
config.GitProvider = gitProvider
config.Kubeconfig = fmt.Sprintf("%s/.k1/%s/kubeconfig", homeDir, clusterName)
config.K1Dir = fmt.Sprintf("%s/.k1/%s", homeDir, clusterName)
config.KubectlClient = fmt.Sprintf("%s/.k1/%s/tools/kubectl", homeDir, clusterName)
config.KubefirstConfig = fmt.Sprintf("%s/.k1/%s/%s", homeDir, clusterName, ".kubefirst")
config.LogsDir = fmt.Sprintf("%s/.k1/%s/logs", homeDir, clusterName)
config.MetaphorDir = fmt.Sprintf("%s/.k1/%s/metaphor", homeDir, clusterName)
config.RegistryAppName = "registry"
config.RegistryYaml = fmt.Sprintf("%s/.k1/%s/gitops/registry/%s/registry.yaml", homeDir, clusterName, clusterName)
config.SSLBackupDir = fmt.Sprintf("%s/.k1/%s/ssl/%s", homeDir, clusterName, domainName)
config.TerraformClient = fmt.Sprintf("%s/.k1/%s/tools/terraform", homeDir, clusterName)
config.ToolsDir = fmt.Sprintf("%s/.k1/%s/tools", homeDir, clusterName)
return &config
}
type GitOpsDirectoryValues struct {
AlertsEmail string
AtlantisAllowList string
CloudProvider string
CloudRegion string
ClusterId string
ClusterName string
ClusterType string
DomainName string
KubeconfigPath string
KubefirstStateStoreBucket string
KubefirstTeam string
KubefirstVersion string
StateStoreBucketHostname string
ArgoCDIngressURL string
ArgoCDIngressNoHTTPSURL string
ArgoWorkflowsIngressURL string
ArgoWorkflowsIngressNoHTTPSURL string
ArgoWorkflowsDir string
AtlantisIngressURL string
AtlantisIngressNoHTTPSURL string
ChartMuseumIngressURL string
VaultIngressURL string
VaultIngressNoHTTPSURL string
VouchIngressURL string
GitDescription string
GitNamespace string
GitProvider string
GitRunner string
GitRunnerDescription string
GitRunnerNS string
GitURL string
GitHubHost string
GitHubOwner string
GitHubUser string
GitlabHost string
GitlabOwner string
GitlabOwnerGroupID int
GitlabUser string
GitOpsRepoAtlantisWebhookURL string
GitOpsRepoGitURL string
GitOpsRepoNoHTTPSURL string
UseTelemetry string
}
type MetaphorTokenValues struct {
CheckoutCWFTTemplate string
CloudRegion string
ClusterName string
CommitCWFTTemplate string
ContainerRegistryURL string
DomainName string
MetaphorDevelopmentIngressURL string
MetaphorProductionIngressURL string
MetaphorStagingIngressURL string
}