Skip to content

Commit

Permalink
fix: Remove empty keys when merging unstructured resources
Browse files Browse the repository at this point in the history
When merging client-side and server-side patches for diffing, we need to remove
any empty/removed keys from the server-side patch in the client-side patch as well.

Fixes: #2331
  • Loading branch information
rquitales committed Mar 8, 2023
1 parent 3157468 commit 79fe424
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion provider/pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,10 @@ func (k *kubeProvider) Diff(ctx context.Context, req *pulumirpc.DiffRequest) (*p
// with the server-side values.
if ssPatchOk {
logger.V(1).Infof("calculated diffs for %s/%s using dry-run and inputs", newInputs.GetNamespace(), newInputs.GetName())
err = mergo.Merge(&patchBase, ssPatchBase, mergo.WithOverride)
// Merge the server-side patch into the client-side patch, and ensure that any fields that are set to null in the
// server-side patch are set to null in the client-side patch.
// Also requires https://github.com/imdario/mergo/pull/231 to be merged and picked up by pulumi-kubernetes.
err = mergo.Merge(&patchBase, ssPatchBase, mergo.WithOverwriteWithEmptyValue)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 79fe424

Please sign in to comment.