diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 53aa5e1b6..e8a1e0d65 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,62 +13,60 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} repository: ${{github.event.pull_request.head.repo.full_name}} persist-credentials: false - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: 1.19 + go-version-file: ./operators/go.mod - name: Check linting - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4 with: - version: v1.50.1 + version: v1.54 working-directory: operators args: --timeout=600s - gomodtidy: name: Enforce go.mod tidiness runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: "${{ github.event.pull_request.head.sha }}" - repository: ${{github.event.pull_request.head.repo.full_name}} - persist-credentials: false - - - name: Setup Go - uses: actions/setup-go@v3 - with: - go-version: 1.19 - - - name: Execute go mod tidy and check the outcome - working-directory: ./operators - run: | - go mod tidy - exit_code=$(git diff --exit-code) - exit ${exit_code} - - - name: Issue a comment in case the of failure - uses: peter-evans/create-or-update-comment@v2 - with: - token: ${{ secrets.CI_TOKEN }} - issue-number: ${{ github.event.pull_request.number }} - body: | - The `go.mod` and/or `go.sum` files appear not to be correctly tidied. - - Please, rerun `go mod tidy` to fix the issues. - reactions: confused - if: | - failure() && github.event.pull_request.head.repo.full_name == github.repository + - name: Checkout + uses: actions/checkout@v4 + with: + ref: "${{ github.event.pull_request.head.sha }}" + repository: ${{github.event.pull_request.head.repo.full_name}} + persist-credentials: false + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: ./operators/go.mod + - name: Execute go mod tidy and check the outcome + working-directory: ./operators + run: | + go mod tidy + exit_code=$(git diff --exit-code) + exit ${exit_code} + + - name: Issue a comment in case the of failure + uses: peter-evans/create-or-update-comment@v4 + with: + token: ${{ secrets.CI_TOKEN }} + issue-number: ${{ github.event.pull_request.number }} + body: | + The `go.mod` and/or `go.sum` files appear not to be correctly tidied. + + Please, rerun `go mod tidy` to fix the issues. + reactions: confused + if: | + failure() && github.event.pull_request.head.repo.full_name == github.repository python-lint: name: Lint python files @@ -76,7 +74,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} repository: ${{github.event.pull_request.head.repo.full_name}} @@ -85,14 +83,13 @@ jobs: - name: Check linting uses: TrueBrain/actions-flake8@v2 - markdown-lint: name: Lint markdown files (check links validity) runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} repository: ${{github.event.pull_request.head.repo.full_name}} @@ -101,8 +98,7 @@ jobs: - name: Check the validity of the links in the documentation uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 with: - use-quiet-mode: 'yes' - + use-quiet-mode: "yes" shell-lint: name: Lint shell files @@ -110,7 +106,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} repository: ${{github.event.pull_request.head.repo.full_name}} @@ -119,8 +115,7 @@ jobs: - name: Run shellcheck uses: azohra/shell-linter@v0.6.0 with: - exclude-paths: "**/.husky/*-commit" - + exclude-paths: "**/.husky/*-commit" frontend-lint: name: Lint frontend files @@ -128,14 +123,14 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} repository: ${{github.event.pull_request.head.repo.full_name}} persist-credentials: false - name: Setup nodeJS - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 14 @@ -147,21 +142,20 @@ jobs: working-directory: ./frontend run: yarn check-format-lint - qlkube-lint: name: Lint qlkube files runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} repository: ${{github.event.pull_request.head.repo.full_name}} persist-credentials: false - name: Setup nodeJS - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 14 diff --git a/operators/pkg/tenant-controller/sandbox_test.go b/operators/pkg/tenant-controller/sandbox_test.go index 24fc6e7b4..8d8250321 100644 --- a/operators/pkg/tenant-controller/sandbox_test.go +++ b/operators/pkg/tenant-controller/sandbox_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -173,8 +173,8 @@ var _ = Describe("Sandbox", func() { Kind: "Tenant", Name: tenant.Name, UID: tenant.GetUID(), - BlockOwnerDeletion: pointer.Bool(true), - Controller: pointer.Bool(true), + BlockOwnerDeletion: ptr.To[bool](true), + Controller: ptr.To[bool](true), } sandboxNSname = types.NamespacedName{ Name: forge.CanonicalSandboxName(tenantName), diff --git a/operators/pkg/tenant-controller/tenant_controller.go b/operators/pkg/tenant-controller/tenant_controller.go index 94de1efba..5b8908456 100644 --- a/operators/pkg/tenant-controller/tenant_controller.go +++ b/operators/pkg/tenant-controller/tenant_controller.go @@ -191,7 +191,7 @@ func (r *TenantReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr } if err = r.EnforceSandboxResources(ctx, &tn); err != nil { - klog.Error("Failed checking sandbox for tenant %s -> %s", tn.Name, err) + klog.Errorf("Failed checking sandbox for tenant %s -> %s", tn.Name, err) tn.Status.SandboxNamespace.Created = false tnOpinternalErrors.WithLabelValues("tenant", "sandbox-resources").Inc() return ctrl.Result{}, err @@ -334,7 +334,7 @@ func (r *TenantReconciler) checkNamespaceKeepAlive(ctx context.Context, tn *crow // Attempt to get instances in current namespace list := &crownlabsv1alpha2.InstanceList{} - if err := r.List(context.Background(), list, client.InNamespace(nsName)); err != nil { + if err := r.List(ctx, list, client.InNamespace(nsName)); err != nil { return true, err } diff --git a/operators/pkg/tenant-controller/tenant_controller_test.go b/operators/pkg/tenant-controller/tenant_controller_test.go index efa64cef0..34575970b 100644 --- a/operators/pkg/tenant-controller/tenant_controller_test.go +++ b/operators/pkg/tenant-controller/tenant_controller_test.go @@ -279,7 +279,7 @@ var _ = Describe("Tenant controller", func() { }) -func checkTnPVBound(ctx context.Context, tnName, nsName string, timeout, interval time.Duration, serverName, rookCephNamespace, path string) { +func checkTnPVBound(ctx context.Context, tnName string, timeout, interval time.Duration, serverName, rookCephNamespace, path string) { var pvc v1.PersistentVolumeClaim doesEventuallyExists(ctx, types.NamespacedName{Name: myDrivePVCName(tnName), Namespace: testMyDrivePVCsNamespace}, &pvc, BeTrue(), timeout, interval) @@ -432,7 +432,7 @@ func checkTnClusterResourceCreation(ctx context.Context, tnName, nsName string, Expect(createdNetPolAllow.Spec.Ingress[0].From[0].NamespaceSelector.MatchLabels["crownlabs.polito.it/allow-instance-access"]).Should(Equal("true")) By("By checking that the mydrive-info secret of the tenant has been created") - checkTnPVBound(ctx, tnName, nsName, timeout, interval, serverName, rookCephNamespace, path) + checkTnPVBound(ctx, tnName, timeout, interval, serverName, rookCephNamespace, path) By("By checking that the mydrive-info secret of the tenant has been created") NFSSecretLookupKey := types.NamespacedName{Name: NFSSecretName, Namespace: nsName}