Skip to content

Commit 6422ff2

Browse files
committed
deprecate pkg/atomicwriter, migrate to github.com/moby/sys/atomicwriter
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent d7b743b commit 6422ff2

20 files changed

Lines changed: 277 additions & 338 deletions

File tree

container/container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ import (
3030
"github.com/docker/docker/image"
3131
libcontainerdtypes "github.com/docker/docker/libcontainerd/types"
3232
"github.com/docker/docker/oci"
33-
"github.com/docker/docker/pkg/atomicwriter"
3433
"github.com/docker/docker/pkg/idtools"
3534
"github.com/docker/docker/restartmanager"
3635
"github.com/docker/docker/volume"
3736
volumemounts "github.com/docker/docker/volume/mounts"
3837
"github.com/docker/go-units"
3938
agentexec "github.com/moby/swarmkit/v2/agent/exec"
39+
"github.com/moby/sys/atomicwriter"
4040
"github.com/moby/sys/signal"
4141
"github.com/moby/sys/symlink"
4242
ocispec "github.com/opencontainers/image-spec/specs-go/v1"

daemon/cluster/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"path/filepath"
77
"strings"
88

9-
"github.com/docker/docker/pkg/atomicwriter"
9+
"github.com/moby/sys/atomicwriter"
1010
)
1111

1212
// convertKVStringsToMap converts ["key=value"] to {"key":"value"}

daemon/graphdriver/overlay2/overlay.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ import (
2323
"github.com/docker/docker/internal/containerfs"
2424
"github.com/docker/docker/internal/directory"
2525
"github.com/docker/docker/pkg/archive"
26-
"github.com/docker/docker/pkg/atomicwriter"
2726
"github.com/docker/docker/pkg/chrootarchive"
2827
"github.com/docker/docker/pkg/idtools"
2928
"github.com/docker/docker/quota"
3029
"github.com/docker/go-units"
3130
"github.com/moby/locker"
31+
"github.com/moby/sys/atomicwriter"
3232
"github.com/moby/sys/mount"
3333
"github.com/moby/sys/userns"
3434
"github.com/opencontainers/selinux/go-selinux/label"

daemon/id.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"os"
55
"path/filepath"
66

7-
"github.com/docker/docker/pkg/atomicwriter"
87
"github.com/google/uuid"
8+
"github.com/moby/sys/atomicwriter"
99
"github.com/pkg/errors"
1010
)
1111

daemon/runtime_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"github.com/docker/docker/daemon/config"
2222
"github.com/docker/docker/errdefs"
2323
"github.com/docker/docker/libcontainerd/shimopts"
24-
"github.com/docker/docker/pkg/atomicwriter"
24+
"github.com/moby/sys/atomicwriter"
2525
"github.com/opencontainers/runtime-spec/specs-go/features"
2626
"github.com/pkg/errors"
2727
)

distribution/metadata/metadata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"path/filepath"
66
"sync"
77

8-
"github.com/docker/docker/pkg/atomicwriter"
8+
"github.com/moby/sys/atomicwriter"
99
)
1010

1111
// Store implements a K/V store for mapping distribution-related IDs

image/fs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"sync"
99

1010
"github.com/containerd/log"
11-
"github.com/docker/docker/pkg/atomicwriter"
11+
"github.com/moby/sys/atomicwriter"
1212
"github.com/opencontainers/go-digest"
1313
"github.com/pkg/errors"
1414
)

layer/filestore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212

1313
"github.com/containerd/log"
1414
"github.com/docker/distribution"
15-
"github.com/docker/docker/pkg/atomicwriter"
1615
"github.com/docker/docker/pkg/ioutils"
16+
"github.com/moby/sys/atomicwriter"
1717
"github.com/opencontainers/go-digest"
1818
"github.com/pkg/errors"
1919
)

libnetwork/internal/resolvconf/resolvconf.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"text/template"
3232

3333
"github.com/containerd/log"
34-
"github.com/docker/docker/pkg/atomicwriter"
34+
"github.com/moby/sys/atomicwriter"
3535
"github.com/opencontainers/go-digest"
3636
"github.com/pkg/errors"
3737
)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package atomicwriter
2+
3+
import (
4+
"io"
5+
"os"
6+
7+
"github.com/moby/sys/atomicwriter"
8+
)
9+
10+
// New returns a WriteCloser so that writing to it writes to a
11+
// temporary file and closing it atomically changes the temporary file to
12+
// destination path. Writing and closing concurrently is not allowed.
13+
// NOTE: umask is not considered for the file's permissions.
14+
//
15+
// New uses [sequential.CreateTemp] to use sequential file access on Windows,
16+
// avoiding depleting the standby list un-necessarily. On Linux, this equates to
17+
// a regular [os.CreateTemp]. Refer to the [Win32 API documentation] for details
18+
// on sequential file access.
19+
//
20+
// Deprecated: use [atomicwriter.New] instead.
21+
//
22+
// [Win32 API documentation]: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#FILE_FLAG_SEQUENTIAL_SCAN
23+
func New(filename string, perm os.FileMode) (io.WriteCloser, error) {
24+
return atomicwriter.New(filename, perm)
25+
}
26+
27+
// WriteFile atomically writes data to a file named by filename and with the
28+
// specified permission bits. The given filename is created if it does not exist,
29+
// but the destination directory must exist. It can be used as a drop-in replacement
30+
// for [os.WriteFile], but currently does not allow the destination path to be
31+
// a symlink. WriteFile is implemented using [New] for its implementation.
32+
//
33+
// NOTE: umask is not considered for the file's permissions.
34+
//
35+
// Deprecated: use [atomicwriter.WriteFile] instead.
36+
func WriteFile(filename string, data []byte, perm os.FileMode) error {
37+
return atomicwriter.WriteFile(filename, data, perm)
38+
}
39+
40+
// WriteSet is used to atomically write a set
41+
// of files and ensure they are visible at the same time.
42+
// Must be committed to a new directory.
43+
//
44+
// Deprecated: use [atomicwriter.WriteSet] instead.
45+
type WriteSet = atomicwriter.WriteSet
46+
47+
// NewWriteSet creates a new atomic write set to
48+
// atomically create a set of files. The given directory
49+
// is used as the base directory for storing files before
50+
// commit. If no temporary directory is given the system
51+
// default is used.
52+
//
53+
// Deprecated: use [atomicwriter.NewWriteSet] instead.
54+
func NewWriteSet(tmpDir string) (*atomicwriter.WriteSet, error) {
55+
return atomicwriter.NewWriteSet(tmpDir)
56+
}

0 commit comments

Comments
 (0)