mirror of
https://github.com/juanfont/headscale.git
synced 2026-04-20 07:41:31 +02:00
all: fix golangci-lint issues (#3064)
This commit is contained in:
@@ -34,6 +34,7 @@ func DockerAddIntegrationLabels(opts *dockertest.RunOptions, testType string) {
|
||||
if opts.Labels == nil {
|
||||
opts.Labels = make(map[string]string)
|
||||
}
|
||||
|
||||
opts.Labels["hi.run-id"] = runID
|
||||
opts.Labels["hi.test-type"] = testType
|
||||
}
|
||||
|
||||
@@ -38,9 +38,10 @@ type buffer struct {
|
||||
|
||||
// Write appends the contents of p to the buffer, growing the buffer as needed. It returns
|
||||
// the number of bytes written.
|
||||
func (b *buffer) Write(p []byte) (n int, err error) {
|
||||
func (b *buffer) Write(p []byte) (int, error) {
|
||||
b.mutex.Lock()
|
||||
defer b.mutex.Unlock()
|
||||
|
||||
return b.store.Write(p)
|
||||
}
|
||||
|
||||
@@ -49,6 +50,7 @@ func (b *buffer) Write(p []byte) (n int, err error) {
|
||||
func (b *buffer) String() string {
|
||||
b.mutex.Lock()
|
||||
defer b.mutex.Unlock()
|
||||
|
||||
return b.store.String()
|
||||
}
|
||||
|
||||
@@ -66,7 +68,8 @@ func ExecuteCommand(
|
||||
}
|
||||
|
||||
for _, opt := range options {
|
||||
if err := opt(&execConfig); err != nil {
|
||||
err := opt(&execConfig)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("execute-command/options: %w", err)
|
||||
}
|
||||
}
|
||||
@@ -105,7 +108,6 @@ func ExecuteCommand(
|
||||
// log.Println("Command: ", cmd)
|
||||
// log.Println("stdout: ", stdout.String())
|
||||
// log.Println("stderr: ", stderr.String())
|
||||
|
||||
return stdout.String(), stderr.String(), fmt.Errorf("command failed, stderr: %s: %w", stderr.String(), ErrDockertestCommandFailed)
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ func SaveLog(
|
||||
}
|
||||
|
||||
var stdout, stderr bytes.Buffer
|
||||
|
||||
err = WriteLog(pool, resource, &stdout, &stderr)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
@@ -55,6 +56,7 @@ func SaveLog(
|
||||
log.Printf("Saving logs for %s to %s\n", resource.Container.Name, basePath)
|
||||
|
||||
stdoutPath := path.Join(basePath, resource.Container.Name+".stdout.log")
|
||||
|
||||
err = os.WriteFile(
|
||||
stdoutPath,
|
||||
stdout.Bytes(),
|
||||
@@ -65,6 +67,7 @@ func SaveLog(
|
||||
}
|
||||
|
||||
stderrPath := path.Join(basePath, resource.Container.Name+".stderr.log")
|
||||
|
||||
err = os.WriteFile(
|
||||
stderrPath,
|
||||
stderr.Bytes(),
|
||||
|
||||
@@ -18,8 +18,9 @@ func GetFirstOrCreateNetwork(pool *dockertest.Pool, name string) (*dockertest.Ne
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("looking up network names: %w", err)
|
||||
}
|
||||
|
||||
if len(networks) == 0 {
|
||||
if _, err := pool.CreateNetwork(name); err == nil {
|
||||
if _, err := pool.CreateNetwork(name); err == nil { //nolint:noinlineerr // intentional inline check
|
||||
// Create does not give us an updated version of the resource, so we need to
|
||||
// get it again.
|
||||
networks, err := pool.NetworksByName(name)
|
||||
@@ -90,6 +91,7 @@ func RandomFreeHostPort() (int, error) {
|
||||
// CleanUnreferencedNetworks removes networks that are not referenced by any containers.
|
||||
func CleanUnreferencedNetworks(pool *dockertest.Pool) error {
|
||||
filter := "name=hs-"
|
||||
|
||||
networks, err := pool.NetworksByName(filter)
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting networks by filter %q: %w", filter, err)
|
||||
@@ -122,6 +124,7 @@ func CleanImagesInCI(pool *dockertest.Pool) error {
|
||||
}
|
||||
|
||||
removedCount := 0
|
||||
|
||||
for _, image := range images {
|
||||
// Only remove dangling (untagged) images to avoid forcing rebuilds
|
||||
// Dangling images have no RepoTags or only have "<none>:<none>"
|
||||
|
||||
Reference in New Issue
Block a user