From 76b66f39d5d4f6371816fab56d1ccf59d770051b Mon Sep 17 00:00:00 2001 From: Horiodino Date: Fri, 21 Jun 2024 14:50:39 +0530 Subject: [PATCH] feat: ensure all DevWorkspace condition messages are capitalized Fix #1092 Signed-off-by: Horiodino --- controllers/workspace/condition.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/controllers/workspace/condition.go b/controllers/workspace/condition.go index 58da14794..d578b90c7 100644 --- a/controllers/workspace/condition.go +++ b/controllers/workspace/condition.go @@ -16,6 +16,8 @@ package controllers import ( + "unicode" + dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" corev1 "k8s.io/api/core/v1" @@ -65,7 +67,7 @@ func (c *workspaceConditions) setConditionTrueWithReason(conditionType dw.DevWor c.conditions[conditionType] = dw.DevWorkspaceCondition{ Status: corev1.ConditionTrue, - Message: msg, + Message: capitalizeMessage(msg), Reason: reason, } } @@ -130,3 +132,13 @@ func getConditionIndexInOrder(condType dw.DevWorkspaceConditionType) int { } return -1 } + +// Capitalizes the first character in the given string. +func capitalizeMessage(msg string) string { + if msg == "" { + return msg + } + runes := []rune(msg) + runes[0] = unicode.ToUpper(runes[0]) + return string(runes) +}