Skip to content

Commit

Permalink
misc: fix hypothetical implicit memory aliasing
Browse files Browse the repository at this point in the history
Signed-off-by: Hidde Beydals <[email protected]>
  • Loading branch information
hiddeco committed Oct 17, 2023
1 parent 5a2f98a commit 30fcaa2
Showing 1 changed file with 40 additions and 20 deletions.
60 changes: 40 additions & 20 deletions pkg/uninstall/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ func Components(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list appsv1.DeploymentList
if err := kubeClient.List(ctx, &list, client.InNamespace(namespace), selector); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
if err := kubeClient.Delete(ctx, &r, opts); err != nil {
logger.Failuref("Deployment/%s/%s deletion failed: %s", r.Namespace, r.Name, err.Error())
aggregateErr = append(aggregateErr, err)
Expand All @@ -61,7 +62,8 @@ func Components(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list corev1.ServiceList
if err := kubeClient.List(ctx, &list, client.InNamespace(namespace), selector); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
if err := kubeClient.Delete(ctx, &r, opts); err != nil {
logger.Failuref("Service/%s/%s deletion failed: %s", r.Namespace, r.Name, err.Error())
aggregateErr = append(aggregateErr, err)
Expand All @@ -74,7 +76,8 @@ func Components(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list networkingv1.NetworkPolicyList
if err := kubeClient.List(ctx, &list, client.InNamespace(namespace), selector); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
if err := kubeClient.Delete(ctx, &r, opts); err != nil {
logger.Failuref("NetworkPolicy/%s/%s deletion failed: %s", r.Namespace, r.Name, err.Error())
aggregateErr = append(aggregateErr, err)
Expand All @@ -87,7 +90,8 @@ func Components(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list corev1.ServiceAccountList
if err := kubeClient.List(ctx, &list, client.InNamespace(namespace), selector); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
if err := kubeClient.Delete(ctx, &r, opts); err != nil {
logger.Failuref("ServiceAccount/%s/%s deletion failed: %s", r.Namespace, r.Name, err.Error())
aggregateErr = append(aggregateErr, err)
Expand All @@ -100,7 +104,8 @@ func Components(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list rbacv1.ClusterRoleList
if err := kubeClient.List(ctx, &list, selector); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
if err := kubeClient.Delete(ctx, &r, opts); err != nil {
logger.Failuref("ClusterRole/%s deletion failed: %s", r.Name, err.Error())
aggregateErr = append(aggregateErr, err)
Expand All @@ -113,7 +118,8 @@ func Components(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list rbacv1.ClusterRoleBindingList
if err := kubeClient.List(ctx, &list, selector); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
if err := kubeClient.Delete(ctx, &r, opts); err != nil {
logger.Failuref("ClusterRoleBinding/%s deletion failed: %s", r.Name, err.Error())
aggregateErr = append(aggregateErr, err)
Expand All @@ -134,7 +140,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list sourcev1.GitRepositoryList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -148,7 +155,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list sourcev1b2.OCIRepositoryList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -162,7 +170,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list sourcev1b2.HelmRepositoryList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -176,7 +185,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list sourcev1b2.HelmChartList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -190,7 +200,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list sourcev1b2.BucketList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -204,7 +215,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list kustomizev1.KustomizationList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -218,7 +230,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list helmv2.HelmReleaseList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -232,7 +245,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list notificationv1b2.AlertList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -246,7 +260,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list notificationv1b2.ProviderList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -260,7 +275,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list notificationv1.ReceiverList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -274,7 +290,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list imagev1.ImagePolicyList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -288,7 +305,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list imagev1.ImageRepositoryList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -302,7 +320,8 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
{
var list autov1.ImageUpdateAutomationList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
r.Finalizers = []string{}
if err := kubeClient.Update(ctx, &r, opts); err != nil {
logger.Failuref("%s/%s/%s removing finalizers failed: %s", r.Kind, r.Namespace, r.Name, err.Error())
Expand All @@ -324,7 +343,8 @@ func CustomResourceDefinitions(ctx context.Context, logger log.Logger, kubeClien
{
var list apiextensionsv1.CustomResourceDefinitionList
if err := kubeClient.List(ctx, &list, selector); err == nil {
for _, r := range list.Items {
for i := range list.Items {
r := list.Items[i]
if err := kubeClient.Delete(ctx, &r, opts); err != nil {
logger.Failuref("CustomResourceDefinition/%s deletion failed: %s", r.Name, err.Error())
aggregateErr = append(aggregateErr, err)
Expand Down

0 comments on commit 30fcaa2

Please sign in to comment.