Formatting the code with https://github.com/mvdan/gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -99,7 +99,7 @@ type Daemon struct {
|
| 99 | 99 |
func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
|
| 100 | 100 |
storageDriver := os.Getenv("DOCKER_GRAPHDRIVER")
|
| 101 | 101 |
|
| 102 |
- if err := os.MkdirAll(SockRoot, 0700); err != nil {
|
|
| 102 |
+ if err := os.MkdirAll(SockRoot, 0o700); err != nil {
|
|
| 103 | 103 |
return nil, errors.Wrapf(err, "failed to create daemon socket root %q", SockRoot) |
| 104 | 104 |
} |
| 105 | 105 |
|
| ... | ... |
@@ -110,7 +110,7 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
|
| 110 | 110 |
return nil, err |
| 111 | 111 |
} |
| 112 | 112 |
daemonRoot := filepath.Join(daemonFolder, "root") |
| 113 |
- if err := os.MkdirAll(daemonRoot, 0755); err != nil {
|
|
| 113 |
+ if err := os.MkdirAll(daemonRoot, 0o755); err != nil {
|
|
| 114 | 114 |
return nil, errors.Wrapf(err, "failed to create daemon root %q", daemonRoot) |
| 115 | 115 |
} |
| 116 | 116 |
|
| ... | ... |
@@ -140,7 +140,7 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
|
| 140 | 140 |
} |
| 141 | 141 |
|
| 142 | 142 |
if d.rootlessUser != nil {
|
| 143 |
- if err := os.Chmod(SockRoot, 0777); err != nil {
|
|
| 143 |
+ if err := os.Chmod(SockRoot, 0o777); err != nil {
|
|
| 144 | 144 |
return nil, err |
| 145 | 145 |
} |
| 146 | 146 |
uid, err := strconv.Atoi(d.rootlessUser.Uid) |
| ... | ... |
@@ -157,20 +157,20 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
|
| 157 | 157 |
if err := os.Chown(d.Root, uid, gid); err != nil {
|
| 158 | 158 |
return nil, err |
| 159 | 159 |
} |
| 160 |
- if err := os.MkdirAll(filepath.Dir(d.execRoot), 0700); err != nil {
|
|
| 160 |
+ if err := os.MkdirAll(filepath.Dir(d.execRoot), 0o700); err != nil {
|
|
| 161 | 161 |
return nil, err |
| 162 | 162 |
} |
| 163 | 163 |
if err := os.Chown(filepath.Dir(d.execRoot), uid, gid); err != nil {
|
| 164 | 164 |
return nil, err |
| 165 | 165 |
} |
| 166 |
- if err := os.MkdirAll(d.execRoot, 0700); err != nil {
|
|
| 166 |
+ if err := os.MkdirAll(d.execRoot, 0o700); err != nil {
|
|
| 167 | 167 |
return nil, err |
| 168 | 168 |
} |
| 169 | 169 |
if err := os.Chown(d.execRoot, uid, gid); err != nil {
|
| 170 | 170 |
return nil, err |
| 171 | 171 |
} |
| 172 | 172 |
d.rootlessXDGRuntimeDir = filepath.Join(d.Folder, "xdgrun") |
| 173 |
- if err := os.MkdirAll(d.rootlessXDGRuntimeDir, 0700); err != nil {
|
|
| 173 |
+ if err := os.MkdirAll(d.rootlessXDGRuntimeDir, 0o700); err != nil {
|
|
| 174 | 174 |
return nil, err |
| 175 | 175 |
} |
| 176 | 176 |
if err := os.Chown(d.rootlessXDGRuntimeDir, uid, gid); err != nil {
|
| ... | ... |
@@ -308,7 +308,7 @@ func (d *Daemon) Start(t testing.TB, args ...string) {
|
| 308 | 308 |
// StartWithError starts the daemon and return once it is ready to receive requests. |
| 309 | 309 |
// It returns an error in case it couldn't start. |
| 310 | 310 |
func (d *Daemon) StartWithError(args ...string) error {
|
| 311 |
- logFile, err := os.OpenFile(filepath.Join(d.Folder, "docker.log"), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600) |
|
| 311 |
+ logFile, err := os.OpenFile(filepath.Join(d.Folder, "docker.log"), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o600) |
|
| 312 | 312 |
if err != nil {
|
| 313 | 313 |
return errors.Wrapf(err, "[%s] failed to create logfile", d.id) |
| 314 | 314 |
} |
| ... | ... |
@@ -16,9 +16,7 @@ const ( |
| 16 | 16 |
defaultSwarmListenAddr = "0.0.0.0" |
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 |
-var ( |
|
| 20 |
- startArgs = []string{"--iptables=false", "--swarm-default-advertise-addr=lo"}
|
|
| 21 |
-) |
|
| 19 |
+var startArgs = []string{"--iptables=false", "--swarm-default-advertise-addr=lo"}
|
|
| 22 | 20 |
|
| 23 | 21 |
// StartNode (re)starts the daemon |
| 24 | 22 |
func (d *Daemon) StartNode(t testing.TB) {
|
| ... | ... |
@@ -34,7 +34,7 @@ func newDir(fake *Fake) error {
|
| 34 | 34 |
if err != nil {
|
| 35 | 35 |
return err |
| 36 | 36 |
} |
| 37 |
- if err := os.Chmod(tmp, 0755); err != nil {
|
|
| 37 |
+ if err := os.Chmod(tmp, 0o755); err != nil {
|
|
| 38 | 38 |
return err |
| 39 | 39 |
} |
| 40 | 40 |
fake.Dir = tmp |
| ... | ... |
@@ -91,11 +91,11 @@ func (f *Fake) addFile(file string, content []byte) error {
|
| 91 | 91 |
fp := filepath.Join(f.Dir, filepath.FromSlash(file)) |
| 92 | 92 |
dirpath := filepath.Dir(fp) |
| 93 | 93 |
if dirpath != "." {
|
| 94 |
- if err := os.MkdirAll(dirpath, 0755); err != nil {
|
|
| 94 |
+ if err := os.MkdirAll(dirpath, 0o755); err != nil {
|
|
| 95 | 95 |
return err |
| 96 | 96 |
} |
| 97 | 97 |
} |
| 98 |
- return os.WriteFile(fp, content, 0644) |
|
| 98 |
+ return os.WriteFile(fp, content, 0o644) |
|
| 99 | 99 |
} |
| 100 | 100 |
|
| 101 | 101 |
// Delete a file at a path |
| ... | ... |
@@ -86,7 +86,7 @@ func CreateInRegistry(ctx context.Context, repo string, auth *registry.AuthConfi |
| 86 | 86 |
defer os.RemoveAll(tmpDir) |
| 87 | 87 |
|
| 88 | 88 |
inPath := filepath.Join(tmpDir, "plugin") |
| 89 |
- if err := os.MkdirAll(inPath, 0755); err != nil {
|
|
| 89 |
+ if err := os.MkdirAll(inPath, 0o755); err != nil {
|
|
| 90 | 90 |
return errors.Wrap(err, "error creating plugin root") |
| 91 | 91 |
} |
| 92 | 92 |
|
| ... | ... |
@@ -163,10 +163,10 @@ func makePluginBundle(inPath string, opts ...CreateOpt) (io.ReadCloser, error) {
|
| 163 | 163 |
if err != nil {
|
| 164 | 164 |
return nil, err |
| 165 | 165 |
} |
| 166 |
- if err := os.WriteFile(filepath.Join(inPath, "config.json"), configJSON, 0644); err != nil {
|
|
| 166 |
+ if err := os.WriteFile(filepath.Join(inPath, "config.json"), configJSON, 0o644); err != nil {
|
|
| 167 | 167 |
return nil, err |
| 168 | 168 |
} |
| 169 |
- if err := os.MkdirAll(filepath.Join(inPath, "rootfs", filepath.Dir(p.Entrypoint[0])), 0755); err != nil {
|
|
| 169 |
+ if err := os.MkdirAll(filepath.Join(inPath, "rootfs", filepath.Dir(p.Entrypoint[0])), 0o755); err != nil {
|
|
| 170 | 170 |
return nil, errors.Wrap(err, "error creating plugin rootfs dir") |
| 171 | 171 |
} |
| 172 | 172 |
|
| ... | ... |
@@ -181,7 +181,7 @@ func makePluginBundle(inPath string, opts ...CreateOpt) (io.ReadCloser, error) {
|
| 181 | 181 |
} |
| 182 | 182 |
|
| 183 | 183 |
if stat == nil || stat.IsDir() {
|
| 184 |
- var mode os.FileMode = 0755 |
|
| 184 |
+ var mode os.FileMode = 0o755 |
|
| 185 | 185 |
if stat != nil {
|
| 186 | 186 |
mode = stat.Mode() |
| 187 | 187 |
} |
| ... | ... |
@@ -189,7 +189,7 @@ func makePluginBundle(inPath string, opts ...CreateOpt) (io.ReadCloser, error) {
|
| 189 | 189 |
return nil, errors.Wrap(err, "error preparing plugin mount destination path") |
| 190 | 190 |
} |
| 191 | 191 |
} else {
|
| 192 |
- if err := os.MkdirAll(filepath.Join(inPath, "rootfs", filepath.Dir(m.Destination)), 0755); err != nil {
|
|
| 192 |
+ if err := os.MkdirAll(filepath.Join(inPath, "rootfs", filepath.Dir(m.Destination)), 0o755); err != nil {
|
|
| 193 | 193 |
return nil, errors.Wrap(err, "error preparing plugin mount destination dir") |
| 194 | 194 |
} |
| 195 | 195 |
f, err := os.Create(filepath.Join(inPath, "rootfs", m.Destination)) |
| ... | ... |
@@ -78,7 +78,7 @@ http: |
| 78 | 78 |
username = "testuser" |
| 79 | 79 |
password = "testpassword" |
| 80 | 80 |
email = "test@test.org" |
| 81 |
- err := os.WriteFile(htpasswdPath, []byte(userpasswd), os.FileMode(0644)) |
|
| 81 |
+ err := os.WriteFile(htpasswdPath, []byte(userpasswd), os.FileMode(0o644)) |
|
| 82 | 82 |
assert.NilError(t, err) |
| 83 | 83 |
authTemplate = fmt.Sprintf(`auth: |
| 84 | 84 |
htpasswd: |
| ... | ... |
@@ -190,7 +190,7 @@ func (r *V2) ReadBlobContents(t testing.TB, blobDigest digest.Digest) []byte {
|
| 190 | 190 |
// WriteBlobContents write the file corresponding to the specified digest with the given content |
| 191 | 191 |
func (r *V2) WriteBlobContents(t testing.TB, blobDigest digest.Digest, data []byte) {
|
| 192 | 192 |
t.Helper() |
| 193 |
- err := os.WriteFile(r.getBlobFilename(blobDigest), data, os.FileMode(0644)) |
|
| 193 |
+ err := os.WriteFile(r.getBlobFilename(blobDigest), data, os.FileMode(0o644)) |
|
| 194 | 194 |
assert.NilError(t, err, "unable to write malicious data blob") |
| 195 | 195 |
} |
| 196 | 196 |
|