From 9af0396537e342dac7390b9d45e43c0862f60ce4 Mon Sep 17 00:00:00 2001 From: lubronzhan Date: Tue, 16 Jan 2024 20:45:19 -0800 Subject: [PATCH] Fix golint Signed-off-by: lubronzhan Signed-off-by: lubronzhan --- .github/workflows/prbuild.yaml | 2 +- internal/provisioner/objects/rbac/role/role.go | 14 +++++++------- .../objects/rbac/rolebinding/role_binding.go | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/prbuild.yaml b/.github/workflows/prbuild.yaml index ed0c0d1c80b..49bad1299dd 100644 --- a/.github/workflows/prbuild.yaml +++ b/.github/workflows/prbuild.yaml @@ -32,7 +32,7 @@ jobs: version: v1.55.2 # TODO: re-enable linting tools package once https://github.com/projectcontour/contour/issues/5077 # is resolved - args: --build-tags=e2e,conformance,gcp,oidc,none + args: --build-tags=e2e,conformance,gcp,oidc,none --out-${NO_FUTURE}format=colored-line-number - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f # v2.0.0 with: status: ${{ job.status }} diff --git a/internal/provisioner/objects/rbac/role/role.go b/internal/provisioner/objects/rbac/role/role.go index 1277cd3d005..46fa48d54d1 100644 --- a/internal/provisioner/objects/rbac/role/role.go +++ b/internal/provisioner/objects/rbac/role/role.go @@ -36,7 +36,7 @@ func EnsureControllerRole(ctx context.Context, cli client.Client, name string, c desired := desiredControllerRole(name, contour) updater := func(ctx context.Context, cli client.Client, current, desired *rbacv1.Role) error { - _, err := updateRoleIfNeeded(ctx, cli, contour, current, desired) + err := updateRoleIfNeeded(ctx, cli, contour, current, desired) return err } @@ -53,7 +53,7 @@ func EnsureRolesInNamespaces(ctx context.Context, cli client.Client, name string desired := desiredRoleForContourInNamespace(name, ns, contour) updater := func(ctx context.Context, cli client.Client, current, desired *rbacv1.Role) error { - _, err := updateRoleIfNeeded(ctx, cli, contour, current, desired) + err := updateRoleIfNeeded(ctx, cli, contour, current, desired) return err } if err := objects.EnsureObject(ctx, cli, desired, updater, &rbacv1.Role{}); err != nil { @@ -104,7 +104,7 @@ func desiredRoleForContourInNamespace(name, namespace string, contour *model.Con }, ObjectMeta: metav1.ObjectMeta{ Name: name, - Namespace: contour.Namespace, + Namespace: namespace, Labels: contour.CommonLabels(), Annotations: contour.CommonAnnotations(), }, @@ -114,15 +114,15 @@ func desiredRoleForContourInNamespace(name, namespace string, contour *model.Con // updateRoleIfNeeded updates a Role resource if current does not match desired, // using contour to verify the existence of owner labels. -func updateRoleIfNeeded(ctx context.Context, cli client.Client, contour *model.Contour, current, desired *rbacv1.Role) (*rbacv1.Role, error) { +func updateRoleIfNeeded(ctx context.Context, cli client.Client, contour *model.Contour, current, desired *rbacv1.Role) error { if labels.AnyExist(current, model.OwnerLabels(contour)) { role, updated := equality.RoleConfigChanged(current, desired) if updated { if err := cli.Update(ctx, role); err != nil { - return nil, fmt.Errorf("failed to update cluster role %s/%s: %w", role.Namespace, role.Name, err) + return fmt.Errorf("failed to update cluster role %s/%s: %w", role.Namespace, role.Name, err) } - return role, nil + return nil } } - return current, nil + return nil } diff --git a/internal/provisioner/objects/rbac/rolebinding/role_binding.go b/internal/provisioner/objects/rbac/rolebinding/role_binding.go index 104b1331ecf..edf63fac366 100644 --- a/internal/provisioner/objects/rbac/rolebinding/role_binding.go +++ b/internal/provisioner/objects/rbac/rolebinding/role_binding.go @@ -54,7 +54,8 @@ func EnsureRoleBindingsInNamespaces(ctx context.Context, cli client.Client, name updater := func(ctx context.Context, cli client.Client, current, desired *rbacv1.RoleBinding) error { return updateRoleBindingIfNeeded(ctx, cli, contour, current, desired) } - objects.EnsureObject(ctx, cli, desired, updater, &rbacv1.RoleBinding{}) + err := objects.EnsureObject(ctx, cli, desired, updater, &rbacv1.RoleBinding{}) + errs = append(errs, err) } return kerrors.NewAggregate(errs)