marshal with struct

This commit is contained in:
Felix Kunde 2019-05-02 17:02:33 +02:00
parent d5a578940f
commit db28339ad3
2 changed files with 9 additions and 4 deletions

View File

@ -102,5 +102,5 @@ func (postgresStatus PostgresStatus) Creating() bool {
}
func (postgresStatus PostgresStatus) String() string {
return fmt.Sprintf(`{"status":{"PostgresClusterStatus": %s}}`, string(postgresStatus.PostgresClusterStatus))
return postgresStatus.PostgresClusterStatus
}

View File

@ -149,10 +149,15 @@ func (c *Cluster) setProcessName(procName string, args ...interface{}) {
}
// SetStatus of Postgres cluster
func (c *Cluster) setStatus(status string) {
c.logger.Debugf("updating status to %s", status)
// TODO: eventually switch to updateStatus() for kubernetes 1.11 and above
patch, err := json.Marshal(acidv1.PostgresStatus{PostgresClusterStatus: status}.String())
func (c *Cluster) setStatus(status string) {
var pgStatus acidv1.PostgresStatus
pgStatus.PostgresClusterStatus = status
patch, err := json.Marshal(struct {
PgStatus interface{} `json:"status"`
}{&pgStatus})
if err != nil {
c.logger.Errorf("could not marshal status: %v", err)
}