Skip to content

Commit 20e5771

Browse files
committed
Standardized pod names to lowercase for pod getting because active directory
1 parent 43dd92b commit 20e5771

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

internal/api/handlers/cloning_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func (ch *CloningHandler) GetPodsHandler(c *gin.Context) {
287287

288288
// Loop through the user's deployed pods and add template information
289289
for i := range pods {
290-
templateName := strings.Replace(pods[i].Name[5:], fmt.Sprintf("_%s", username), "", 1)
290+
templateName := strings.Replace(strings.ToLower(pods[i].Name[5:]), fmt.Sprintf("_%s", strings.ToLower(username)), "", 1)
291291
templateInfo, err := ch.Service.DatabaseService.GetTemplateInfo(templateName)
292292
if err != nil {
293293
log.Printf("Error retrieving template info for pod %s: %v", pods[i].Name, err)

internal/api/handlers/dashboard_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (dh *DashboardHandler) GetUserDashboardStatsHandler(c *gin.Context) {
9191

9292
// Loop through the user's deployed pods and add template information
9393
for i := range pods {
94-
templateName := strings.Replace(pods[i].Name[5:], fmt.Sprintf("_%s", username), "", 1)
94+
templateName := strings.Replace(strings.ToLower(pods[i].Name[5:]), fmt.Sprintf("_%s", strings.ToLower(username)), "", 1)
9595
templateInfo, err := dh.cloningHandler.Service.DatabaseService.GetTemplateInfo(templateName)
9696
if err != nil {
9797
log.Printf("Error retrieving template info for pod %s: %v", pods[i].Name, err)

internal/cloning/pods.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (cs *CloningService) GetPods(username string) ([]Pod, error) {
2323

2424
// Build regex pattern to match username or any of their group names
2525
groupsWithUser := append(groups, username)
26-
regexPattern := fmt.Sprintf(`1[0-9]{3}_.*_(%s)`, strings.Join(groupsWithUser, "|"))
26+
regexPattern := fmt.Sprintf(`(?i)1[0-9]{3}_.*_(%s)`, strings.Join(groupsWithUser, "|"))
2727

2828
// Get pods based on regex pattern
2929
pods, err := cs.MapVirtualResourcesToPods(regexPattern)
@@ -87,11 +87,11 @@ func (cs *CloningService) ValidateCloneRequest(templateName string, username str
8787

8888
for _, pod := range podPools {
8989
// Remove the Pod ID number and _ to compare
90-
if !alreadyDeployed && pod.Name[5:] == templateName {
90+
if !alreadyDeployed && strings.EqualFold(pod.Name[5:], templateName) {
9191
alreadyDeployed = true
9292
}
9393

94-
if strings.Contains(pod.Name, username) {
94+
if strings.Contains(strings.ToLower(pod.Name), strings.ToLower(username)) {
9595
numDeployments++
9696
}
9797
}

0 commit comments

Comments
 (0)