@@ -1068,7 +1068,7 @@ func (repman *ReplicationManager) InitConfig(conf config.Config) {
1068
1068
if strClusters == "" {
1069
1069
// Discovering the clusters from all merged conf files build clusterDiscovery map
1070
1070
strClusters = repman .DiscoverClusters (fistRead )
1071
- log .WithField ("clusters" , strClusters ).Debug ( "New clusters discovered" )
1071
+ log .WithField ("clusters" , strClusters ).Infof ( "Clusters discovered: %s" , strClusters )
1072
1072
}
1073
1073
1074
1074
cfgGroupIndex = 0
@@ -1092,82 +1092,81 @@ func (repman *ReplicationManager) InitConfig(conf config.Config) {
1092
1092
// backupvipersave := viper.GetViper()
1093
1093
1094
1094
//if clusters have been discovered
1095
- if strClusters != "" {
1096
- //set cluster list
1097
- repman .ClusterList = strings .Split (strClusters , "," )
1098
- repman .ImmuableFlagMaps ["default" ] = ImmuableMap
1099
- conf .ImmuableFlagMap = ImmuableMap
1100
- //load config file from git hub
1101
- conf .DecryptSecretsFromConfig ()
1102
-
1103
- if conf .GitUrl != "" && conf .GitAccesToken != "" && ! conf .Cloud18 {
1104
- var tok string
1105
-
1106
- if conf .IsVaultUsed () && conf .IsPath (conf .GitAccesToken ) {
1107
- conn , err := conf .GetVaultConnection ()
1108
- if err != nil {
1109
- log .Printf ("Error vault connection %v" , err )
1110
- }
1111
- tok , err = conf .GetVaultCredentials (conn , conf .GitAccesToken , "git-acces-token" )
1112
- if err != nil {
1113
- log .Printf ("Error get vault git-acces-token value %v" , err )
1114
- tok = conf .GetDecryptedValue ("git-acces-token" )
1115
- } else {
1116
- var Secrets config.Secret
1117
- Secrets .Value = tok
1118
- conf .Secrets ["git-acces-token" ] = Secrets
1119
- }
1095
+ if strClusters == "" {
1120
1096
1121
- } else {
1122
- tok = conf .GetDecryptedValue ("git-acces-token" )
1123
- }
1097
+ //add default to the clusterlist if no cluster discover
1098
+ log .WithField ("cluster" , "Default" ).Debug ("No clusters dicoverd add Default Cluster" )
1124
1099
1125
- conf .CloneConfigFromGit (conf .GitUrl , conf .GitUsername , tok , conf .WorkingDir )
1126
- }
1100
+ strClusters += "Default"
1101
+
1102
+ }
1103
+
1104
+ //set cluster list
1105
+ repman .ClusterList = strings .Split (strClusters , "," )
1106
+ repman .ImmuableFlagMaps ["default" ] = ImmuableMap
1107
+ conf .ImmuableFlagMap = ImmuableMap
1108
+ //load config file from git hub
1109
+ conf .DecryptSecretsFromConfig ()
1110
+
1111
+ if conf .GitUrl != "" && conf .GitAccesToken != "" && ! conf .Cloud18 {
1112
+ var tok string
1127
1113
1128
- if conf .Cloud18GitUser != "" && conf .Cloud18GitPassword != "" && conf .Cloud18 {
1129
- acces_tok := githelper .GetGitLabTokenBasicAuth (conf .Cloud18GitUser , conf .GetDecryptedValue ("cloud18-gitlab-password" ), conf .LogGit )
1130
- personal_access_token , _ := githelper .GetGitLabTokenOAuth (acces_tok , conf .LogGit )
1131
- if personal_access_token != "" {
1114
+ if conf .IsVaultUsed () && conf .IsPath (conf .GitAccesToken ) {
1115
+ conn , err := conf .GetVaultConnection ()
1116
+ if err != nil {
1117
+ log .Printf ("Error vault connection %v" , err )
1118
+ }
1119
+ tok , err = conf .GetVaultCredentials (conn , conf .GitAccesToken , "git-acces-token" )
1120
+ if err != nil {
1121
+ log .Printf ("Error get vault git-acces-token value %v" , err )
1122
+ tok = conf .GetDecryptedValue ("git-acces-token" )
1123
+ } else {
1132
1124
var Secrets config.Secret
1133
- Secrets .Value = personal_access_token
1125
+ Secrets .Value = tok
1134
1126
conf .Secrets ["git-acces-token" ] = Secrets
1135
- conf .GitUrl = conf .OAuthProvider + "/" + conf .Cloud18Domain + "/" + conf .Cloud18SubDomain + "-" + conf .Cloud18SubDomainZone + ".git"
1136
- conf .GitUsername = conf .Cloud18GitUser
1137
- conf .GitAccesToken = personal_access_token
1138
- conf .ImmuableFlagMap ["git-url" ] = conf .GitUrl
1139
- conf .ImmuableFlagMap ["git-username" ] = conf .GitUsername
1140
- conf .ImmuableFlagMap ["git-acces-token" ] = personal_access_token
1141
- conf .CloneConfigFromGit (conf .GitUrl , conf .GitUsername , conf .GitAccesToken , conf .WorkingDir )
1142
- conf .PushConfigToGit (conf .GitUrl , conf .GitAccesToken , conf .GitUsername , conf .WorkingDir , []string {})
1143
- //conf.GitAddReadMe(conf.GitUrl, conf.GitAccesToken, conf.GitUsername, conf.WorkingDir)
1144
-
1145
- } else if conf .LogGit {
1146
- log .WithField ("group" , repman .ClusterList [cfgGroupIndex ]).Infof ("Could not get personal access token from gitlab" )
1147
1127
}
1148
1128
1129
+ } else {
1130
+ tok = conf .GetDecryptedValue ("git-acces-token" )
1149
1131
}
1150
1132
1151
- //add config from cluster to the config map
1152
- for _ , cluster := range repman .ClusterList {
1153
- //vipersave := backupvipersave
1154
- confs [cluster ] = repman .GetClusterConfig (fistRead , ImmuableMap , DynamicMap , cluster , conf )
1155
- cfgGroupIndex ++
1156
-
1133
+ conf .CloneConfigFromGit (conf .GitUrl , conf .GitUsername , tok , conf .WorkingDir )
1134
+ }
1135
+
1136
+ if conf .Cloud18GitUser != "" && conf .Cloud18GitPassword != "" && conf .Cloud18 {
1137
+ acces_tok := githelper .GetGitLabTokenBasicAuth (conf .Cloud18GitUser , conf .GetDecryptedValue ("cloud18-gitlab-password" ), conf .LogGit )
1138
+ personal_access_token , _ := githelper .GetGitLabTokenOAuth (acces_tok , conf .LogGit )
1139
+ if personal_access_token != "" {
1140
+ var Secrets config.Secret
1141
+ Secrets .Value = personal_access_token
1142
+ conf .Secrets ["git-acces-token" ] = Secrets
1143
+ conf .GitUrl = conf .OAuthProvider + "/" + conf .Cloud18Domain + "/" + conf .Cloud18SubDomain + "-" + conf .Cloud18SubDomainZone + ".git"
1144
+ conf .GitUsername = conf .Cloud18GitUser
1145
+ conf .GitAccesToken = personal_access_token
1146
+ conf .ImmuableFlagMap ["git-url" ] = conf .GitUrl
1147
+ conf .ImmuableFlagMap ["git-username" ] = conf .GitUsername
1148
+ conf .ImmuableFlagMap ["git-acces-token" ] = personal_access_token
1149
+ conf .CloneConfigFromGit (conf .GitUrl , conf .GitUsername , conf .GitAccesToken , conf .WorkingDir )
1150
+ conf .PushConfigToGit (conf .GitUrl , conf .GitAccesToken , conf .GitUsername , conf .WorkingDir , []string {})
1151
+ //conf.GitAddReadMe(conf.GitUrl, conf.GitAccesToken, conf.GitUsername, conf.WorkingDir)
1152
+
1153
+ } else if conf .LogGit {
1154
+ log .WithField ("group" , repman .ClusterList [cfgGroupIndex ]).Infof ("Could not get personal access token from gitlab" )
1157
1155
}
1158
1156
1159
- cfgGroupIndex --
1160
- log .WithField ("cluster" , repman .ClusterList [cfgGroupIndex ]).Debug ("Default Cluster set" )
1161
-
1162
- } else {
1163
- //add default to the clusterlist if no cluster discover
1164
- repman .ClusterList = append (repman .ClusterList , "Default" )
1165
- log .WithField ("cluster" , repman .ClusterList [cfgGroupIndex ]).Debug ("Default Cluster set" )
1157
+ }
1166
1158
1167
- confs ["Default" ] = conf
1159
+ //add config from cluster to the config map
1160
+ for _ , cluster := range repman .ClusterList {
1161
+ //vipersave := backupvipersave
1162
+ confs [cluster ] = repman .GetClusterConfig (fistRead , ImmuableMap , DynamicMap , cluster , conf )
1163
+ cfgGroupIndex ++
1168
1164
1169
1165
}
1170
1166
1167
+ cfgGroupIndex --
1168
+ log .WithField ("cluster" , repman .ClusterList [cfgGroupIndex ]).Debug ("Default Cluster set" )
1169
+
1171
1170
//fmt.Printf("%+v\n", fistRead.AllSettings())
1172
1171
repman .Confs = confs
1173
1172
repman .Conf = conf
@@ -1703,11 +1702,11 @@ func (repman *ReplicationManager) StartCluster(clusterName string) (*cluster.Clu
1703
1702
myClusterConf .ImmuableFlagMap = repman .ImmuableFlagMaps [clusterName ]
1704
1703
myClusterConf .DynamicFlagMap = repman .DynamicFlagMaps [clusterName ]
1705
1704
myClusterConf .DefaultFlagMap = repman .DefaultFlagMap
1705
+ log .Infof ("Starting cluster: %s workingdir %s" , clusterName , myClusterConf .WorkingDir )
1706
1706
1707
1707
repman .VersionConfs [clusterName ].ConfInit = myClusterConf
1708
1708
//log.Infof("Default config for %s workingdir:\n %v", clusterName, myClusterConf.DefaultFlagMap)
1709
1709
1710
- log .Infof ("Starting cluster: %s workingdir %s" , clusterName , myClusterConf .WorkingDir )
1711
1710
repman .currentCluster .Init (repman .VersionConfs [clusterName ], clusterName , & repman .tlog , & repman .Logs , repman .termlength , repman .UUID , repman .Version , repman .Hostname )
1712
1711
repman .Clusters [clusterName ] = repman .currentCluster
1713
1712
repman .currentCluster .SetCertificate (repman .OpenSVC )
0 commit comments