diff --git a/internal/graph/model/sqlinstance.go b/internal/graph/model/sqlinstance.go index 0a7245573..3cef26d6d 100644 --- a/internal/graph/model/sqlinstance.go +++ b/internal/graph/model/sqlinstance.go @@ -2,6 +2,7 @@ package model import ( "fmt" + "strings" sql_cnrm_cloud_google_com_v1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/sql/v1beta1" "github.com/nais/api/internal/graph/scalar" @@ -115,7 +116,7 @@ func ToSqlInstance(u *unstructured.Unstructured, env string) (*SQLInstance, erro Type: condition.Type, Status: string(condition.Status), Reason: condition.Reason, - Message: condition.Message, + Message: formatMessage(condition.Message), LastTransitionTime: condition.LastTransitionTime, }) } @@ -171,6 +172,14 @@ func ToSqlInstance(u *unstructured.Unstructured, env string) (*SQLInstance, erro }, nil } +func formatMessage(raw string) string { + gapi := strings.SplitAfter(raw, "googleapi:") + if len(gapi) > 1 { + return strings.ReplaceAll(gapi[1], ",", "") + } + return raw +} + func equals(s *string, eq string) bool { return s != nil && *s == eq }