Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass garbage collection items by values instead of references #440

Merged
merged 1 commit into from
Feb 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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