Skip to content

Commit

Permalink
Pass garbage collection items by values instead of references
Browse files Browse the repository at this point in the history
  • Loading branch information
astefanutti authored and lburgazzoli committed Feb 15, 2019
1 parent cc7735d commit 86c42bd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/trait/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (t *garbageCollectorTrait) Apply(e *Environment) error {
}
// And delete them
for _, resource := range resources {
err = e.Client.Delete(context.TODO(), resource)
err = e.Client.Delete(context.TODO(), &resource)
if err != nil {
// The resource may have already been deleted
if !k8serrors.IsNotFound(err) {
Expand All @@ -99,7 +99,7 @@ func (t *garbageCollectorTrait) Apply(e *Environment) error {
return nil
}

func getOldGenerationResources(e *Environment) ([]*unstructured.Unstructured, error) {
func getOldGenerationResources(e *Environment) ([]unstructured.Unstructured, error) {
// We rely on the discovery API to retrieve all the resources group and kind.
// That results in an unbounded collection that can be a bit slow (a couple of seconds).
// We may want to refine that step by white-listing or enlisting types to speed-up
Expand All @@ -114,7 +114,7 @@ func getOldGenerationResources(e *Environment) ([]*unstructured.Unstructured, er
return nil, err
}

res := make([]*unstructured.Unstructured, 0)
res := make([]unstructured.Unstructured, 0)

for _, t := range types {
options := k8sclient.ListOptions{
Expand All @@ -139,7 +139,7 @@ func getOldGenerationResources(e *Environment) ([]*unstructured.Unstructured, er
return nil, err
}
for _, item := range list.Items {
res = append(res, &item)
res = append(res, item)
}
}
return res, nil
Expand Down

0 comments on commit 86c42bd

Please sign in to comment.