Skip to content

Commit

Permalink
fix(sqlinstances): format error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ybelMekk committed Apr 16, 2024
1 parent 311f8b2 commit 2fa719f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/graph/model/sqlinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
})
}
Expand Down Expand Up @@ -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
}

0 comments on commit 2fa719f

Please sign in to comment.