diff --git a/pkg/app/pipedv1/controller/planner.go b/pkg/app/pipedv1/controller/planner.go index ed2518ef4b..434d948471 100644 --- a/pkg/app/pipedv1/controller/planner.go +++ b/pkg/app/pipedv1/controller/planner.go @@ -15,7 +15,6 @@ package controller import ( - "bytes" "context" "encoding/json" "fmt" @@ -273,8 +272,8 @@ func (p *planner) buildPlan(ctx context.Context, runningDS, targetDS *model.Depl } } - cfg := new(config.GenericApplicationSpec) - if err := json.NewDecoder(bytes.NewReader(targetDS.ApplicationConfig)).Decode(cfg); err != nil { + cfg, err := config.ParseApplication(targetDS.GetApplicationConfig()) + if err != nil { p.logger.Error("unable to parse application config", zap.Error(err)) return nil, err } diff --git a/pkg/configv1/application.go b/pkg/configv1/application.go index a2c49495b1..bb870a6daf 100644 --- a/pkg/configv1/application.go +++ b/pkg/configv1/application.go @@ -15,6 +15,7 @@ package config import ( + "bytes" "encoding/json" "fmt" "os" @@ -593,3 +594,13 @@ func LoadApplication(repoPath, configRelPath string, appKind model.ApplicationKi return &spec, nil } + +// ParseApplication parses the given byte slice into a GenericApplicationSpec. +func ParseApplication(b []byte) (*GenericApplicationSpec, error) { + cfg := new(GenericApplicationSpec) + if err := json.NewDecoder(bytes.NewReader(b)).Decode(cfg); err != nil { + return nil, err + } + + return cfg, nil +}