@@ -130,41 +130,41 @@ func (th *genericTaskHandler) DoPRMutations(
130130 defer span .End ()
131131
132132 // Update package contents only if the package is in draft state
133- if oldObj .Spec .Lifecycle == porchapi .PackageRevisionLifecycleDraft {
134- apiResources , err := repoPR .GetResources (ctx )
135- if err != nil {
136- return fmt .Errorf ("cannot get package resources: %w" , err )
137- }
138- resources := repository.PackageResources {
139- Contents : apiResources .Spec .Resources ,
140- }
133+ if oldObj .Spec .Lifecycle != porchapi .PackageRevisionLifecycleDraft {
134+ return nil
135+ }
141136
142- newKptfileContent , changed , err := PatchKptfile (ctx , repoPR , newObj )
143- if err != nil {
144- return err
145- }
146- if changed && newKptfileContent != "" && newKptfileContent != "{} \n " {
147- resources . Contents [ kptfilev1 . KptFileName ] = newKptfileContent
148- }
137+ apiResources , err := repoPR . GetResources (ctx )
138+ if err != nil {
139+ return fmt . Errorf ( "cannot get package resources: %w" , err )
140+ }
141+ resources := repository. PackageResources {
142+ Contents : apiResources . Spec . Resources ,
143+ }
149144
150- // render
151- draftMeta := draft . GetMeta ()
152- resources , _ , err = th . renderMutation ( draftMeta . GetNamespace ()). apply ( ctx , resources )
153- if err != nil {
154- klog . Error ( err )
155- return renderError ( err )
156- }
145+ newKptfileContent , changed , err := PatchKptfile ( ctx , repoPR , newObj )
146+ if err != nil {
147+ return err
148+ }
149+ if changed && newKptfileContent != "" && newKptfileContent != "{} \n " {
150+ resources . Contents [ kptfilev1 . KptFileName ] = newKptfileContent
151+ }
157152
158- prr := & porchapi.PackageRevisionResources {
159- Spec : porchapi.PackageRevisionResourcesSpec {
160- Resources : resources .Contents ,
161- },
162- }
153+ // render
154+ draftMeta := draft .GetMeta ()
155+ resources , _ , err = th .renderMutation (draftMeta .GetNamespace ()).apply (ctx , resources )
156+ if err != nil {
157+ klog .Error (err )
158+ return renderError (err )
159+ }
163160
164- return draft .UpdateResources (ctx , prr , & porchapi.Task {Type : porchapi .TaskTypeRender })
161+ prr := & porchapi.PackageRevisionResources {
162+ Spec : porchapi.PackageRevisionResourcesSpec {
163+ Resources : resources .Contents ,
164+ },
165165 }
166166
167- return nil
167+ return draft . UpdateResources ( ctx , prr , & porchapi. Task { Type : porchapi . TaskTypeRender })
168168}
169169
170170func (th * genericTaskHandler ) DoPRResourceMutations (
0 commit comments