github.com/crossplane/upjet@v1.3.0/pkg/migration/categorical_steps.go (about) 1 // SPDX-FileCopyrightText: 2023 The Crossplane Authors <https://crossplane.io> 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package migration 6 7 import ( 8 "fmt" 9 10 "github.com/pkg/errors" 11 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 12 ) 13 14 const ( 15 errEditCategory = "failed to put the edited resource of category %q: %s" 16 ) 17 18 func (pg *PlanGenerator) stepEditCategory(source UnstructuredWithMetadata, t *UnstructuredWithMetadata) error { 19 s := pg.stepConfiguration(stepOrphanMRs) 20 t.Metadata.Path = fmt.Sprintf("%s/%s.yaml", s.Name, getVersionedName(t.Object)) 21 s.Patch.Files = append(s.Patch.Files, t.Metadata.Path) 22 patchMap, err := computeJSONMergePathDoc(source.Object, t.Object) 23 if err != nil { 24 return err 25 } 26 return errors.Wrapf(pg.target.Put(UnstructuredWithMetadata{ 27 Object: unstructured.Unstructured{ 28 Object: addNameGVK(t.Object, patchMap), 29 }, 30 Metadata: t.Metadata, 31 }), errEditCategory, source.Metadata.Category, source.Object.GetName()) 32 }