浏览代码

Merge pull request #29345 from yuexiao-wang/fix-err-info

Fix incorrect words and formats in image
Vincent Demeester 8 年之前
父节点
当前提交
ba1c20f8d6
共有 5 个文件被更改,包括 36 次插入36 次删除
  1. 2 2
      image/fs.go
  2. 19 19
      image/fs_test.go
  3. 12 12
      image/image.go
  4. 2 2
      image/image_test.go
  5. 1 1
      image/tarexport/tarexport.go

+ 2 - 2
image/fs.go

@@ -75,7 +75,7 @@ func (s *fs) Walk(f DigestWalkFunc) error {
 	for _, v := range dir {
 		dgst := digest.NewDigestFromHex(string(digest.Canonical), v.Name())
 		if err := dgst.Validate(); err != nil {
-			logrus.Debugf("Skipping invalid digest %s: %s", dgst, err)
+			logrus.Debugf("skipping invalid digest %s: %s", dgst, err)
 			continue
 		}
 		if err := f(dgst); err != nil {
@@ -113,7 +113,7 @@ func (s *fs) Set(data []byte) (digest.Digest, error) {
 	defer s.Unlock()
 
 	if len(data) == 0 {
-		return "", fmt.Errorf("Invalid empty data")
+		return "", fmt.Errorf("invalid empty data")
 	}
 
 	dgst := digest.FromBytes(data)

+ 19 - 19
image/fs_test.go

@@ -52,7 +52,7 @@ func TestFSGetInvalidData(t *testing.T) {
 
 	_, err = fs.Get(id)
 	if err == nil {
-		t.Fatal("Expected get to fail after data modification.")
+		t.Fatal("expected get to fail after data modification.")
 	}
 }
 
@@ -75,7 +75,7 @@ func TestFSInvalidSet(t *testing.T) {
 
 	_, err = fs.Set([]byte("foobar"))
 	if err == nil {
-		t.Fatal("Expecting error from invalid filesystem data.")
+		t.Fatal("expected error from invalid filesystem data.")
 	}
 }
 
@@ -109,7 +109,7 @@ func TestFSInvalidRoot(t *testing.T) {
 
 		_, err = NewFSStoreBackend(root)
 		if err == nil {
-			t.Fatalf("Expected error from root %q and invlid file %q", tc.root, tc.invalidFile)
+			t.Fatalf("expected error from root %q and invalid file %q", tc.root, tc.invalidFile)
 		}
 
 		os.RemoveAll(root)
@@ -154,18 +154,18 @@ func testMetadataGetSet(t *testing.T, store StoreBackend) {
 
 	_, err = store.GetMetadata(id2, "tkey2")
 	if err == nil {
-		t.Fatal("Expected error for getting metadata for unknown key")
+		t.Fatal("expected error for getting metadata for unknown key")
 	}
 
 	id3 := digest.FromBytes([]byte("baz"))
 	err = store.SetMetadata(id3, "tkey", []byte("tval"))
 	if err == nil {
-		t.Fatal("Expected error for setting metadata for unknown ID.")
+		t.Fatal("expected error for setting metadata for unknown ID.")
 	}
 
 	_, err = store.GetMetadata(id3, "tkey")
 	if err == nil {
-		t.Fatal("Expected error for getting metadata for unknown ID.")
+		t.Fatal("expected error for getting metadata for unknown ID.")
 	}
 }
 
@@ -234,16 +234,16 @@ func TestFSInvalidWalker(t *testing.T) {
 	n := 0
 	err = fs.Walk(func(id digest.Digest) error {
 		if id != fooID {
-			t.Fatalf("Invalid walker ID %q, expected %q", id, fooID)
+			t.Fatalf("invalid walker ID %q, expected %q", id, fooID)
 		}
 		n++
 		return nil
 	})
 	if err != nil {
-		t.Fatalf("Invalid data should not have caused walker error, got %v", err)
+		t.Fatalf("invalid data should not have caused walker error, got %v", err)
 	}
 	if n != 1 {
-		t.Fatalf("Expected 1 walk initialization, got %d", n)
+		t.Fatalf("expected 1 walk initialization, got %d", n)
 	}
 }
 
@@ -261,7 +261,7 @@ func testGetSet(t *testing.T, store StoreBackend) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	// skipping use of digest pkg because its used by the implementation
+	// skipping use of digest pkg because it is used by the implementation
 	h := sha256.New()
 	_, err = h.Write(randomInput)
 	if err != nil {
@@ -278,14 +278,14 @@ func testGetSet(t *testing.T, store StoreBackend) {
 			t.Fatal(err)
 		}
 		if id != tc.expected {
-			t.Fatalf("Expected ID %q, got %q", tc.expected, id)
+			t.Fatalf("expected ID %q, got %q", tc.expected, id)
 		}
 	}
 
 	for _, emptyData := range [][]byte{nil, {}} {
 		_, err := store.Set(emptyData)
 		if err == nil {
-			t.Fatal("Expected error for nil input.")
+			t.Fatal("expected error for nil input.")
 		}
 	}
 
@@ -295,14 +295,14 @@ func testGetSet(t *testing.T, store StoreBackend) {
 			t.Fatal(err)
 		}
 		if bytes.Compare(data, tc.input) != 0 {
-			t.Fatalf("Expected data %q, got %q", tc.input, data)
+			t.Fatalf("expected data %q, got %q", tc.input, data)
 		}
 	}
 
 	for _, key := range []digest.Digest{"foobar:abc", "sha256:abc", "sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2a"} {
 		_, err := store.Get(key)
 		if err == nil {
-			t.Fatalf("Expected error for ID %q.", key)
+			t.Fatalf("expected error for ID %q.", key)
 		}
 	}
 
@@ -325,7 +325,7 @@ func testDelete(t *testing.T, store StoreBackend) {
 
 	_, err = store.Get(id)
 	if err == nil {
-		t.Fatalf("Expected getting deleted item %q to fail", id)
+		t.Fatalf("expected getting deleted item %q to fail", id)
 	}
 	_, err = store.Get(id2)
 	if err != nil {
@@ -338,7 +338,7 @@ func testDelete(t *testing.T, store StoreBackend) {
 	}
 	_, err = store.Get(id2)
 	if err == nil {
-		t.Fatalf("Expected getting deleted item %q to fail", id2)
+		t.Fatalf("expected getting deleted item %q to fail", id2)
 	}
 }
 
@@ -366,10 +366,10 @@ func testWalker(t *testing.T, store StoreBackend) {
 	}
 
 	if n != 2 {
-		t.Fatalf("Expected 2 walk initializations, got %d", n)
+		t.Fatalf("expected 2 walk initializations, got %d", n)
 	}
 	if len(tcases) != 0 {
-		t.Fatalf("Expected empty unwalked set, got %+v", tcases)
+		t.Fatalf("expected empty unwalked set, got %+v", tcases)
 	}
 
 	// stop on error
@@ -379,6 +379,6 @@ func testWalker(t *testing.T, store StoreBackend) {
 		return errors.New("")
 	})
 	if err == nil {
-		t.Fatalf("Exected error from walker.")
+		t.Fatalf("expected error from walker.")
 	}
 }

+ 12 - 12
image/image.go

@@ -29,21 +29,21 @@ func IDFromDigest(digest digest.Digest) ID {
 
 // V1Image stores the V1 image configuration.
 type V1Image struct {
-	// ID a unique 64 character identifier of the image
+	// ID is a unique 64 character identifier of the image
 	ID string `json:"id,omitempty"`
-	// Parent id of the image
+	// Parent is the ID of the parent image
 	Parent string `json:"parent,omitempty"`
-	// Comment user added comment
+	// Comment is the commit message that was set when committing the image
 	Comment string `json:"comment,omitempty"`
-	// Created timestamp when image was created
+	// Created is the timestamp at which the image was created
 	Created time.Time `json:"created"`
 	// Container is the id of the container used to commit
 	Container string `json:"container,omitempty"`
 	// ContainerConfig is the configuration of the container that is committed into the image
 	ContainerConfig container.Config `json:"container_config,omitempty"`
-	// DockerVersion specifies version on which image is built
+	// DockerVersion specifies the version of Docker that was used to build the image
 	DockerVersion string `json:"docker_version,omitempty"`
-	// Author of the image
+	// Author is the name of the author that was specified when committing the image
 	Author string `json:"author,omitempty"`
 	// Config is the configuration of the container received from the client
 	Config *container.Config `json:"config,omitempty"`
@@ -112,13 +112,13 @@ func (img *Image) MarshalJSON() ([]byte, error) {
 
 // History stores build commands that were used to create an image
 type History struct {
-	// Created timestamp for build point
+	// Created is the timestamp at which the image was created
 	Created time.Time `json:"created"`
-	// Author of the build point
+	// Author is the name of the author that was specified when committing the image
 	Author string `json:"author,omitempty"`
-	// CreatedBy keeps the Dockerfile command used while building image.
+	// CreatedBy keeps the Dockerfile command used while building the image
 	CreatedBy string `json:"created_by,omitempty"`
-	// Comment is custom message set by the user when creating the image.
+	// Comment is the commit message that was set when committing the image
 	Comment string `json:"comment,omitempty"`
 	// EmptyLayer is set to true if this history item did not generate a
 	// layer. Otherwise, the history item is associated with the next
@@ -126,7 +126,7 @@ type History struct {
 	EmptyLayer bool `json:"empty_layer,omitempty"`
 }
 
-// Exporter provides interface for exporting and importing images
+// Exporter provides interface for loading and saving images
 type Exporter interface {
 	Load(io.ReadCloser, io.Writer, bool) error
 	// TODO: Load(net.Context, io.ReadCloser, <- chan StatusMessage) error
@@ -141,7 +141,7 @@ func NewFromJSON(src []byte) (*Image, error) {
 		return nil, err
 	}
 	if img.RootFS == nil {
-		return nil, errors.New("Invalid image JSON, no RootFS key.")
+		return nil, errors.New("invalid image JSON, no RootFS key")
 	}
 
 	img.rawJSON = src

+ 2 - 2
image/image_test.go

@@ -24,14 +24,14 @@ func TestJSON(t *testing.T) {
 	}
 	rawJSON := img.RawJSON()
 	if string(rawJSON) != sampleImageJSON {
-		t.Fatalf("Raw JSON of config didn't match: expected %+v, got %v", sampleImageJSON, rawJSON)
+		t.Fatalf("raw JSON of config didn't match: expected %+v, got %v", sampleImageJSON, rawJSON)
 	}
 }
 
 func TestInvalidJSON(t *testing.T) {
 	_, err := NewFromJSON([]byte("{}"))
 	if err == nil {
-		t.Fatal("Expected JSON parse error")
+		t.Fatal("expected JSON parse error")
 	}
 }
 

+ 1 - 1
image/tarexport/tarexport.go

@@ -36,7 +36,7 @@ type LogImageEvent interface {
 	LogImageEvent(imageID, refName, action string)
 }
 
-// NewTarExporter returns new ImageExporter for tar packages
+// NewTarExporter returns new Exporter for tar packages
 func NewTarExporter(is image.Store, ls layer.Store, rs reference.Store, loggerImgEvent LogImageEvent) image.Exporter {
 	return &tarexporter{
 		is:             is,