Skip to content

Commit

Permalink
ci: upgrade golangci lint to v1.59 (#7611)
Browse files Browse the repository at this point in the history
* ci: upgrade golangci lint to v1.59

Signed-off-by: Justin Chadwell <[email protected]>

* chore: fix linting issues

Signed-off-by: Justin Chadwell <[email protected]>

---------

Signed-off-by: Justin Chadwell <[email protected]>
  • Loading branch information
jedevc authored Jun 11, 2024
1 parent c7ac504 commit 70d7b65
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
3 changes: 0 additions & 3 deletions ci/consts/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ const (
WolfiImage = "cgr.dev/chainguard/wolfi-base"
WolfiVersion = "latest" // Wolfi is a rolling distro; no release to pin to

GolangLintVersion = "v1.57"
GolangLintImage = "golangci/golangci-lint:" + GolangLintVersion + "-alpine"

UbuntuVersion = "22.04"
RuncVersion = "v1.1.12"
CniVersion = "v1.3.0"
Expand Down
16 changes: 14 additions & 2 deletions ci/std/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"fmt"
"path"

"golang.org/x/sync/errgroup"
Expand All @@ -14,17 +15,28 @@ func New(
// +optional
// +default="1.22.4"
version string,
// Go linter version
// +optional
// +default="1.59"
lintVersion string,
) *Go {
if source == nil {
source = dag.Directory()
}
return &Go{Version: version, Source: source}
return &Go{
Version: version,
LintVersion: lintVersion,
Source: source,
}
}

// A Go project
type Go struct {
// Go version
Version string
// Go linter version
LintVersion string

// Project source directory
Source *Directory
}
Expand Down Expand Up @@ -84,7 +96,7 @@ func (p *Go) Lint(
// FIXME: consider using the same base container in Lint() and Env()
base := dag.
Container().
From("golangci/golangci-lint:v1.57-alpine").
From(fmt.Sprintf("golangci/golangci-lint:v%s-alpine", p.LintVersion)).
WithMountedDirectory("/app", p.Source).
WithWorkdir("/app")
for _, pkg := range pkgs {
Expand Down
4 changes: 1 addition & 3 deletions cmd/engine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/dagger/dagger/engine/distconsts"
)

func setDaggerDefaults(cfg *config.Config, netConf *networkConfig) error {
func setDaggerDefaults(cfg *config.Config, netConf *networkConfig) {
if cfg.Root == "" {
cfg.Root = distconsts.EngineDefaultStateDir
}
Expand All @@ -30,8 +30,6 @@ func setDaggerDefaults(cfg *config.Config, netConf *networkConfig) error {
setNetworkDefaults(&cfg.Workers.Containerd.NetworkConfig, netConf.CNIConfigPath)
}
}

return nil
}

func setNetworkDefaults(cfg *config.NetworkConfig, cniConfigPath string) {
Expand Down
4 changes: 1 addition & 3 deletions cmd/engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,7 @@ func main() { //nolint:gocyclo
}

bklog.G(ctx).Debug("setting engine configs from defaults and flags")
if err := setDaggerDefaults(&cfg, netConf); err != nil {
return err
}
setDaggerDefaults(&cfg, netConf)

setDefaultConfig(&cfg)

Expand Down
28 changes: 21 additions & 7 deletions engine/sources/gitdns/source_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ func mergeResolv(dst *os.File, src io.Reader, dns *oci.DNSConfig) error {
var replacedOptions bool

for _, ns := range dns.Nameservers {
fmt.Fprintln(dst, "nameserver", ns)
if _, err := fmt.Fprintln(dst, "nameserver", ns); err != nil {
return err
}
}

for srcScan.Scan() {
Expand All @@ -139,30 +141,42 @@ func mergeResolv(dst *os.File, src io.Reader, dns *oci.DNSConfig) error {
oldDomains := strings.Fields(srcScan.Text())[1:]
newDomains := append([]string{}, dns.SearchDomains...)
newDomains = append(newDomains, oldDomains...)
fmt.Fprintln(dst, "search", strings.Join(newDomains, " "))
if _, err := fmt.Fprintln(dst, "search", strings.Join(newDomains, " ")); err != nil {
return err
}
replacedSearch = true
case strings.HasPrefix(srcScan.Text(), "options"):
oldOptions := strings.Fields(srcScan.Text())[1:]
newOptions := append([]string{}, dns.Options...)
newOptions = append(newOptions, oldOptions...)
fmt.Fprintln(dst, "options", strings.Join(newOptions, " "))
if _, err := fmt.Fprintln(dst, "options", strings.Join(newOptions, " ")); err != nil {
return err
}
replacedOptions = true
case strings.HasPrefix(srcScan.Text(), "nameserver"):
if len(dns.Nameservers) == 0 {
// preserve existing nameservers
fmt.Fprintln(dst, srcScan.Text())
if _, err := fmt.Fprintln(dst, srcScan.Text()); err != nil {
return err
}
}
default:
fmt.Fprintln(dst, srcScan.Text())
if _, err := fmt.Fprintln(dst, srcScan.Text()); err != nil {
return err
}
}
}

if !replacedSearch {
fmt.Fprintln(dst, "search", strings.Join(dns.SearchDomains, " "))
if _, err := fmt.Fprintln(dst, "search", strings.Join(dns.SearchDomains, " ")); err != nil {
return err
}
}

if !replacedOptions {
fmt.Fprintln(dst, "options", strings.Join(dns.Options, " "))
if _, err := fmt.Fprintln(dst, "options", strings.Join(dns.Options, " ")); err != nil {
return err
}
}

return nil
Expand Down

0 comments on commit 70d7b65

Please sign in to comment.