Skip to content

Commit

Permalink
Instance status improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
krystian-panek-vmltech committed Apr 11, 2024
1 parent cbc6f2f commit ada8259
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion pkg/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,13 @@ func (i Instance) HealthChecks() []string {
continue
}
result := check.Check(i.manager.CheckContext().Value(checkContextKey{}).(CheckContext), i)
resultText := result.Text()
resultText := InstanceTrim(i, result.Text())
if resultText != "" {
messages = append(messages, resultText)
}
if !result.ok && check.Spec().Mandatory {
break
}
}
}
return messages
Expand Down
13 changes: 10 additions & 3 deletions pkg/instance_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,21 @@ func (im *InstanceManager) Await(instances []Instance) error {
return im.AwaitStarted(instances)
}

func InstanceTrim(instance Instance, msgStr string) string {
return strings.Replace(msgStr, InstancePrefix(instance), "", -1)
}

func InstanceMsg(instance Instance, msg any) string {
msgStr := fmt.Sprintf("%v", msg)
instanceIDPrefix := fmt.Sprintf("%s > ", instance.IDColor())
msgStr = strings.Replace(msgStr, instanceIDPrefix, "", -1)
msgStr = instanceIDPrefix + msgStr
msgStr = InstanceTrim(instance, msgStr)
msgStr = InstancePrefix(instance) + msgStr
return msgStr
}

func InstancePrefix(instance Instance) string {
return fmt.Sprintf("%s > ", instance.IDColor())
}

func InstancesMsg(instances []Instance, msg any) string {
count := len(instances)
switch count {
Expand Down

0 comments on commit ada8259

Please sign in to comment.