Skip to content

Commit

Permalink
merging app if vhostname matches across differetn drove cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmndr committed Dec 5, 2024
1 parent dbabd3a commit 8e43c8f
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/reload.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,42 @@ func createRenderingData(data *RenderingData) {
LeaderVHost: nmData.Drove.LeaderVHost,
Leader: nmData.Leader,
}
//Merging App if already exists
for appId, appData := range nmData.Apps {
allApps[appId] = appData //TODO:fix this
if existingAppData, ok := allApps[appId]; ok {
//Appending hosts
existingAppData.Hosts = append(existingAppData.Hosts, appData.Hosts...)

//adding same as that of app refresh logic
if existingAppData.Tags == nil {
existingAppData.Tags = make(map[string]string)
}

for tagK, tagV := range appData.Tags {
existingAppData.Tags[tagK] = tagV
}

for groupName, groupData := range appData.Groups {
if existingGroup, ok := existingAppData.Groups[groupName]; ok {
existingGroup.Hosts = append(existingGroup.Hosts, groupData.Hosts...)

if existingGroup.Tags == nil {
existingGroup.Tags = make(map[string]string)
}

for tn, tv := range groupData.Tags {
existingGroup.Tags[tn] = tv
}

existingAppData.Groups[groupName] = existingGroup
} else {
existingAppData.Groups[groupName] = groupData
}
}
allApps[appId] = existingAppData
} else {
allApps[appId] = appData
}
}
}
data.Apps = allApps
Expand Down

0 comments on commit 8e43c8f

Please sign in to comment.