Skip to content

Commit

Permalink
capitalizeMsg function to correctly capitalize the first character an…
Browse files Browse the repository at this point in the history
…d handle error scenarios

Signed-off-by: Horiodino <[email protected]>
  • Loading branch information
Horiodino committed Jun 21, 2024
1 parent ef7b885 commit e758926
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 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: capitalizeMsg(msg),
Reason: reason,
}
}
Expand Down Expand Up @@ -130,3 +132,12 @@ func getConditionIndexInOrder(condType dw.DevWorkspaceConditionType) int {
}
return -1
}

func capitalizeMsg(msg string) string {
if len(msg) == 0 {
return msg
}
runes := []rune(msg)
runes[0] = unicode.ToUpper(runes[0])
return string(runes)
}

0 comments on commit e758926

Please sign in to comment.