Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensures golangci-lint is latest release version in CI #12018

Merged
merged 12 commits into from
Jul 14, 2023
Merged
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ jobs:
shellcheck

python3 -m pip install flake8
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2

- name: Download go dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ build-mo: $(MOFILES)
.PHONY: static-analysis
static-analysis:
ifeq ($(shell command -v golangci-lint 2> /dev/null),)
go install github.com/golangci/golangci-lint/cmd/[email protected]
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin
endif
ifeq ($(shell command -v shellcheck 2> /dev/null),)
echo "Please install shellcheck"
Expand Down
1 change: 1 addition & 0 deletions lxc-to-lxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ __attribute__((constructor)) void init(void) {
}
*/
import "C"

import (
"os"

Expand Down
44 changes: 22 additions & 22 deletions lxd/devices.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
package main

import (
"fmt"
"os"
"path"
"path/filepath"
"sort"
"strconv"
"strings"

"golang.org/x/sys/unix"

"github.com/canonical/lxd/lxd/cgroup"
"github.com/canonical/lxd/lxd/device"
_ "github.com/canonical/lxd/lxd/include" // Used by cgo
"github.com/canonical/lxd/lxd/instance"
"github.com/canonical/lxd/lxd/instance/instancetype"
"github.com/canonical/lxd/lxd/resources"
"github.com/canonical/lxd/lxd/state"
"github.com/canonical/lxd/shared"
"github.com/canonical/lxd/shared/logger"
)

/*
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
Expand Down Expand Up @@ -54,6 +32,28 @@ static int get_hidraw_devinfo(int fd, struct hidraw_devinfo *info)
*/
import "C"

import (
"fmt"
"os"
"path"
"path/filepath"
"sort"
"strconv"
"strings"

"golang.org/x/sys/unix"

"github.com/canonical/lxd/lxd/cgroup"
"github.com/canonical/lxd/lxd/device"
_ "github.com/canonical/lxd/lxd/include" // Used by cgo
"github.com/canonical/lxd/lxd/instance"
"github.com/canonical/lxd/lxd/instance/instancetype"
"github.com/canonical/lxd/lxd/resources"
"github.com/canonical/lxd/lxd/state"
"github.com/canonical/lxd/shared"
"github.com/canonical/lxd/shared/logger"
)

type deviceTaskCPU struct {
id int64
strId string
Expand Down
4 changes: 2 additions & 2 deletions lxd/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -2327,8 +2327,8 @@ func pruneExpiredImages(ctx context.Context, s *state.State, op *operations.Oper
}

allImages = make(map[string][]dbCluster.Image, len(images))
for i := range images {
allImages[images[i].Fingerprint] = append(allImages[images[i].Fingerprint], images[i])
for _, image := range images {
allImages[image.Fingerprint] = append(allImages[image.Fingerprint], image)
}

return nil
Expand Down
22 changes: 11 additions & 11 deletions lxd/main_checkfeature.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
package main

import (
"os"
"runtime"

"golang.org/x/sys/unix"

_ "github.com/canonical/lxd/lxd/include" // Used by cgo
"github.com/canonical/lxd/shared"
"github.com/canonical/lxd/shared/logger"
)

/*
#include "config.h"

Expand Down Expand Up @@ -589,6 +578,17 @@ static bool kernel_supports_idmapped_mounts(void)
*/
import "C"

import (
"os"
"runtime"

"golang.org/x/sys/unix"

_ "github.com/canonical/lxd/lxd/include" // Used by cgo
"github.com/canonical/lxd/shared"
"github.com/canonical/lxd/shared/logger"
)

func canUseNetnsGetifaddrs() bool {
if !bool(C.is_empty_string(&C.errbuf[0])) {
logger.Debugf("%s", C.GoString(&C.errbuf[0]))
Expand Down
18 changes: 9 additions & 9 deletions lxd/main_forkcoresched.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
package main

import (
"fmt"

"github.com/spf13/cobra"

// Used by cgo
_ "github.com/canonical/lxd/lxd/include"
)

/*
#include "config.h"

Expand Down Expand Up @@ -92,6 +83,15 @@ void forkcoresched(void)
*/
import "C"

import (
"fmt"

"github.com/spf13/cobra"

// Used by cgo
_ "github.com/canonical/lxd/lxd/include"
)

type cmdForkcoresched struct {
global *cmdGlobal
}
Expand Down
18 changes: 9 additions & 9 deletions lxd/main_forkexec.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
package main

import (
"fmt"

"github.com/spf13/cobra"

// Used by cgo
_ "github.com/canonical/lxd/lxd/include"
)

/*
#include "config.h"

Expand Down Expand Up @@ -336,6 +327,15 @@ void forkexec(void)
*/
import "C"

import (
"fmt"

"github.com/spf13/cobra"

// Used by cgo
_ "github.com/canonical/lxd/lxd/include"
)

type cmdForkexec struct {
global *cmdGlobal
}
Expand Down
26 changes: 13 additions & 13 deletions lxd/main_forkfile.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
package main

import (
"net"
"os"
"os/signal"
"strconv"
"sync"
"time"

"github.com/pkg/sftp"
"github.com/spf13/cobra"
"golang.org/x/sys/unix"
)

/*
#include "config.h"

Expand Down Expand Up @@ -97,6 +84,19 @@ void forkfile(void)
*/
import "C"

import (
"net"
"os"
"os/signal"
"strconv"
"sync"
"time"

"github.com/pkg/sftp"
"github.com/spf13/cobra"
"golang.org/x/sys/unix"
)

type cmdForkfile struct {
global *cmdGlobal
}
Expand Down
18 changes: 9 additions & 9 deletions lxd/main_forkmount.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
package main

import (
"fmt"

"github.com/spf13/cobra"

// Used by cgo
_ "github.com/canonical/lxd/lxd/include"
)

/*
#include "config.h"

Expand Down Expand Up @@ -658,6 +649,15 @@ void forkmount(void)
*/
import "C"

import (
"fmt"

"github.com/spf13/cobra"

// Used by cgo
_ "github.com/canonical/lxd/lxd/include"
)

type cmdForkmount struct {
global *cmdGlobal
}
Expand Down
24 changes: 12 additions & 12 deletions lxd/main_forknet.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
package main

import (
"encoding/json"
"fmt"
"net"

"github.com/spf13/cobra"

_ "github.com/canonical/lxd/lxd/include" // Used by cgo
"github.com/canonical/lxd/lxd/ip"
"github.com/canonical/lxd/shared/netutils"
)

/*
#include "config.h"

Expand Down Expand Up @@ -114,6 +102,18 @@ void forknet(void)
*/
import "C"

import (
"encoding/json"
"fmt"
"net"

"github.com/spf13/cobra"

_ "github.com/canonical/lxd/lxd/include" // Used by cgo
"github.com/canonical/lxd/lxd/ip"
"github.com/canonical/lxd/shared/netutils"
)

type cmdForknet struct {
global *cmdGlobal
}
Expand Down
46 changes: 23 additions & 23 deletions lxd/main_forkproxy.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
package main

import (
"fmt"
"io"
"net"
"os"
"os/signal"
"strconv"
"strings"
"sync"
"time"
"unsafe"

"github.com/spf13/cobra"
"golang.org/x/sys/unix"

"github.com/canonical/lxd/lxd/daemon"
deviceConfig "github.com/canonical/lxd/lxd/device/config"
_ "github.com/canonical/lxd/lxd/include" // Used by cgo
"github.com/canonical/lxd/lxd/network"
"github.com/canonical/lxd/shared"
"github.com/canonical/lxd/shared/netutils"
)

/*
#include "config.h"

Expand Down Expand Up @@ -263,6 +240,29 @@ void forkproxy(void)
*/
import "C"

import (
"fmt"
"io"
"net"
"os"
"os/signal"
"strconv"
"strings"
"sync"
"time"
"unsafe"

"github.com/spf13/cobra"
"golang.org/x/sys/unix"

"github.com/canonical/lxd/lxd/daemon"
deviceConfig "github.com/canonical/lxd/lxd/device/config"
_ "github.com/canonical/lxd/lxd/include" // Used by cgo
"github.com/canonical/lxd/lxd/network"
"github.com/canonical/lxd/shared"
"github.com/canonical/lxd/shared/netutils"
)

const forkproxyUDSSockFDNum int = C.FORKPROXY_UDS_SOCK_FD_NUM

type cmdForkproxy struct {
Expand Down
18 changes: 9 additions & 9 deletions lxd/main_forksyscall.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
package main

import (
"fmt"

"github.com/spf13/cobra"

// Used by cgo
_ "github.com/canonical/lxd/lxd/include"
)

/*
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
Expand Down Expand Up @@ -662,6 +653,15 @@ void forksyscall(void)
*/
import "C"

import (
"fmt"

"github.com/spf13/cobra"

// Used by cgo
_ "github.com/canonical/lxd/lxd/include"
)

type cmdForksyscall struct {
global *cmdGlobal
}
Expand Down
Loading