Skip to content

Commit

Permalink
dev: switch external status to json
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsingerus committed Dec 13, 2024
1 parent aa865f8 commit 4b76438
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/controller/chi/kube/cr.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ package kube

import (
"context"
"encoding/json"
"fmt"
"time"

"gopkg.in/yaml.v3"

core "k8s.io/api/core/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -74,15 +73,15 @@ func (c *CR) buildCR(chi *api.ClickHouseInstallation, cm *core.ConfigMap) *api.C

if len(cm.Data[statusNormalized]) > 0 {
normalized := &api.ClickHouseInstallation{}
if yaml.Unmarshal([]byte(cm.Data[statusNormalized]), normalized) != nil {
if json.Unmarshal([]byte(cm.Data[statusNormalized]), normalized) != nil {
return chi
}
chi.EnsureStatus().NormalizedCR = normalized
}

if len(cm.Data[statusNormalizedCompleted]) > 0 {
normalizedCompleted := &api.ClickHouseInstallation{}
if yaml.Unmarshal([]byte(cm.Data[statusNormalizedCompleted]), normalizedCompleted) != nil {
if json.Unmarshal([]byte(cm.Data[statusNormalizedCompleted]), normalizedCompleted) != nil {
return chi
}
chi.EnsureStatus().NormalizedCRCompleted = normalizedCompleted
Expand Down Expand Up @@ -194,10 +193,10 @@ func (c *CR) statusUpdate(ctx context.Context, chi *api.ClickHouseInstallation)
func (c *CR) buildResources(chi *api.ClickHouseInstallation) (*api.ClickHouseInstallation, *core.ConfigMap) {
var normalized, normalizedCompleted []byte
if chi.Status.NormalizedCR != nil {
normalized, _ = yaml.Marshal(chi.Status.NormalizedCR)
normalized, _ = json.Marshal(chi.Status.NormalizedCR)
}
if chi.Status.NormalizedCRCompleted != nil {
normalizedCompleted, _ = yaml.Marshal(chi.Status.NormalizedCRCompleted)
normalizedCompleted, _ = json.Marshal(chi.Status.NormalizedCRCompleted)
}
cm := &core.ConfigMap{
ObjectMeta: meta.ObjectMeta{
Expand Down

0 comments on commit 4b76438

Please sign in to comment.