Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Morales committed Feb 13, 2025
1 parent d7477d7 commit 45950e4
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 19 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ name: Lint Code Base
on:
push:
pull_request:
permissions: read-all
jobs:
get-sloc:
name: Count Lines of Code
Expand Down Expand Up @@ -42,7 +43,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: /
VALIDATE_CHECKOV: false
VALIDATE_GOOGLE_JAVA_FORMAT: false
VALIDATE_JAVA: false
VALIDATE_KUBERNETES_KUBECONFORM: false
VALIDATE_GO: false
1 change: 1 addition & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
schedule:
- cron: "0 0 * * 5"
workflow_dispatch:
permissions: read-all
jobs:
check-versions:
permissions:
Expand Down
24 changes: 15 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,28 @@ linters:
enable-all: true
disable:
- exportloopref # Deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar.
- gomnd # Deprecated (since v1.58.0) due to: The linter has been renamed. Replaced by mnd.
- execinquery # Deprecated (since v1.58.0) due to: The repository of the linter has been archived by the owner.
- exhaustruct
linters-settings:
depguard:
rules:
prevent_unmaintained_packages:
list-mode: lax # allow unless explicitely denied
files:
- $all
- "!$test"
allow:
- $gostd
deny:
- pkg: io/ioutil
desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"
- github.com/electrocucaracha/kubevirt-actions-runner/cmd/kar/app
- github.com/electrocucaracha/kubevirt-actions-runner/internal
- github.com/golang/mock/gomock
- github.com/pkg/errors
- github.com/spf13/cobra
- github.com/spf13/pflag
- github.com/spf13/viper
- k8s.io/api/core/v1
- k8s.io/apimachinery/pkg/apis/meta/v1
- k8s.io/utils/ptr
- kubevirt.io/api/core/v1
- kubevirt.io/client-go/containerizeddataimporter/fake
- kubevirt.io/client-go/kubecli
- kubevirt.io/client-go/kubevirt/fake
- kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1
gomoddirectives:
replace-allow-list:
- k8s.io/kube-openapi
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ lint:
sudo -E $(DOCKER_CMD) run --rm -v $$(pwd):/tmp/lint \
-e RUN_LOCAL=true \
-e LINTER_RULES_PATH=/ \
-e VALIDATE_KUBERNETES_KUBEVAL=false \
-e KUBERNETES_KUBECONFORM_OPTIONS='-ignore-missing-schemas' \
-e VALIDATE_GO=false \
ghcr.io/super-linter/super-linter

.PHONY: fmt
Expand Down
1 change: 1 addition & 0 deletions cmd/kar/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func run(ctx context.Context, runner runner.Runner, opts Opts) error {
if err := runner.CreateResources(ctx, opts.VMTemplate, opts.RunnerName, opts.JitConfig); err != nil {
return errors.Wrap(err, "fail to create resources")
}

if err := runner.WaitForVirtualMachineInstance(ctx, runner.GetVMIName()); err != nil {
return errors.Wrap(err, "fail to wait for resources")
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/kar/app/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package app_test
import (
"context"
"errors"

"slices"

"github.com/electrocucaracha/kubevirt-actions-runner/cmd/kar/app"
Expand Down Expand Up @@ -96,14 +95,15 @@ var _ = Describe("Root Command", func() {

DescribeTable("initialization process", func(shouldSucceed bool, failure Failure, args ...string) {
cmd.SetArgs(args)
expectedFailure := errors.New("failure")
if HasOneOf(failure, Create) {
runner.createErr = errors.New("create failure")
runner.createErr = expectedFailure
}
if HasOneOf(failure, Delete) {
runner.deleteErr = errors.New("delete failure")
runner.deleteErr = expectedFailure
}
if HasOneOf(failure, Wait) {
runner.waitErr = errors.New("wait failure")
runner.waitErr = expectedFailure
}

err := cmd.Execute()
Expand Down
6 changes: 5 additions & 1 deletion cmd/kar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ func main() {

go func() {
<-ctx.Done()
runner.DeleteResources(ctx, runner.GetVMIName(), runner.GetDataVolumeName())

if err := runner.DeleteResources(ctx, runner.GetVMIName(), runner.GetDataVolumeName()); err != nil {
log.Panicln(err.Error())
}

stop()
}()

Expand Down

0 comments on commit 45950e4

Please sign in to comment.