From 95f96bceb1684aac1745f6045dff88b13ef2b101 Mon Sep 17 00:00:00 2001 From: ezmcdja Date: Tue, 10 Dec 2024 15:44:59 +0000 Subject: [PATCH] Issue #615 - have PackageVariant set readiness gate on PackageRevisions - PackageVariant controller now uses a readiness gate to allow a PackageRevision to complete its mutation pipeline before it is allowed to be proposed/approved - refactored conversion of Kptfiles to YAML since readiness condition information is stored in the package Kptfile - unified all cases to the same kyaml/yaml-based method (KptFile.ToYamlString() and ToYamlString(*fn.KubeObject)) - this ensures consistency in the YAML (indentation, field order etc.) - and reduces the chances of Git conflicts when setting and updating readiness conditions - added more info to error message in case of Git conflict when applying a patch https://github.com/nephio-project/nephio/issues/615 --- pkg/task/generictaskhandler.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/task/generictaskhandler.go b/pkg/task/generictaskhandler.go index 3454882b..287d1576 100644 --- a/pkg/task/generictaskhandler.go +++ b/pkg/task/generictaskhandler.go @@ -18,6 +18,7 @@ import ( "context" "fmt" + sdkfn "github.com/GoogleContainerTools/kpt-functions-sdk/go/fn" api "github.com/nephio-project/porch/api/porch/v1alpha1" configapi "github.com/nephio-project/porch/api/porchconfig/v1alpha1" "github.com/nephio-project/porch/internal/kpt/builtins" @@ -527,6 +528,17 @@ func healConfig(old, new map[string]string) (map[string]string, error) { healed := out.output.Contents + var kptfileKubeObject *sdkfn.KubeObject + if kptfileKubeObject, err = sdkfn.ParseKubeObject([]byte(healed[kptfile.KptFileName])); err != nil { + return nil, err + } + + kptfileYaml, err := kptfile.ToYamlString(kptfileKubeObject) + if err != nil { + return nil, err + } + healed[kptfile.KptFileName] = kptfileYaml + for k, v := range extra { healed[k] = v }