Skip to content

Commit 5d0a0f3

Browse files
chore: format go code using gofumpt (#172)
1 parent 6bc56e8 commit 5d0a0f3

File tree

17 files changed

+62
-45
lines changed

17 files changed

+62
-45
lines changed

.github/workflows/ci.yaml

+17-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ name: ci
22

33
on:
44
push:
5+
branches:
6+
- main
57
pull_request:
8+
branches:
9+
- main
610
workflow_dispatch:
711

812
permissions:
@@ -53,22 +57,8 @@ jobs:
5357
steps:
5458
- name: Checkout
5559
uses: actions/checkout@v4
56-
with:
57-
ref: ${{ github.event.pull_request.head.sha }}
58-
59-
- name: Echo Go Cache Paths
60-
id: go-cache-paths
61-
run: |
62-
echo "GOCACHE=$(go env GOCACHE)" >> ${{ runner.os == 'Windows' && '$env:' || '$' }}GITHUB_OUTPUT
63-
echo "GOMODCACHE=$(go env GOMODCACHE)" >> ${{ runner.os == 'Windows' && '$env:' || '$' }}GITHUB_OUTPUT
64-
65-
- name: Go Build Cache
66-
uses: actions/cache@v3
67-
with:
68-
path: ${{ steps.go-cache-paths.outputs.GOCACHE }}
69-
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go') }}
7060

71-
- uses: actions/setup-go@v3
61+
- uses: actions/setup-go@v5
7262
with:
7363
go-version: "~1.21"
7464

@@ -77,3 +67,15 @@ jobs:
7767

7868
- name: Check for unstaged files
7969
run: git diff --exit-code
70+
fmt:
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@v4
75+
76+
- uses: actions/setup-go@v5
77+
with:
78+
go-version: "~1.21"
79+
80+
- name: Check format
81+
run: bash ./scripts/check_fmt.sh

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
GOARCH := $(shell go env GOARCH)
22
PWD=$(shell pwd)
33

4+
fmt: **/*.go
5+
go run mvdan.cc/[email protected] -l -w .
6+
47
develop:
58
./scripts/develop.sh
69

devcontainer/devcontainer.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (s *Spec) Compile(fs billy.Filesystem, devcontainerDir, scratchDir string,
141141
if s.Image != "" {
142142
// We just write the image to a file and return it.
143143
dockerfilePath := filepath.Join(scratchDir, "Dockerfile")
144-
file, err := fs.OpenFile(dockerfilePath, os.O_CREATE|os.O_WRONLY, 0644)
144+
file, err := fs.OpenFile(dockerfilePath, os.O_CREATE|os.O_WRONLY, 0o644)
145145
if err != nil {
146146
return nil, fmt.Errorf("open dockerfile: %w", err)
147147
}
@@ -228,7 +228,7 @@ func (s *Spec) compileFeatures(fs billy.Filesystem, devcontainerDir, scratchDir
228228
}
229229

230230
featuresDir := filepath.Join(scratchDir, "features")
231-
err := fs.MkdirAll(featuresDir, 0644)
231+
err := fs.MkdirAll(featuresDir, 0o644)
232232
if err != nil {
233233
return "", nil, fmt.Errorf("create features directory: %w", err)
234234
}
@@ -278,7 +278,7 @@ func (s *Spec) compileFeatures(fs billy.Filesystem, devcontainerDir, scratchDir
278278
featureSha := md5.Sum([]byte(featureRefRaw))
279279
featureName := filepath.Base(featureRef)
280280
featureDir := filepath.Join(featuresDir, fmt.Sprintf("%s-%x", featureName, featureSha[:4]))
281-
if err := fs.MkdirAll(featureDir, 0644); err != nil {
281+
if err := fs.MkdirAll(featureDir, 0o644); err != nil {
282282
return "", nil, err
283283
}
284284
spec, err := features.Extract(fs, devcontainerDir, featureDir, featureRefRaw)

devcontainer/devcontainer_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ func TestCompileDevContainer(t *testing.T) {
137137
},
138138
}
139139
dcDir := "/workspaces/coder/.devcontainer"
140-
err := fs.MkdirAll(dcDir, 0755)
140+
err := fs.MkdirAll(dcDir, 0o755)
141141
require.NoError(t, err)
142-
file, err := fs.OpenFile(filepath.Join(dcDir, "Dockerfile"), os.O_CREATE|os.O_WRONLY, 0644)
142+
file, err := fs.OpenFile(filepath.Join(dcDir, "Dockerfile"), os.O_CREATE|os.O_WRONLY, 0o644)
143143
require.NoError(t, err)
144144
_, err = io.WriteString(file, "FROM localhost:5000/envbuilder-test-ubuntu:latest")
145145
require.NoError(t, err)

devcontainer/features/features.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func extractFromImage(fs billy.Filesystem, directory, reference string) error {
6565
path := filepath.Join(directory, header.Name)
6666
switch header.Typeflag {
6767
case tar.TypeDir:
68-
err = fs.MkdirAll(path, 0755)
68+
err = fs.MkdirAll(path, 0o755)
6969
if err != nil {
7070
return fmt.Errorf("mkdir %s: %w", path, err)
7171
}
@@ -126,7 +126,7 @@ func Extract(fs billy.Filesystem, devcontainerDir, directory, reference string)
126126
if ok {
127127
// For some reason the filesystem abstraction doesn't support chmod.
128128
// https://github.com/src-d/go-billy/issues/56
129-
err = chmodder.Chmod(installScriptPath, 0755)
129+
err = chmodder.Chmod(installScriptPath, 0o755)
130130
}
131131
if err != nil {
132132
return nil, fmt.Errorf("chmod install.sh: %w", err)

envbuilder.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func Run(ctx context.Context, options Options) error {
150150
if err != nil {
151151
return fmt.Errorf("parse docker config: %w", err)
152152
}
153-
err = os.WriteFile(filepath.Join(MagicDir, "config.json"), decoded, 0644)
153+
err = os.WriteFile(filepath.Join(MagicDir, "config.json"), decoded, 0o644)
154154
if err != nil {
155155
return fmt.Errorf("write docker config: %w", err)
156156
}
@@ -217,7 +217,7 @@ func Run(ctx context.Context, options Options) error {
217217

218218
defaultBuildParams := func() (*devcontainer.Compiled, error) {
219219
dockerfile := filepath.Join(MagicDir, "Dockerfile")
220-
file, err := options.Filesystem.OpenFile(dockerfile, os.O_CREATE|os.O_WRONLY, 0644)
220+
file, err := options.Filesystem.OpenFile(dockerfile, os.O_CREATE|os.O_WRONLY, 0o644)
221221
if err != nil {
222222
return nil, err
223223
}
@@ -697,7 +697,7 @@ func Run(ctx context.Context, options Options) error {
697697
endStage("👤 Updated the ownership of the workspace!")
698698
}
699699

700-
err = os.MkdirAll(options.WorkspaceFolder, 0755)
700+
err = os.MkdirAll(options.WorkspaceFolder, 0o755)
701701
if err != nil {
702702
return fmt.Errorf("create workspace folder: %w", err)
703703
}
@@ -954,7 +954,7 @@ func createPostStartScript(path string, postStartCommand devcontainer.LifecycleS
954954
}
955955
defer postStartScript.Close()
956956

957-
if err := postStartScript.Chmod(0755); err != nil {
957+
if err := postStartScript.Chmod(0o755); err != nil {
958958
return err
959959
}
960960

envbuilder_internal_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestFindDevcontainerJSON(t *testing.T) {
3232

3333
// given
3434
fs := memfs.New()
35-
err := fs.MkdirAll("/workspace/.devcontainer", 0600)
35+
err := fs.MkdirAll("/workspace/.devcontainer", 0o600)
3636
require.NoError(t, err)
3737

3838
// when
@@ -50,7 +50,7 @@ func TestFindDevcontainerJSON(t *testing.T) {
5050

5151
// given
5252
fs := memfs.New()
53-
err := fs.MkdirAll("/workspace/.devcontainer", 0600)
53+
err := fs.MkdirAll("/workspace/.devcontainer", 0o600)
5454
require.NoError(t, err)
5555
fs.Create("/workspace/.devcontainer/devcontainer.json")
5656

@@ -71,7 +71,7 @@ func TestFindDevcontainerJSON(t *testing.T) {
7171

7272
// given
7373
fs := memfs.New()
74-
err := fs.MkdirAll("/workspace/experimental-devcontainer", 0600)
74+
err := fs.MkdirAll("/workspace/experimental-devcontainer", 0o600)
7575
require.NoError(t, err)
7676
fs.Create("/workspace/experimental-devcontainer/devcontainer.json")
7777

@@ -93,7 +93,7 @@ func TestFindDevcontainerJSON(t *testing.T) {
9393

9494
// given
9595
fs := memfs.New()
96-
err := fs.MkdirAll("/workspace/.devcontainer", 0600)
96+
err := fs.MkdirAll("/workspace/.devcontainer", 0o600)
9797
require.NoError(t, err)
9898
fs.Create("/workspace/.devcontainer/experimental.json")
9999

@@ -115,7 +115,7 @@ func TestFindDevcontainerJSON(t *testing.T) {
115115

116116
// given
117117
fs := memfs.New()
118-
err := fs.MkdirAll("/workspace", 0600)
118+
err := fs.MkdirAll("/workspace", 0o600)
119119
require.NoError(t, err)
120120
fs.Create("/workspace/devcontainer.json")
121121

@@ -136,7 +136,7 @@ func TestFindDevcontainerJSON(t *testing.T) {
136136

137137
// given
138138
fs := memfs.New()
139-
err := fs.MkdirAll("/workspace/.devcontainer/sample", 0600)
139+
err := fs.MkdirAll("/workspace/.devcontainer/sample", 0o600)
140140
require.NoError(t, err)
141141
fs.Create("/workspace/.devcontainer/sample/devcontainer.json")
142142

git.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func CloneRepo(ctx context.Context, opts CloneRepoOptions) (bool, error) {
7373
}
7474
}
7575

76-
err = opts.Storage.MkdirAll(opts.Path, 0755)
76+
err = opts.Storage.MkdirAll(opts.Path, 0o755)
7777
if err != nil {
7878
return false, fmt.Errorf("mkdir %q: %w", opts.Path, err)
7979
}

git_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ func TestSetupRepoAuth(t *testing.T) {
386386

387387
func mustRead(t *testing.T, fs billy.Filesystem, path string) string {
388388
t.Helper()
389-
f, err := fs.OpenFile(path, os.O_RDONLY, 0644)
389+
f, err := fs.OpenFile(path, os.O_RDONLY, 0o644)
390390
require.NoError(t, err)
391391
content, err := io.ReadAll(f)
392392
require.NoError(t, err)

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ require (
127127
github.com/ebitengine/purego v0.5.0-alpha.1 // indirect
128128
github.com/emirpasic/gods v1.18.1 // indirect
129129
github.com/felixge/httpsnoop v1.0.3 // indirect
130+
github.com/frankban/quicktest v1.14.6 // indirect
130131
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
131132
github.com/go-chi/chi/v5 v5.0.10 // indirect
132133
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
@@ -223,6 +224,7 @@ require (
223224
github.com/richardartoul/molecule v1.0.1-0.20221107223329-32cfee06a052 // indirect
224225
github.com/rivo/uniseg v0.4.4 // indirect
225226
github.com/robfig/cron/v3 v3.0.1 // indirect
227+
github.com/rogpeppe/go-internal v1.12.0 // indirect
226228
github.com/rootless-containers/rootlesskit v1.1.0 // indirect
227229
github.com/secure-systems-lab/go-securesystemslib v0.7.0 // indirect
228230
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect

go.sum

+7-4
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
230230
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
231231
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
232232
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
233+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
233234
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
234235
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
235236
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
@@ -290,8 +291,8 @@ github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4Nij
290291
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
291292
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
292293
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
293-
github.com/frankban/quicktest v1.14.5 h1:dfYrrRyLtiqT9GyKXgdh+k4inNeTvmGbuSgZ3lx3GhA=
294-
github.com/frankban/quicktest v1.14.5/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
294+
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
295+
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
295296
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa h1:RDBNVkRviHZtvDvId8XSGPu3rmpmSe+wKRcEWNgsfWU=
296297
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA=
297298
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
@@ -697,6 +698,7 @@ github.com/pion/udp v0.1.4 h1:OowsTmu1Od3sD6i3fQUJxJn2fEvJO6L1TidgadtbTI8=
697698
github.com/pion/udp v0.1.4/go.mod h1:G8LDo56HsFwC24LIcnT4YIDU5qcB6NepqqjP0keL2us=
698699
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
699700
github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
701+
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
700702
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
701703
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
702704
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@@ -733,8 +735,9 @@ github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
733735
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
734736
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
735737
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
736-
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
737-
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
738+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
739+
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
740+
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
738741
github.com/rootless-containers/rootlesskit v1.1.0 h1:cRaRIYxY8oce4eE/zeAUZhgKu/4tU1p9YHN4+suwV7M=
739742
github.com/rootless-containers/rootlesskit v1.1.0/go.mod h1:H+o9ndNe7tS91WqU0/+vpvc+VaCd7TCIWaJjnV0ujUo=
740743
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

integration/integration_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func TestBuildIgnoreVarRunSecrets(t *testing.T) {
279279
},
280280
})
281281
dir := t.TempDir()
282-
err := os.WriteFile(filepath.Join(dir, "secret"), []byte("test"), 0644)
282+
err := os.WriteFile(filepath.Join(dir, "secret"), []byte("test"), 0o644)
283283
require.NoError(t, err)
284284
ctr, err := runEnvbuilder(t, options{
285285
env: []string{
@@ -360,6 +360,7 @@ func TestBuildFromDevcontainerInSubfolder(t *testing.T) {
360360
output := execContainer(t, ctr, "echo hello")
361361
require.Equal(t, "hello", strings.TrimSpace(output))
362362
}
363+
363364
func TestBuildFromDevcontainerInRoot(t *testing.T) {
364365
t.Parallel()
365366

@@ -772,7 +773,6 @@ func setupPassthroughRegistry(t *testing.T, image string, auth *registryAuth) st
772773
}
773774

774775
proxy.ServeHTTP(w, r)
775-
776776
}))
777777
return fmt.Sprintf("%s/%s", strings.TrimPrefix(srv.URL, "http://"), image)
778778
}

options_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func TestCLIOutput(t *testing.T) {
8989
require.NoError(t, err)
9090

9191
if *updateCLIOutputGoldenFiles {
92-
err = os.WriteFile("testdata/options.golden", b.Stdout.Bytes(), 0644)
92+
err = os.WriteFile("testdata/options.golden", b.Stdout.Bytes(), 0o644)
9393
require.NoError(t, err)
9494
t.Logf("updated golden file: testdata/options.golden")
9595
} else {
@@ -111,7 +111,6 @@ func runCLI() envbuilder.Options {
111111
i := cmd.Invoke().WithOS()
112112
fakeIO(i)
113113
err := i.Run()
114-
115114
if err != nil {
116115
panic("failed to run CLI: " + err.Error())
117116
}

scripts/check_fmt.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
list="$(go run mvdan.cc/[email protected] -l .)"
4+
if [[ -n $list ]]; then
5+
echo -e "error: The following files have changes:\n\n${list}\n\nDiff:\n\n"
6+
go run mvdan.cc/[email protected] -d .
7+
exit 1
8+
fi

scripts/docsgen/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func main() {
3030
mkd := "\n## Environment Variables\n\n" + options.Markdown()
3131
modifiedContent := readmeContent[:startIndex+len(startSection)] + mkd + readmeContent[endIndex:]
3232

33-
err = os.WriteFile(readmePath, []byte(modifiedContent), 0644)
33+
err = os.WriteFile(readmePath, []byte(modifiedContent), 0o644)
3434
if err != nil {
3535
panic(err)
3636
}

testutil/gittest/gittest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ func NewRepo(t *testing.T, fs billy.Filesystem, commits ...CommitFunc) *git.Repo
242242
// WriteFile writes a file to the filesystem.
243243
func WriteFile(t *testing.T, fs billy.Filesystem, path, content string) {
244244
t.Helper()
245-
file, err := fs.OpenFile(path, os.O_CREATE|os.O_RDWR, 0644)
245+
file, err := fs.OpenFile(path, os.O_CREATE|os.O_RDWR, 0o644)
246246
require.NoError(t, err)
247247
_, err = file.Write([]byte(content))
248248
require.NoError(t, err)

testutil/registrytest/registrytest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func WriteContainer(t *testing.T, serverURL, containerRef, mediaType string, fil
7474
require.NoError(t, err)
7575
}
7676
err := wtr.WriteHeader(&tar.Header{
77-
Mode: 0777,
77+
Mode: 0o777,
7878
Name: name,
7979
Typeflag: tar.TypeReg,
8080
Size: int64(len(data)),

0 commit comments

Comments
 (0)