fix: upgrade using --force shoud not run patch logic

fix helm/helm#7999

Signed-off-by: Liu Ming <hit_oak_tree@126.com>
pull/8000/head
Liu Ming 6 years ago
parent 029922202a
commit a967d8feda

@ -418,6 +418,15 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
kind = target.Mapping.GroupVersionKind.Kind
)
// if --force is applied, attempt to replace the existing resource with the new object.
if force {
var err error
obj, err = helper.Replace(target.Namespace, target.Name, true, target.Object)
if err != nil {
return errors.Wrap(err, "failed to replace object")
}
c.Log("Replaced %q with kind %s for kind %s\n", target.Name, currentObj.GetObjectKind().GroupVersionKind().Kind, kind)
} else {
patch, patchType, err := createPatch(target, currentObj)
if err != nil {
return errors.Wrap(err, "failed to create patch")
@ -432,15 +441,6 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
}
return nil
}
// if --force is applied, attempt to replace the existing resource with the new object.
if force {
obj, err = helper.Replace(target.Namespace, target.Name, true, target.Object)
if err != nil {
return errors.Wrap(err, "failed to replace object")
}
c.Log("Replaced %q with kind %s for kind %s\n", target.Name, currentObj.GetObjectKind().GroupVersionKind().Kind, kind)
} else {
// send patch to server
obj, err = helper.Patch(target.Namespace, target.Name, patchType, patch, nil)
if err != nil {

Loading…
Cancel
Save