Browse Source

Add porter-application labels to pods along with deployments (#3367)

Feroze Mohideen 2 years ago
parent
commit
62994c598f
1 changed files with 18 additions and 0 deletions
  1. 18 0
      api/server/handlers/porter_app/parse.go

+ 18 - 0
api/server/handlers/porter_app/parse.go

@@ -942,6 +942,24 @@ func addLabelsToService(service *Service, envGroups []string, defaultLabelKey st
 		}
 	}
 
+	if _, ok := service.Config["podLabels"]; !ok {
+		service.Config["podLabels"] = make(map[string]string)
+	}
+	switch service.Config["podLabels"].(type) {
+	case map[string]string:
+		service.Config["podLabels"].(map[string]string)[defaultLabelKey] = porter_app.LabelValue_PorterApplication
+	case map[string]any:
+		service.Config["podLabels"].(map[string]any)[defaultLabelKey] = porter_app.LabelValue_PorterApplication
+	case any:
+		if val, ok := service.Config["podLabels"].(string); ok {
+			if val == "" {
+				service.Config["podLabels"] = map[string]string{
+					defaultLabelKey: porter_app.LabelValue_PorterApplication,
+				}
+			}
+		}
+	}
+
 	return service
 }