Skip to content

Commit d5865c1

Browse files
Merge pull request #27498 from Luap99/gofumpt
enable gofumpt formatter
2 parents 52c6841 + cd0293a commit d5865c1

File tree

390 files changed

+1230
-1601
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

390 files changed

+1230
-1601
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ run:
44

55
formatters:
66
enable:
7-
- gofmt
7+
- gofumpt
88
- goimports
99
exclusions:
1010
generated: disable

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ It is not necessary to test a single change in multiple places.
146146

147147
### Go Format and lint
148148

149-
All code changes must pass ``make validatepr``.
149+
All code changes must pass `make validatepr`.
150+
We are using the [`gofumpt`](https://github.com/mvdan/gofumpt) formatter for our go code, you can either use it directly or format via `golangci-lint fmt`. The `validatepr`/`validate` make targets will fail if the code is not formatted correctly.
150151

151152
### Integration Tests
152153

cmd/podman-mac-helper/install.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919
)
2020

2121
const (
22-
mode755 = 0755
23-
mode644 = 0644
22+
mode755 = 0o755
23+
mode644 = 0o644
2424
)
2525

2626
const launchConfig = `<?xml version="1.0" encoding="UTF-8"?>

cmd/podman-testing/store_unsupported.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import (
66
"github.com/containers/podman/v6/pkg/domain/entities"
77
)
88

9-
var (
10-
engineMode = entities.TunnelMode
11-
)
9+
var engineMode = entities.TunnelMode
1210

1311
func storeBefore() error {
1412
return nil

cmd/podman-wslkerninst/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ func setupLogging(name string) (*eventlog.Log, error) {
4343

4444
func installWslKernel() error {
4545
logrus.Info("Installing WSL Kernel update")
46-
var (
47-
err error
48-
)
46+
var err error
4947
backoff := 500 * time.Millisecond
5048
for i := 1; i < 6; i++ {
5149
err = wutil.SilentExec("--update")

cmd/podman/artifact/add.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@ import (
1212
"go.podman.io/common/pkg/completion"
1313
)
1414

15-
var (
16-
addCmd = &cobra.Command{
17-
Use: "add [options] ARTIFACT PATH [...PATH]",
18-
Short: "Add an OCI artifact to the local store",
19-
Long: "Add an OCI artifact to the local store from the local filesystem",
20-
RunE: add,
21-
Args: cobra.MinimumNArgs(2),
22-
ValidArgsFunction: common.AutocompleteArtifactAdd,
23-
Example: `podman artifact add quay.io/myimage/myartifact:latest /tmp/foobar.txt
15+
var addCmd = &cobra.Command{
16+
Use: "add [options] ARTIFACT PATH [...PATH]",
17+
Short: "Add an OCI artifact to the local store",
18+
Long: "Add an OCI artifact to the local store from the local filesystem",
19+
RunE: add,
20+
Args: cobra.MinimumNArgs(2),
21+
ValidArgsFunction: common.AutocompleteArtifactAdd,
22+
Example: `podman artifact add quay.io/myimage/myartifact:latest /tmp/foobar.txt
2423
podman artifact add --file-type text/yaml quay.io/myimage/myartifact:latest /tmp/foobar.yaml
2524
podman artifact add --append quay.io/myimage/myartifact:latest /tmp/foobar.tar.gz`,
26-
}
27-
)
25+
}
2826

2927
// AddOptionsWrapper wraps entities.ArtifactsAddOptions and prevents leaking
3028
// CLI-only fields into the API types.

cmd/podman/artifact/extract.go

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,18 @@ import (
88
"go.podman.io/common/pkg/completion"
99
)
1010

11-
var (
12-
extractCmd = &cobra.Command{
13-
Use: "extract [options] ARTIFACT PATH",
14-
Short: "Extract an OCI artifact to a local path",
15-
Long: "Extract the blobs of an OCI artifact to a local file or directory",
16-
RunE: extract,
17-
Args: cobra.ExactArgs(2),
18-
ValidArgsFunction: common.AutocompleteArtifactAdd,
19-
Example: `podman artifact Extract quay.io/myimage/myartifact:latest /tmp/foobar.txt
11+
var extractCmd = &cobra.Command{
12+
Use: "extract [options] ARTIFACT PATH",
13+
Short: "Extract an OCI artifact to a local path",
14+
Long: "Extract the blobs of an OCI artifact to a local file or directory",
15+
RunE: extract,
16+
Args: cobra.ExactArgs(2),
17+
ValidArgsFunction: common.AutocompleteArtifactAdd,
18+
Example: `podman artifact Extract quay.io/myimage/myartifact:latest /tmp/foobar.txt
2019
podman artifact Extract quay.io/myimage/myartifact:latest /home/paul/mydir`,
21-
}
22-
)
20+
}
2321

24-
var (
25-
extractOpts entities.ArtifactExtractOptions
26-
)
22+
var extractOpts entities.ArtifactExtractOptions
2723

2824
func init() {
2925
registry.Commands = append(registry.Commands, registry.CliCommand{

cmd/podman/artifact/list.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ func (a artifactListOutput) CreatedAt() string {
6363
return a.created.String()
6464
}
6565

66-
var (
67-
defaultArtifactListOutputFormat = "{{range .}}{{.Repository}}\t{{.Tag}}\t{{.Digest}}\t{{.Created}}\t{{.Size}}\n{{end -}}"
68-
)
66+
var defaultArtifactListOutputFormat = "{{range .}}{{.Repository}}\t{{.Tag}}\t{{.Digest}}\t{{.Created}}\t{{.Size}}\n{{end -}}"
6967

7068
func init() {
7169
registry.Commands = append(registry.Commands, registry.CliCommand{
@@ -93,9 +91,7 @@ func outputTemplate(cmd *cobra.Command, lrs []*entities.ArtifactListReport) erro
9391
var err error
9492
artifacts := make([]artifactListOutput, 0)
9593
for _, lr := range lrs {
96-
var (
97-
tag string
98-
)
94+
var tag string
9995
artifactName, err := lr.Artifact.GetName()
10096
if err != nil {
10197
return err

cmd/podman/artifact/rm.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func rmFlags(cmd *cobra.Command) {
3535
flags.BoolVarP(&rmOptions.All, "all", "a", false, "Remove all artifacts")
3636
flags.BoolVarP(&rmOptions.Ignore, "ignore", "i", false, "Ignore error if artifact does not exist")
3737
}
38+
3839
func init() {
3940
registry.Commands = append(registry.Commands, registry.CliCommand{
4041
Command: rmCmd,

cmd/podman/common/build.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ type BuildFlagsWrapper struct {
5252

5353
// FarmBuildHiddenFlags are the flags hidden from the farm build command because they are either not
5454
// supported or don't make sense in the farm build use case
55-
var FarmBuildHiddenFlags = []string{"arch", "all-platforms", "compress", "cw", "disable-content-trust",
55+
var FarmBuildHiddenFlags = []string{
56+
"arch", "all-platforms", "compress", "cw", "disable-content-trust",
5657
"logsplit", "manifest", "os", "output", "platform", "sign-by", "signature-policy", "stdin",
57-
"variant"}
58+
"variant",
59+
}
5860

5961
func DefineBuildFlags(cmd *cobra.Command, buildOpts *BuildFlagsWrapper, isFarmBuild bool) {
6062
flags := cmd.Flags()

0 commit comments

Comments
 (0)