Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/dev_module_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ jobs:
find . \
-path ./images/cdi-cloner/cloner-startup -prune -o \
-path ./images/dvcr-artifact -prune -o \
-path ./images/virtualization-dra -prune -o \
-path ./test/performance/shatal -prune -o \
-type f -name '.golangci.yaml' -printf '%h\0' | \
xargs -0 -n1 | sort -u
Expand Down Expand Up @@ -279,6 +280,33 @@ jobs:
exit 1
fi

lint_go-virtualization-dra:
runs-on: ubuntu-22.04
name: Run go linter virtualization-dra
steps:
- name: Set up Go 1.25
uses: actions/setup-go@v5
with:
go-version: "1.25"

- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Install golangci-lint
run: |
echo "Installing golangci-lint..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.8.0
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "golangci-lint v2.8.0 installed successfully!"

- name: Lint virtualization-dra directory with golangci-lint
shell: bash
working-directory: ./images/virtualization-dra
run: |
set -e
golangci-lint run

lint_yaml:
runs-on: ubuntu-latest
name: Run yaml linter
Expand Down
18 changes: 9 additions & 9 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -283,19 +283,19 @@ tasks:
kubectl -n d8-virtualization port-forward deploy/virt-api 2345:2345
EOF

dlv:virtualization-dra-plugin:build:
desc: "Build image virtualization-dra-plugin with dlv"
dlv:virtualization-dra-usb:build:
desc: "Build image virtualization-dra-usb with dlv"
cmds:
- docker build --build-arg BRANCH=$BRANCH -f ./images/virtualization-dra-plugin/debug/dlv.Dockerfile -t "{{ .DLV_IMAGE }}" --platform linux/amd64 .
- docker build --build-arg BRANCH=$BRANCH -f ./images/virtualization-dra-usb/debug/dlv.Dockerfile -t "{{ .DLV_IMAGE }}" --platform linux/amd64 .

dlv:virtualization-dra-plugin:build-push:
desc: "Build and Push image virtualization-dra-plugin with dlv"
dlv:virtualization-dra-usb:build-push:
desc: "Build and Push image virtualization-dra-usb with dlv"
cmds:
- task: dlv:virtualization-dra-plugin:build
- task: dlv:virtualization-dra-usb:build
- docker push "{{ .DLV_IMAGE }}"
- task: dlv:virtualization-dra-plugin:print
- task: dlv:virtualization-dra-usb:print

dlv:virtualization-dra-plugin:print:
dlv:virtualization-dra-usb:print:
desc: "Print commands for debug"
env:
IMAGE: "{{ .DLV_IMAGE }}"
Expand All @@ -314,5 +314,5 @@ tasks:
}
}
}'
kubectl -n d8-virtualization port-forward deploy/virtualization-dra 2345:2345
kubectl -n d8-virtualization port-forward pod/<virtualization-dra-pod> 2345:2345
EOF
1 change: 1 addition & 0 deletions images/virt-artifact/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
image: {{ .ModuleNamePrefix }}{{ .ImageName }}-src-artifact
final: false
fromImage: builder/src
fromCacheVersion: "hotplug-36" # TODO: remove this
secrets:
- id: SOURCE_REPO
value: {{ $.SOURCE_REPO }}
Expand Down
4 changes: 2 additions & 2 deletions images/virt-controller/debug/dlv.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN go install github.com/go-delve/delve/cmd/dlv@latest

ARG BRANCH="v1.6.2-virtualization"
ENV VERSION="1.6.2"
ENV GOVERSION="1.23.0"
ENV GOVERSION="1.24.0"

# Copy the git commits for rebuilding the image if the branch changes
ADD "https://api.github.com/repos/deckhouse/3p-kubevirt/commits/$BRANCH" /.git-commit-hash.tmp
Expand All @@ -26,7 +26,7 @@ ENV GOOS=linux
ENV CGO_ENABLED=0
ENV GOARCH=amd64

RUN go build -o /kubevirt-binaries/virt-controller ./cmd/virt-controller/
RUN go build -gcflags="all=-N -l" -o /kubevirt-binaries/virt-controller ./cmd/virt-controller/

FROM busybox

Expand Down
16 changes: 4 additions & 12 deletions images/virtualization-artifact/pkg/common/patch/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package patch
import (
"encoding/json"
"fmt"
"slices"
"strings"
)

Expand Down Expand Up @@ -78,18 +79,9 @@ func (jp *JSONPatch) Append(patches ...JSONPatchOperation) {
}

func (jp *JSONPatch) Delete(op, path string) {
var idx int
var found bool
for i, o := range jp.operations {
if o.Op == op && o.Path == path {
idx = i
found = true
break
}
}
if found {
jp.operations = append(jp.operations[:idx], jp.operations[idx+1:]...)
}
jp.operations = slices.DeleteFunc(jp.operations, func(o JSONPatchOperation) bool {
return o.Op == op && o.Path == path
})
}

func (jp *JSONPatch) Len() int {
Expand Down
4 changes: 4 additions & 0 deletions images/virtualization-dra-usb/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import:
add: /out/virtualization-dra-usb
to: /app/virtualization-dra-usb
after: install
- image: {{ .ModuleNamePrefix }}virtualization-dra-builder
add: /out/go-usbip
to: /usb/bin/go-usbip
after: install
{{- if eq $.DEBUG_COMPONENT "delve/virtualization-dra-usb" }}
- image: debugger
add: /app/dlv
Expand Down
155 changes: 86 additions & 69 deletions images/virtualization-dra/.golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,102 +1,61 @@
# https://golangci-lint.run/usage/configuration/
version: "2"

run:
concurrency: 4
timeout: 10m

issues:
# Show all errors.
max-issues-per-linter: 0
max-same-issues: 0
exclude:
- "don't use an underscore in package name"

output:
sort-results: true

exclude-files:
- "^zz_generated.*"
exclusions:
paths:
- "^zz_generated.*"

linters-settings:
gofumpt:
extra-rules: true
gci:
sections:
- standard
- default
- prefix(github.com/deckhouse/)
goimports:
local-prefixes: github.com/deckhouse/
errcheck:
exclude-functions: fmt:.*,[rR]ead|[wW]rite|[cC]lose,io:Copy
revive:
rules:
- name: dot-imports
disabled: true
nolintlint:
# Exclude following linters from requiring an explanation.
# Default: []
allow-no-explanation: [funlen, gocognit, lll]
# Enable to require an explanation of nonzero length after each nolint directive.
# Default: false
require-explanation: true
# Enable to require nolint directives to mention the specific linter being suppressed.
# Default: false
require-specific: true
importas:
# Do not allow unaliased imports of aliased packages.
# Default: false
no-unaliased: true
# Do not allow non-required aliases.
# Default: false
no-extra-aliases: false
# List of aliases
# Default: []
alias:
- pkg: github.com/deckhouse/virtualization/api/core/v1alpha2
alias: ""
- pkg: github.com/deckhouse/virtualization/api/subresources/v1alpha2
alias: subv1alpha2
- pkg: kubevirt.io/api/core/v1
alias: virtv1
- pkg: k8s.io/api/core/v1
alias: corev1
- pkg: k8s.io/api/authentication/v1
alias: authnv1
- pkg: k8s.io/api/storage/v1
alias: storagev1
- pkg: k8s.io/api/networking/v1
alias: netv1
- pkg: k8s.io/api/policy/v1
alias: policyv1
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
alias: metav1
- pkg: k8s.io/api/resource/v1
alias: resourcev1
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
settings:
gci:
sections:
- standard
- default
- prefix(github.com/deckhouse/)
gofumpt:
extra-rules: true
goimports:
local-prefixes: github.com/deckhouse/

linters:
disable-all: true
default: none
enable:
- asciicheck # checks that your code does not contain non-ASCII identifiers
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- contextcheck # [maby too many false positives] checks the function whether use a non-inherited context
- contextcheck # [maybe too many false positives] checks the function whether use a non-inherited context
- dogsled # checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
- copyloopvar # detects places where loop variables are copied (Go 1.22+)
- gci # controls golang package import order and makes it always deterministic
- gocritic # provides diagnostics that check for bugs, performance and style issues
- gofmt # [replaced by goimports] checks whether code was gofmt-ed
- gofumpt # [replaced by goimports, gofumports is not available yet] checks whether code was gofumpt-ed
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
- gosimple # specializes in simplifying a code
- govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- ineffassign # detects when assignments to existing variables are not used
- misspell # finds commonly misspelled English words in comments
- nolintlint # reports ill-formed or insufficient nolint directives
- reassign # Checks that package variables are not reassigned.
- reassign # checks that package variables are not reassigned
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
- stylecheck # is a replacement for golint
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
- typecheck # like the front-end of a Go compiler, parses and type-checks Go code
- testifylint # checks usage of github.com/stretchr/testify
- unconvert # removes unnecessary type conversions
- unparam # reports unused function parameters
Expand All @@ -106,5 +65,63 @@ linters:
- thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
- whitespace # detects leading and trailing whitespace
- wastedassign # Finds wasted assignment statements.
- wastedassign # finds wasted assignment statements
- importas # checks import aliases against the configured convention
settings:
errcheck:
exclude-functions:
- "(*os.File).Close"
- "(*net.TCPConn).Close"
# - "fmt:.*"
# - "[rR]ead"
# - "[wW]rite"
# - "[cC]lose"
# - "io:Copy"
revive:
rules:
- name: dot-imports
disabled: true
- name: exported
disabled: true
- name: package-comments
disabled: true
nolintlint:
# Exclude following linters from requiring an explanation.
# Default: []
allow-no-explanation: [funlen, gocognit, lll]
# Enable to require an explanation of nonzero length after each nolint directive.
# Default: false
require-explanation: true
# Enable to require nolint directives to mention the specific linter being suppressed.
# Default: false
require-specific: true
importas:
# Do not allow unaliased imports of aliased packages.
# Default: false
no-unaliased: true
# Do not allow non-required aliases.
# Default: false
no-extra-aliases: false
# List of aliases
# Default: []
alias:
- pkg: github.com/deckhouse/virtualization/api/core/v1alpha2
alias: ""
- pkg: github.com/deckhouse/virtualization/api/subresources/v1alpha2
alias: subv1alpha2
- pkg: kubevirt.io/api/core/v1
alias: virtv1
- pkg: k8s.io/api/core/v1
alias: corev1
- pkg: k8s.io/api/authentication/v1
alias: authnv1
- pkg: k8s.io/api/storage/v1
alias: storagev1
- pkg: k8s.io/api/networking/v1
alias: netv1
- pkg: k8s.io/api/policy/v1
alias: policyv1
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
alias: metav1
- pkg: k8s.io/api/resource/v1
alias: resourcev1
23 changes: 21 additions & 2 deletions images/virtualization-dra/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,27 @@ tasks:

lint:go:
desc: "Run golangci-lint"
deps:
- _ensure:golangci-lint
cmds:
- |
golangci-lint run

lint:go:fix:
desc: "Run golangci-lint with --fix"
cmds:
- |
golangci-lint run --fix

build:go-usbip:
desc: "Build go-usbip binary"
cmds:
- go build -o bin/go-usbip cmd/usb/go-usbip/main.go

build:usb-monitor:
desc: "Build usb-monitor binary"
cmds:
- go build -o bin/usb-monitor cmd/usb/usb-monitor/main.go

api:generate:
desc: "Generate API code"
cmds:
- hack/update-codegen.sh
Loading
Loading