Skip to content

Commit

Permalink
feat: ensure all DevWorkspace condition messages are capitalized
Browse files Browse the repository at this point in the history
Fix #1092

Signed-off-by: Horiodino <[email protected]>
  • Loading branch information
Horiodino committed Aug 23, 2024
1 parent ef7b885 commit 76b66f3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion controllers/workspace/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package controllers

import (
"unicode"

dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
corev1 "k8s.io/api/core/v1"

Expand Down Expand Up @@ -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,
}
}
Expand Down Expand Up @@ -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)
}

0 comments on commit 76b66f3

Please sign in to comment.