Commit d744a3d0 authored by Michelle Noorali's avatar Michelle Noorali Committed by GitHub

Merge pull request #1385 from michelleN/check-upgrade-kind

fix(kube): find current resource by name and kind
parents d631328a a8418dd7
......@@ -176,6 +176,7 @@ func (c *Client) Update(namespace string, currentReader, targetReader io.Reader)
return err
}
resourceName := info.Name
resourceKind := info.Mapping.GroupVersionKind.Kind
helper := resource.NewHelper(info.Client, info.Mapping)
if _, err := helper.Get(info.Namespace, resourceName, info.Export); err != nil {
......@@ -193,7 +194,7 @@ func (c *Client) Update(namespace string, currentReader, targetReader io.Reader)
return nil
}
currentObj, err := getCurrentObject(resourceName, currentInfos)
currentObj, err := getCurrentObject(resourceName, resourceKind, currentInfos)
if err != nil {
return err
}
......@@ -453,10 +454,11 @@ func deleteUnwantedResources(currentInfos, targetInfos []*resource.Info) {
}
}
func getCurrentObject(targetName string, infos []*resource.Info) (runtime.Object, error) {
func getCurrentObject(targetName, targetKind string, infos []*resource.Info) (runtime.Object, error) {
var curr *resource.Info
for _, currInfo := range infos {
if currInfo.Name == targetName {
currKind := currInfo.Mapping.GroupVersionKind.Kind
if currInfo.Name == targetName && currKind == targetKind {
curr = currInfo
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment