image: format code with gofumpt

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-08-24 17:57:22 +02:00
parent 976da91fb7
commit 87cedbe443
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
3 changed files with 12 additions and 12 deletions

View file

@ -47,10 +47,10 @@ func newFSStore(root string) (*fs, error) {
s := &fs{
root: root,
}
if err := os.MkdirAll(filepath.Join(root, contentDirName, string(digest.Canonical)), 0700); err != nil {
if err := os.MkdirAll(filepath.Join(root, contentDirName, string(digest.Canonical)), 0o700); err != nil {
return nil, errors.Wrap(err, "failed to create storage backend")
}
if err := os.MkdirAll(filepath.Join(root, metadataDirName, string(digest.Canonical)), 0700); err != nil {
if err := os.MkdirAll(filepath.Join(root, metadataDirName, string(digest.Canonical)), 0o700); err != nil {
return nil, errors.Wrap(err, "failed to create storage backend")
}
return s, nil
@ -118,7 +118,7 @@ func (s *fs) Set(data []byte) (digest.Digest, error) {
}
dgst := digest.FromBytes(data)
if err := ioutils.AtomicWriteFile(s.contentFile(dgst), data, 0600); err != nil {
if err := ioutils.AtomicWriteFile(s.contentFile(dgst), data, 0o600); err != nil {
return "", errors.Wrap(err, "failed to write digest data")
}
@ -145,10 +145,10 @@ func (s *fs) SetMetadata(dgst digest.Digest, key string, data []byte) error {
}
baseDir := filepath.Join(s.metadataDir(dgst))
if err := os.MkdirAll(baseDir, 0700); err != nil {
if err := os.MkdirAll(baseDir, 0o700); err != nil {
return err
}
return ioutils.AtomicWriteFile(filepath.Join(s.metadataDir(dgst), key), data, 0600)
return ioutils.AtomicWriteFile(filepath.Join(s.metadataDir(dgst), key), data, 0o600)
}
// GetMetadata returns metadata for a given digest.

View file

@ -66,7 +66,7 @@ func TestFSInvalidRoot(t *testing.T) {
for _, tc := range tcases {
root := filepath.Join(tmpdir, tc.root)
filePath := filepath.Join(tmpdir, tc.invalidFile)
err := os.MkdirAll(filepath.Dir(filePath), 0700)
err := os.MkdirAll(filepath.Dir(filePath), 0o700)
assert.Check(t, err)
f, err := os.Create(filePath)
@ -128,7 +128,7 @@ func TestFSInvalidWalker(t *testing.T) {
fooID, err := store.Set([]byte("foo"))
assert.Check(t, err)
err = os.WriteFile(filepath.Join(store.(*fs).root, contentDirName, "sha256/foobar"), []byte("foobar"), 0600)
err = os.WriteFile(filepath.Join(store.(*fs).root, contentDirName, "sha256/foobar"), []byte("foobar"), 0o600)
assert.Check(t, err)
n := 0

View file

@ -301,7 +301,7 @@ func (s *saveSession) save(outStream io.Writer) error {
if len(reposLegacy) > 0 {
reposFile := filepath.Join(tempDir, legacyRepositoriesFileName)
rf, err := os.OpenFile(reposFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
rf, err := os.OpenFile(reposFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o644)
if err != nil {
return err
}
@ -319,7 +319,7 @@ func (s *saveSession) save(outStream io.Writer) error {
}
manifestPath := filepath.Join(tempDir, manifestFileName)
f, err := os.OpenFile(manifestPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f, err := os.OpenFile(manifestPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o644)
if err != nil {
return err
}
@ -460,11 +460,11 @@ func (s *saveSession) saveLayer(id layer.ChainID, legacyImg image.V1Image, creat
cfgDgst := digest.FromBytes(imageConfig)
configPath := filepath.Join(outDir, cfgDgst.Algorithm().String(), cfgDgst.Encoded())
if err := os.MkdirAll(filepath.Dir(configPath), 0755); err != nil {
if err := os.MkdirAll(filepath.Dir(configPath), 0o755); err != nil {
return distribution.Descriptor{}, errors.Wrap(err, "could not create layer dir parent")
}
if err := os.WriteFile(configPath, imageConfig, 0644); err != nil {
if err := os.WriteFile(configPath, imageConfig, 0o644); err != nil {
return distribution.Descriptor{}, err
}
@ -485,7 +485,7 @@ func (s *saveSession) saveLayer(id layer.ChainID, legacyImg image.V1Image, creat
// We use sequential file access to avoid depleting the standby list on
// Windows. On Linux, this equates to a regular os.Create.
if err := os.MkdirAll(filepath.Dir(layerPath), 0755); err != nil {
if err := os.MkdirAll(filepath.Dir(layerPath), 0o755); err != nil {
return distribution.Descriptor{}, errors.Wrap(err, "could not create layer dir parent")
}
tarFile, err := sequential.Create(layerPath)