From 31d5dd517500a7eb912aab6f21a6fced26298846 Mon Sep 17 00:00:00 2001 From: Tony Holdstock-Brown Date: Thu, 24 Mar 2016 11:33:01 -0700 Subject: [PATCH] utulize config log format within gc Signed-off-by: Tony Holdstock-Brown --- registry/garbagecollect.go | 13 +++++++++---- registry/garbagecollect_test.go | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/registry/garbagecollect.go b/registry/garbagecollect.go index 5e165aea..add25a73 100644 --- a/registry/garbagecollect.go +++ b/registry/garbagecollect.go @@ -17,9 +17,7 @@ import ( "github.com/spf13/cobra" ) -func markAndSweep(storageDriver driver.StorageDriver) error { - ctx := context.Background() - +func markAndSweep(ctx context.Context, storageDriver driver.StorageDriver) error { // Construct a registry registry, err := storage.NewRegistry(ctx, storageDriver) if err != nil { @@ -141,7 +139,14 @@ var GCCmd = &cobra.Command{ os.Exit(1) } - err = markAndSweep(driver) + ctx := context.Background() + ctx, err = configureLogging(ctx, config) + if err != nil { + fmt.Fprintf(os.Stderr, "unable to configure logging with config: %s", err) + os.Exit(1) + } + + err = markAndSweep(ctx, driver) if err != nil { fmt.Fprintf(os.Stderr, "failed to garbage collect: %v", err) os.Exit(1) diff --git a/registry/garbagecollect_test.go b/registry/garbagecollect_test.go index 951a9e81..6096e758 100644 --- a/registry/garbagecollect_test.go +++ b/registry/garbagecollect_test.go @@ -161,7 +161,7 @@ func TestNoDeletionNoEffect(t *testing.T) { } // Run GC - err = markAndSweep(inmemoryDriver) + err = markAndSweep(context.Background(), inmemoryDriver) if err != nil { t.Fatalf("Failed mark and sweep: %v", err) } @@ -193,7 +193,7 @@ func TestDeletionHasEffect(t *testing.T) { manifests.Delete(ctx, image3.manifestDigest) // Run GC - err = markAndSweep(inmemoryDriver) + err = markAndSweep(context.Background(), inmemoryDriver) if err != nil { t.Fatalf("Failed mark and sweep: %v", err) } @@ -327,7 +327,7 @@ func TestOrphanBlobDeleted(t *testing.T) { uploadRandomSchema2Image(t, repo) // Run GC - err = markAndSweep(inmemoryDriver) + err = markAndSweep(context.Background(), inmemoryDriver) if err != nil { t.Fatalf("Failed mark and sweep: %v", err) }