@@ -906,27 +906,27 @@ func detectFileFormat(filename string, data []byte) string {
906906func parseEnvFile (data []byte ) map [string ]interface {} {
907907 config := make (map [string ]interface {})
908908 lines := strings .Split (string (data ), "\n " )
909-
909+
910910 for _ , line := range lines {
911911 line = strings .TrimSpace (line )
912912 if line == "" || strings .HasPrefix (line , "#" ) {
913913 continue
914914 }
915-
915+
916916 parts := strings .SplitN (line , "=" , 2 )
917917 if len (parts ) != 2 {
918918 continue
919919 }
920-
920+
921921 key := strings .TrimSpace (parts [0 ])
922922 value := strings .TrimSpace (parts [1 ])
923-
923+
924924 // Remove quotes if present
925925 if (strings .HasPrefix (value , "\" " ) && strings .HasSuffix (value , "\" " )) ||
926- (strings .HasPrefix (value , "'" ) && strings .HasSuffix (value , "'" )) {
926+ (strings .HasPrefix (value , "'" ) && strings .HasSuffix (value , "'" )) {
927927 value = value [1 : len (value )- 1 ]
928928 }
929-
929+
930930 // Convert common Atlas environment variables to config keys
931931 switch key {
932932 case "ATLAS_PROJECT_ID" :
@@ -952,13 +952,13 @@ func parseEnvFile(data []byte) map[string]interface{} {
952952 }
953953 }
954954 }
955-
955+
956956 return config
957957}
958958
959959func normalizeConfigKeys (config map [string ]interface {}) map [string ]interface {} {
960960 normalized := make (map [string ]interface {})
961-
961+
962962 for key , value := range config {
963963 // Convert various key formats to standard camelCase
964964 normalKey := key
@@ -974,26 +974,26 @@ func normalizeConfigKeys(config map[string]interface{}) map[string]interface{} {
974974 case "public_key" , "public-key" , "pub_key" , "pub-key" , "publickey" :
975975 normalKey = "publicKey"
976976 }
977-
977+
978978 normalized [normalKey ] = value
979979 }
980-
980+
981981 return normalized
982982}
983983
984984func mergeConfigs (existing , source map [string ]interface {}) map [string ]interface {} {
985985 result := make (map [string ]interface {})
986-
986+
987987 // Copy existing config
988988 for key , value := range existing {
989989 result [key ] = value
990990 }
991-
991+
992992 // Overlay source config (source wins conflicts)
993993 for key , value := range source {
994994 result [key ] = value
995995 }
996-
996+
997997 return result
998998}
999999
@@ -1121,7 +1121,7 @@ func detectConfigVersion(config map[string]interface{}) string {
11211121 }
11221122
11231123 // Check for schema indicators to detect version
1124-
1124+
11251125 // v2.0.0+ indicators (current format)
11261126 if _ , hasProjectId := config ["projectId" ]; hasProjectId {
11271127 // Check for new camelCase format
@@ -1147,7 +1147,7 @@ func detectConfigVersion(config map[string]interface{}) string {
11471147
11481148func applyMigrations (config map [string ]interface {}, fromVersion , toVersion string ) (map [string ]interface {}, error ) {
11491149 result := make (map [string ]interface {})
1150-
1150+
11511151 // Copy original config
11521152 for k , v := range config {
11531153 result [k ] = v
@@ -1176,7 +1176,7 @@ func applyMigrations(config map[string]interface{}, fromVersion, toVersion strin
11761176
11771177 // Add version field to migrated config
11781178 result ["version" ] = toVersion
1179-
1179+
11801180 return result , nil
11811181}
11821182
@@ -1189,11 +1189,11 @@ type migration struct {
11891189func shouldApplyMigration (currentVersion , targetVersion , migrationFrom , migrationTo string ) bool {
11901190 // Apply migration if:
11911191 // 1. Current version is at or past the migration starting point
1192- // 2. Target version includes this migration step
1192+ // 2. Target version includes this migration step
11931193 // 3. Current version is before the migration endpoint (to avoid applying migrations we've already done)
1194- return versionLessOrEqual (migrationFrom , currentVersion ) &&
1195- versionLessOrEqual (migrationTo , targetVersion ) &&
1196- versionLess (currentVersion , migrationTo )
1194+ return versionLessOrEqual (migrationFrom , currentVersion ) &&
1195+ versionLessOrEqual (migrationTo , targetVersion ) &&
1196+ versionLess (currentVersion , migrationTo )
11971197}
11981198
11991199func versionLessOrEqual (v1 , v2 string ) bool {
@@ -1210,64 +1210,64 @@ func versionLess(v1, v2 string) bool {
12101210
12111211func migrateV0_9ToV1_0 (config map [string ]interface {}) (map [string ]interface {}, error ) {
12121212 result := make (map [string ]interface {})
1213-
1213+
12141214 // Copy all existing values
12151215 for k , v := range config {
12161216 result [k ] = v
12171217 }
1218-
1218+
12191219 // Add default values that were introduced in v1.0.0
12201220 if _ , exists := result ["timeout" ]; ! exists {
12211221 result ["timeout" ] = "30s"
12221222 }
12231223 if _ , exists := result ["output" ]; ! exists {
12241224 result ["output" ] = "text"
12251225 }
1226-
1226+
12271227 return result , nil
12281228}
12291229
12301230func migrateV1_0ToV1_5 (config map [string ]interface {}) (map [string ]interface {}, error ) {
12311231 result := make (map [string ]interface {})
1232-
1232+
12331233 // Migrate from snake_case to camelCase (partial migration)
12341234 keyMappings := map [string ]string {
12351235 "project_id" : "projectId" ,
1236- "org_id" : "orgId" ,
1236+ "org_id" : "orgId" ,
12371237 "cluster_name" : "clusterName" ,
12381238 "api_key" : "apiKey" ,
12391239 "public_key" : "publicKey" ,
12401240 }
1241-
1241+
12421242 for oldKey , newKey := range keyMappings {
12431243 if value , exists := config [oldKey ]; exists {
12441244 result [newKey ] = value
12451245 }
12461246 }
1247-
1247+
12481248 // Copy other values as-is
12491249 for k , v := range config {
12501250 if _ , isMapped := keyMappings [k ]; ! isMapped {
12511251 result [k ] = v
12521252 }
12531253 }
1254-
1254+
12551255 return result , nil
12561256}
12571257
12581258func migrateV1_5ToV2_0 (config map [string ]interface {}) (map [string ]interface {}, error ) {
12591259 result := make (map [string ]interface {})
1260-
1260+
12611261 // Copy all existing values (v1.5.0 → v2.0.0 is mostly compatible)
12621262 for k , v := range config {
12631263 result [k ] = v
12641264 }
1265-
1265+
12661266 // Ensure all keys are in proper camelCase format
12671267 result = normalizeConfigKeys (result )
1268-
1268+
12691269 // Remove any deprecated keys
12701270 delete (result , "deprecated_field" ) // Example - remove any deprecated fields
1271-
1271+
12721272 return result , nil
12731273}
0 commit comments