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