Skip to content

Commit

Permalink
Fix golint
Browse files Browse the repository at this point in the history
Signed-off-by: lubronzhan <lubronzhan@gmail.com>

Signed-off-by: lubronzhan <lubronzhan@gmail.com>
  • Loading branch information
lubronzhan committed Jan 17, 2024
1 parent 7ee694d commit 9af0396
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
14 changes: 7 additions & 7 deletions internal/provisioner/objects/rbac/role/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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(),
},
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9af0396

Please sign in to comment.