distribution: format code with gofumpt
Formatting the code with https://github.com/mvdan/gofumpt Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
b7f5db432f
commit
846bcd7dd1
7 changed files with 25 additions and 8 deletions
|
@ -29,7 +29,7 @@ type FSMetadataStore struct {
|
|||
|
||||
// NewFSMetadataStore creates a new filesystem-based metadata store.
|
||||
func NewFSMetadataStore(basePath string) (*FSMetadataStore, error) {
|
||||
if err := os.MkdirAll(basePath, 0700); err != nil {
|
||||
if err := os.MkdirAll(basePath, 0o700); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &FSMetadataStore{
|
||||
|
@ -57,10 +57,10 @@ func (store *FSMetadataStore) Set(namespace, key string, value []byte) error {
|
|||
defer store.Unlock()
|
||||
|
||||
path := store.path(namespace, key)
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutils.AtomicWriteFile(path, value, 0644)
|
||||
return ioutils.AtomicWriteFile(path, value, 0o644)
|
||||
}
|
||||
|
||||
// Delete removes data indexed by namespace and key. The data file named after
|
||||
|
|
|
@ -195,7 +195,7 @@ func TestValidateManifest(t *testing.T) {
|
|||
|
||||
func TestFormatPlatform(t *testing.T) {
|
||||
var platform ocispec.Platform
|
||||
var result = formatPlatform(platform)
|
||||
result := formatPlatform(platform)
|
||||
if strings.HasPrefix(result, "unknown") {
|
||||
t.Fatal("expected formatPlatform to show a known platform")
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/Microsoft/hcsshim/osversion"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/docker/distribution"
|
||||
"github.com/docker/distribution/manifest/manifestlist"
|
||||
|
@ -19,7 +20,6 @@ import (
|
|||
"github.com/docker/distribution/registry/client/transport"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/containerd/containerd/log"
|
||||
)
|
||||
|
||||
var _ distribution.Describable = &layerDescriptor{}
|
||||
|
|
|
@ -688,6 +688,7 @@ func (bla byLikeness) Less(i, j int) bool {
|
|||
bMatch := numOfMatchingPathComponents(bla.arr[j].SourceRepository, bla.pathComponents)
|
||||
return aMatch > bMatch
|
||||
}
|
||||
|
||||
func (bla byLikeness) Swap(i, j int) {
|
||||
bla.arr[i], bla.arr[j] = bla.arr[j], bla.arr[i]
|
||||
}
|
||||
|
|
|
@ -466,24 +466,28 @@ func TestLayerAlreadyExists(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
type mockReferenceStore struct {
|
||||
}
|
||||
type mockReferenceStore struct{}
|
||||
|
||||
func (s *mockReferenceStore) References(id digest.Digest) []reference.Named {
|
||||
return []reference.Named{}
|
||||
}
|
||||
|
||||
func (s *mockReferenceStore) ReferencesByName(ref reference.Named) []refstore.Association {
|
||||
return []refstore.Association{}
|
||||
}
|
||||
|
||||
func (s *mockReferenceStore) AddTag(ref reference.Named, id digest.Digest, force bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *mockReferenceStore) AddDigest(ref reference.Canonical, id digest.Digest, force bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *mockReferenceStore) Delete(ref reference.Named) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (s *mockReferenceStore) Get(ref reference.Named) (digest.Digest, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
@ -641,14 +645,17 @@ func (m *mockRepo) Named() reference.Named {
|
|||
m.t.Fatalf("Named() not implemented")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockRepo) Manifests(ctc context.Context, options ...distribution.ManifestServiceOption) (distribution.ManifestService, error) {
|
||||
m.t.Fatalf("Manifests() not implemented")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *mockRepo) Tags(ctc context.Context) distribution.TagService {
|
||||
m.t.Fatalf("Tags() not implemented")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockRepo) Blobs(ctx context.Context) distribution.BlobStore {
|
||||
return &mockBlobStore{
|
||||
repo: m,
|
||||
|
@ -671,6 +678,7 @@ func (m *mockBlobStore) Stat(ctx context.Context, dgst digest.Digest) (distribut
|
|||
}
|
||||
return distribution.Descriptor{}, distribution.ErrBlobUnknown
|
||||
}
|
||||
|
||||
func (m *mockBlobStore) Get(ctx context.Context, dgst digest.Digest) ([]byte, error) {
|
||||
m.repo.t.Fatal("Get() not implemented")
|
||||
return nil, nil
|
||||
|
@ -690,14 +698,17 @@ func (m *mockBlobStore) Create(ctx context.Context, options ...distribution.Blob
|
|||
m.repo.t.Fatal("Create() not implemented")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *mockBlobStore) Resume(ctx context.Context, id string) (distribution.BlobWriter, error) {
|
||||
m.repo.t.Fatal("Resume() not implemented")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *mockBlobStore) Delete(ctx context.Context, dgst digest.Digest) error {
|
||||
m.repo.t.Fatal("Delete() not implemented")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockBlobStore) ServeBlob(ctx context.Context, w http.ResponseWriter, r *http.Request, dgst digest.Digest) error {
|
||||
m.repo.t.Fatalf("ServeBlob() not implemented")
|
||||
return nil
|
||||
|
@ -713,18 +724,22 @@ var _ metadata.V2MetadataService = &mockV2MetadataService{}
|
|||
func (*mockV2MetadataService) GetMetadata(diffID layer.DiffID) ([]metadata.V2Metadata, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (*mockV2MetadataService) GetDiffID(dgst digest.Digest) (layer.DiffID, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (m *mockV2MetadataService) Add(diffID layer.DiffID, metadata metadata.V2Metadata) error {
|
||||
m.added = append(m.added, metadata)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockV2MetadataService) TagAndAdd(diffID layer.DiffID, hmacKey []byte, meta metadata.V2Metadata) error {
|
||||
meta.HMAC = metadata.ComputeV2MetadataHMAC(hmacKey, &meta)
|
||||
m.Add(diffID, meta)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockV2MetadataService) Remove(metadata metadata.V2Metadata) error {
|
||||
m.removed = append(m.removed, metadata)
|
||||
return nil
|
||||
|
|
|
@ -96,7 +96,6 @@ type DownloadDescriptor interface {
|
|||
// registered layer. This method is called if a cast to DigestRegisterer is
|
||||
// successful.
|
||||
type DigestRegisterer interface {
|
||||
|
||||
// TODO existing implementations in distribution and builder-next swallow errors
|
||||
// when registering the diffID. Consider changing the Registered signature
|
||||
// to return the error.
|
||||
|
|
|
@ -126,6 +126,7 @@ func (ls *mockLayerStore) Get(chainID layer.ChainID) (layer.Layer, error) {
|
|||
func (ls *mockLayerStore) Release(l layer.Layer) ([]layer.Metadata, error) {
|
||||
return []layer.Metadata{}, nil
|
||||
}
|
||||
|
||||
func (ls *mockLayerStore) CreateRWLayer(string, layer.ChainID, *layer.CreateRWLayerOpts) (layer.RWLayer, error) {
|
||||
return nil, errors.New("not implemented")
|
||||
}
|
||||
|
@ -137,6 +138,7 @@ func (ls *mockLayerStore) GetRWLayer(string) (layer.RWLayer, error) {
|
|||
func (ls *mockLayerStore) ReleaseRWLayer(layer.RWLayer) ([]layer.Metadata, error) {
|
||||
return nil, errors.New("not implemented")
|
||||
}
|
||||
|
||||
func (ls *mockLayerStore) GetMountID(string) (string, error) {
|
||||
return "", errors.New("not implemented")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue