Skip to content
Merged
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
61 changes: 19 additions & 42 deletions .github/workflows/dev_module_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,78 +196,55 @@ jobs:
echo "golangci-lint v${{ env.GOLANGCI_LINT_VERSION}} installed successfully!"

- name: Lint all directories with golangci-lint
id: linters
# continue-on-error: true
shell: bash
run: |
# set -eo pipefail
set -e

# Find directories containing .golangci.yaml
mapfile -t config_dirs < <(find . -type f -name '.golangci.yaml' -printf '%h\0' | xargs -0 -n1 | sort -u)
mapfile -t config_dirs < <(
find . \
-path ./images/cdi-cloner/cloner-startup -prune -o \
-path ./images/dvcr-artifact -prune -o \
-path ./tests/performance/shatal -prune -o \
-type f -name '.golangci.yaml' -printf '%h\0' | \
xargs -0 -n1 | sort -u
)
count=${#config_dirs[@]}
echo "::notice title=Lint Setup::🔍 Found $count directories with linter configurations"

report=""
error_count=0
find_errors=0

for dir in "${config_dirs[@]}"; do
# echo "::group::📂 Linting directory: $dir"
# cd "$dir" || { echo "::error::Failed to access directory $dir"; exit 1; }

find_errors=0
cd "$dir" || { echo "::error::Failed to access directory $dir"; continue; }

# Run linter with multiple formats

output=$(golangci-lint run --out-format=json 2>/dev/null | jq '{warning: .Report.Warnings, error: .Report.Error}' || true)
find_errors=$(echo $output | jq '.error | select(.!=null)' | wc -l)

# Track errors
if [ $find_errors -ne 0 ]; then
if ! output=$(golangci-lint run --sort-results); then
error_count=$(( error_count + 1 ))
# find_errors=$(( find_errors + 1 ))
echo "::group::📂 Linting directory ❌: $dir"
echo -e "❌ Errors:\n$output\n"
echo "== debug =="
golangci-lint run --sort-results || true
else
echo "::group::📂 Linting directory ✅: $dir"
echo -e "✅ All check passed\n"
fi

report_out_warning=$(echo $output | jq '.warning')
report_out_error=$(echo $output | jq '.error')

# Build report section
report+="\n\n### Directory: $dir\n"
report+="Find Errors: $find_errors\n"
report+="Output:\n\`\`\`\n$report_out_warning\n$report_out_error\n\`\`\`\n"
report+="---\n"

cd - &>/dev/null

if [ $find_errors -ne 0 ]; then
echo -e "⚠️ Warnings:\n$report_out_warning"
echo -e "❌ Errors:\n$report_out_error\n"
else
echo -e "✅ All check passed\n"
fi

echo "::endgroup::"
done

echo "directory_count=$count" >> "$GITHUB_OUTPUT"

has_errors=$( [[ "$error_count" -gt 0 ]] && echo true || echo false)
echo "has_errors=$has_errors" >> "$GITHUB_OUTPUT"

if [ $error_count -gt 0 ]; then
echo "$error_count error more than 0, exit 1"
exit 1
fi

- name: Final status check
if: always()
run: |
if ${{ steps.linters.outputs.has_errors }}; then
echo "::error::🔥 Lint errors found in $error_count directories. Check step 'Lint all directories with golangci-lint' for details."
exit 1
else
echo "::notice::✅ All linters passed successfully in ${{ steps.linters.outputs.directory_count }} directories"
fi

lint_yaml:
runs-on: ubuntu-latest
name: Run yaml linter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Options struct {
Features *genericoptions.FeatureOptions
Logging *logs.Options

Kubevirt vmrest.KubevirtApiServerConfig
Kubevirt vmrest.KubevirtAPIServerConfig

ProxyClientCertFile string
ProxyClientKeyFile string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

"github.com/deckhouse/deckhouse/pkg/log"

appconfig "github.com/deckhouse/virtualization-controller/pkg/config"
"github.com/deckhouse/virtualization-controller/pkg/controller/cvi"
"github.com/deckhouse/virtualization-controller/pkg/controller/evacuation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func Build(store *storage.VirtualMachineStorage) genericapiserver.APIGroupInfo {
func Install(
vmLister virtlisters.VirtualMachineLister,
server *genericapiserver.GenericAPIServer,
kubevirt vmrest.KubevirtApiServerConfig,
kubevirt vmrest.KubevirtAPIServerConfig,
proxyCertManager certmanager.CertificateManager,
crd *apiextensionsv1.CustomResourceDefinition,
vmClient versionedv1alpha2.VirtualMachinesGetter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ import (
type AddVolumeREST struct {
vmLister virtlisters.VirtualMachineLister
proxyCertManager certmanager.CertificateManager
kubevirt KubevirtApiServerConfig
kubevirt KubevirtAPIServerConfig
}

var (
_ rest.Storage = &AddVolumeREST{}
_ rest.Connecter = &AddVolumeREST{}
)

func NewAddVolumeREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtApiServerConfig, proxyCertManager certmanager.CertificateManager) *AddVolumeREST {
func NewAddVolumeREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtAPIServerConfig, proxyCertManager certmanager.CertificateManager) *AddVolumeREST {
return &AddVolumeREST{
vmLister: vmLister,
kubevirt: kubevirt,
Expand Down Expand Up @@ -194,11 +194,11 @@ func AddVolumeLocation(
getter virtlisters.VirtualMachineLister,
name string,
opts *subresources.VirtualMachineAddVolume,
kubevirt KubevirtApiServerConfig,
kubevirt KubevirtAPIServerConfig,
proxyCertManager certmanager.CertificateManager,
addVolumePather pather,
) (*url.URL, *http.Transport, error) {
return streamLocation(ctx, getter, name, opts, addVolumePather, kubevirt, proxyCertManager)
return streamLocation(ctx, getter, name, addVolumePather, kubevirt, proxyCertManager)
}

type VirtualMachineVolumeRequest struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ import (
type CancelEvacuationREST struct {
vmLister virtlisters.VirtualMachineLister
proxyCertManager certmanager.CertificateManager
kubevirt KubevirtApiServerConfig
kubevirt KubevirtAPIServerConfig
}

var (
_ rest.Storage = &CancelEvacuationREST{}
_ rest.Connecter = &CancelEvacuationREST{}
)

func NewCancelEvacuationREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtApiServerConfig, proxyCertManager certmanager.CertificateManager) *CancelEvacuationREST {
func NewCancelEvacuationREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtAPIServerConfig, proxyCertManager certmanager.CertificateManager) *CancelEvacuationREST {
return &CancelEvacuationREST{
vmLister: vmLister,
kubevirt: kubevirt,
Expand Down Expand Up @@ -109,9 +109,9 @@ func CancelEvacuationRESTRESTLocation(
getter virtlisters.VirtualMachineLister,
name string,
opts *subresources.VirtualMachineCancelEvacuation,
kubevirt KubevirtApiServerConfig,
kubevirt KubevirtAPIServerConfig,
proxyCertManager certmanager.CertificateManager,
cancelEvacuationPather pather,
) (*url.URL, *http.Transport, error) {
return streamLocation(ctx, getter, name, opts, cancelEvacuationPather, kubevirt, proxyCertManager)
return streamLocation(ctx, getter, name, cancelEvacuationPather, kubevirt, proxyCertManager)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import (
type ConsoleREST struct {
vmLister virtlisters.VirtualMachineLister
proxyCertManager certmanager.CertificateManager
kubevirt KubevirtApiServerConfig
kubevirt KubevirtAPIServerConfig
}

type KubevirtApiServerConfig struct {
type KubevirtAPIServerConfig struct {
Endpoint string
CaBundlePath string
ServiceAccount types.NamespacedName
Expand All @@ -48,7 +48,7 @@ var (
_ rest.Connecter = &ConsoleREST{}
)

func NewConsoleREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtApiServerConfig, proxyCertManager certmanager.CertificateManager) *ConsoleREST {
func NewConsoleREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtAPIServerConfig, proxyCertManager certmanager.CertificateManager) *ConsoleREST {
return &ConsoleREST{
vmLister: vmLister,
kubevirt: kubevirt,
Expand Down Expand Up @@ -93,14 +93,13 @@ func ConsoleLocation(
getter virtlisters.VirtualMachineLister,
name string,
opts *subresources.VirtualMachineConsole,
kubevirt KubevirtApiServerConfig,
kubevirt KubevirtAPIServerConfig,
proxyCertManager certmanager.CertificateManager,
) (*url.URL, *http.Transport, error) {
return streamLocation(
ctx,
getter,
name,
opts,
newKVVMIPather("console"),
kubevirt,
proxyCertManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ import (
type FreezeREST struct {
vmLister virtlisters.VirtualMachineLister
proxyCertManager certmanager.CertificateManager
kubevirt KubevirtApiServerConfig
kubevirt KubevirtAPIServerConfig
}

var (
_ rest.Storage = &FreezeREST{}
_ rest.Connecter = &FreezeREST{}
)

func NewFreezeREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtApiServerConfig, proxyCertManager certmanager.CertificateManager) *FreezeREST {
func NewFreezeREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtAPIServerConfig, proxyCertManager certmanager.CertificateManager) *FreezeREST {
return &FreezeREST{
vmLister: vmLister,
kubevirt: kubevirt,
Expand Down Expand Up @@ -84,14 +84,13 @@ func FreezeLocation(
getter virtlisters.VirtualMachineLister,
name string,
opts *subresources.VirtualMachineFreeze,
kubevirt KubevirtApiServerConfig,
kubevirt KubevirtAPIServerConfig,
proxyCertManager certmanager.CertificateManager,
) (*url.URL, *http.Transport, error) {
return streamLocation(
ctx,
getter,
name,
opts,
newKVVMIPather("freeze"),
kubevirt,
proxyCertManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ import (
type PortForwardREST struct {
vmLister virtlisters.VirtualMachineLister
proxyCertManager certmanager.CertificateManager
kubevirt KubevirtApiServerConfig
kubevirt KubevirtAPIServerConfig
}

var (
_ rest.Storage = &PortForwardREST{}
_ rest.Connecter = &PortForwardREST{}
)

func NewPortForwardREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtApiServerConfig, proxyCertManager certmanager.CertificateManager) *PortForwardREST {
func NewPortForwardREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtAPIServerConfig, proxyCertManager certmanager.CertificateManager) *PortForwardREST {
return &PortForwardREST{
vmLister: vmLister,
kubevirt: kubevirt,
Expand Down Expand Up @@ -88,15 +88,14 @@ func PortForwardLocation(
getter virtlisters.VirtualMachineLister,
name string,
opts *subresources.VirtualMachinePortForward,
kubevirt KubevirtApiServerConfig,
kubevirt KubevirtAPIServerConfig,
proxyCertManager certmanager.CertificateManager,
) (*url.URL, *http.Transport, error) {
streamPath := buildPortForwardResourcePath(opts)
return streamLocation(
ctx,
getter,
name,
opts,
newKVVMIPather(streamPath),
kubevirt,
proxyCertManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ import (
type RemoveVolumeREST struct {
vmLister virtlisters.VirtualMachineLister
proxyCertManager certmanager.CertificateManager
kubevirt KubevirtApiServerConfig
kubevirt KubevirtAPIServerConfig
}

var (
_ rest.Storage = &RemoveVolumeREST{}
_ rest.Connecter = &RemoveVolumeREST{}
)

func NewRemoveVolumeREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtApiServerConfig, proxyCertManager certmanager.CertificateManager) *RemoveVolumeREST {
func NewRemoveVolumeREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtAPIServerConfig, proxyCertManager certmanager.CertificateManager) *RemoveVolumeREST {
return &RemoveVolumeREST{
vmLister: vmLister,
kubevirt: kubevirt,
Expand Down Expand Up @@ -121,9 +121,9 @@ func RemoveVolumeRESTLocation(
getter virtlisters.VirtualMachineLister,
name string,
opts *subresources.VirtualMachineRemoveVolume,
kubevirt KubevirtApiServerConfig,
kubevirt KubevirtAPIServerConfig,
proxyCertManager certmanager.CertificateManager,
removeVolumePather pather,
) (*url.URL, *http.Transport, error) {
return streamLocation(ctx, getter, name, opts, removeVolumePather, kubevirt, proxyCertManager)
return streamLocation(ctx, getter, name, removeVolumePather, kubevirt, proxyCertManager)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"net/url"
"os"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/proxy"
"k8s.io/apiserver/pkg/endpoints/request"
Expand Down Expand Up @@ -83,9 +82,8 @@ func streamLocation(
ctx context.Context,
getter virtlisters.VirtualMachineLister,
name string,
opts runtime.Object,
pather pather,
kubevirt KubevirtApiServerConfig,
kubevirt KubevirtAPIServerConfig,
proxyCertManager certmanager.CertificateManager,
preConditions ...preconditionVirtualMachine,
) (*url.URL, *http.Transport, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ import (
type UnfreezeREST struct {
vmLister virtlisters.VirtualMachineLister
proxyCertManager certmanager.CertificateManager
kubevirt KubevirtApiServerConfig
kubevirt KubevirtAPIServerConfig
}

var (
_ rest.Storage = &UnfreezeREST{}
_ rest.Connecter = &UnfreezeREST{}
)

func NewUnfreezeREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtApiServerConfig, proxyCertManager certmanager.CertificateManager) *UnfreezeREST {
func NewUnfreezeREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtAPIServerConfig, proxyCertManager certmanager.CertificateManager) *UnfreezeREST {
return &UnfreezeREST{
vmLister: vmLister,
kubevirt: kubevirt,
Expand Down Expand Up @@ -84,14 +84,13 @@ func UnfreezeLocation(
getter virtlisters.VirtualMachineLister,
name string,
opts *subresources.VirtualMachineUnfreeze,
kubevirt KubevirtApiServerConfig,
kubevirt KubevirtAPIServerConfig,
proxyCertManager certmanager.CertificateManager,
) (*url.URL, *http.Transport, error) {
return streamLocation(
ctx,
getter,
name,
opts,
newKVVMIPather("unfreeze"),
kubevirt,
proxyCertManager,
Expand Down
Loading
Loading