Skip to content

Commit 7fb1c72

Browse files
committed
refactor: run environment patches in order
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
1 parent 873f26b commit 7fb1c72

File tree

3 files changed

+101
-95
lines changed

3 files changed

+101
-95
lines changed

fn.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,11 @@ func (f *Function) RunFunction(ctx context.Context, req *fnv1beta1.RunFunctionRe
114114
}
115115

116116
if input.Environment != nil {
117-
// Run all patches that are from the (observed) XR to the environment.
118-
if err := RenderToEnvironmentPatches(env, oxr.Resource, input.Environment.Patches); err != nil {
117+
// Run all patches that are from the (observed) XR to the environment or from the environment to the (desired) XR.
118+
if err := RenderEnvironmentPatches(env, oxr.Resource, dxr.Resource, input.Environment.Patches); err != nil {
119119
response.Fatal(rsp, errors.Wrapf(err, "cannot render ToEnvironment patches from the composite resource"))
120120
return rsp, nil
121121
}
122-
123-
// Run all patches that are from the environment to the (desired) XR.
124-
if err := RenderFromEnvironmentPatches(dxr.Resource, env, input.Environment.Patches); err != nil {
125-
response.Fatal(rsp, errors.Wrapf(err, "cannot render FromEnvironment patches to the composite resource"))
126-
return rsp, nil
127-
}
128122
}
129123

130124
// Increment this if you emit a warning result.

0 commit comments

Comments
 (0)