Skip to content

Commit 03f3478

Browse files
committed
Allow kubernetes apiVersion upgrades
Use the API version of the desired state to get current state and then determine the patch from there
1 parent a53c59f commit 03f3478

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

kustomize/resource_kustomization.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ func kustomizationResourceDiff(d *schema.ResourceDiff, m interface{}) error {
190190
return nil
191191
}
192192

193-
srcJSON := originalJSON.(string)
194-
if srcJSON == "" {
193+
desiredJSON := modifiedJSON.(string)
194+
if desiredJSON == "" {
195195
return nil
196196
}
197197

198-
u, err := parseJSON(srcJSON)
198+
u, err := parseJSON(desiredJSON)
199199
if err != nil {
200200
return logError(fmt.Errorf("JSON parse error: %s", err))
201201
}

kustomize/util.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func getOriginalModifiedCurrent(originalJSON string, modifiedJSON string, curren
5050
setLastAppliedConfig(o, originalJSON)
5151
setLastAppliedConfig(n, modifiedJSON)
5252

53-
mapping, err := mapper.RESTMapping(o.GroupVersionKind().GroupKind(), o.GroupVersionKind().Version)
53+
mapping, err := mapper.RESTMapping(n.GroupVersionKind().GroupKind(), n.GroupVersionKind().Version)
5454
if err != nil {
5555
return nil, nil, nil, err
5656
}
@@ -94,7 +94,6 @@ func getPatch(gvk k8sschema.GroupVersionKind, original []byte, modified []byte,
9494
patchType = k8stypes.MergePatchType
9595

9696
preconditions := []mergepatch.PreconditionFunc{
97-
mergepatch.RequireKeyUnchanged("apiVersion"),
9897
mergepatch.RequireKeyUnchanged("kind"),
9998
mergepatch.RequireMetadataKeyUnchanged("name"),
10099
}

0 commit comments

Comments
 (0)