From 765844e419f7ec021d9f097581b2224c5b5199c4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn <github@gone.nl> Date: Sat, 22 Jan 2022 13:04:46 +0100 Subject: [PATCH] distribution/xfer: un-export NewTransfer() This is also only used internally, so no need to export. Signed-off-by: Sebastiaan van Stijn <github@gone.nl> --- distribution/xfer/download.go | 4 ++-- distribution/xfer/transfer.go | 4 ++-- distribution/xfer/transfer_test.go | 12 ++++++------ distribution/xfer/upload.go | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/distribution/xfer/download.go b/distribution/xfer/download.go index 83b41ecb4d..718d463b57 100644 --- a/distribution/xfer/download.go +++ b/distribution/xfer/download.go @@ -225,7 +225,7 @@ func (ldm *LayerDownloadManager) Download(ctx context.Context, initialRootFS ima func (ldm *LayerDownloadManager) makeDownloadFunc(descriptor DownloadDescriptor, parentLayer layer.ChainID, parentDownload *downloadTransfer) DoFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) Transfer { d := &downloadTransfer{ - Transfer: NewTransfer(), + Transfer: newTransfer(), layerStore: ldm.layerStore, } @@ -389,7 +389,7 @@ func (ldm *LayerDownloadManager) makeDownloadFunc(descriptor DownloadDescriptor, func (ldm *LayerDownloadManager) makeDownloadFuncFromDownload(descriptor DownloadDescriptor, sourceDownload *downloadTransfer, parentDownload *downloadTransfer) DoFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) Transfer { d := &downloadTransfer{ - Transfer: NewTransfer(), + Transfer: newTransfer(), layerStore: ldm.layerStore, } diff --git a/distribution/xfer/transfer.go b/distribution/xfer/transfer.go index 724ca6ce46..cff403456b 100644 --- a/distribution/xfer/transfer.go +++ b/distribution/xfer/transfer.go @@ -77,8 +77,8 @@ type transfer struct { broadcastSyncChan chan struct{} } -// NewTransfer creates a new transfer. -func NewTransfer() Transfer { +// newTransfer creates a new transfer. +func newTransfer() Transfer { t := &transfer{ watchers: make(map[chan struct{}]*Watcher), running: make(chan struct{}), diff --git a/distribution/xfer/transfer_test.go b/distribution/xfer/transfer_test.go index 6364ae0aa5..a13d118a00 100644 --- a/distribution/xfer/transfer_test.go +++ b/distribution/xfer/transfer_test.go @@ -17,7 +17,7 @@ func TestTransfer(t *testing.T) { t.Errorf("%s: transfer function not started even though concurrency limit not reached", id) } - xfer := NewTransfer() + xfer := newTransfer() go func() { for i := 0; i <= 10; i++ { progressChan <- progress.Progress{ID: id, Action: "testing", Current: int64(i), Total: 10} @@ -73,7 +73,7 @@ func TestConcurrencyLimit(t *testing.T) { makeXferFunc := func(id string) DoFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, _ chan<- struct{}) Transfer { - xfer := NewTransfer() + xfer := newTransfer() go func() { <-start totalJobs := atomic.AddInt32(&runningJobs, 1) @@ -132,7 +132,7 @@ func TestInactiveJobs(t *testing.T) { makeXferFunc := func(id string) DoFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) Transfer { - xfer := NewTransfer() + xfer := newTransfer() go func() { <-start totalJobs := atomic.AddInt32(&runningJobs, 1) @@ -192,7 +192,7 @@ func TestWatchRelease(t *testing.T) { makeXferFunc := func(id string) DoFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, _ chan<- struct{}) Transfer { - xfer := NewTransfer() + xfer := newTransfer() go func() { defer func() { close(progressChan) @@ -281,7 +281,7 @@ func TestWatchRelease(t *testing.T) { func TestWatchFinishedTransfer(t *testing.T) { makeXferFunc := func(id string) DoFunc { return func(progressChan chan<- progress.Progress, _ <-chan struct{}, _ chan<- struct{}) Transfer { - xfer := NewTransfer() + xfer := newTransfer() go func() { // Finish immediately close(progressChan) @@ -324,7 +324,7 @@ func TestDuplicateTransfer(t *testing.T) { makeXferFunc := func(id string) DoFunc { return func(progressChan chan<- progress.Progress, _ <-chan struct{}, _ chan<- struct{}) Transfer { atomic.AddInt32(&xferFuncCalls, 1) - xfer := NewTransfer() + xfer := newTransfer() go func() { defer func() { close(progressChan) diff --git a/distribution/xfer/upload.go b/distribution/xfer/upload.go index a369daff5c..cc4e0daf9d 100644 --- a/distribution/xfer/upload.go +++ b/distribution/xfer/upload.go @@ -105,7 +105,7 @@ func (lum *LayerUploadManager) Upload(ctx context.Context, layers []UploadDescri func (lum *LayerUploadManager) makeUploadFunc(descriptor UploadDescriptor) DoFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) Transfer { u := &uploadTransfer{ - Transfer: NewTransfer(), + Transfer: newTransfer(), } go func() {