Skip to content

Commit

Permalink
fix(kube): find current resource by name and kind
Browse files Browse the repository at this point in the history
This resolves #1210. Update will find current resource
by name and kind for comparison purposes.
  • Loading branch information
Michelle Noorali committed Oct 17, 2016
1 parent bb2511a commit a8418dd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit a8418dd

Please sign in to comment.