manifest: rename variables that collided with imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>master
							parent
							
								
									b9f9073d1a
								
							
						
					
					
						commit
						0e3efe749b
					
				|  | @ -93,17 +93,17 @@ func (m *DeserializedManifest) UnmarshalJSON(b []byte) error { | ||||||
| 	copy(m.canonical, b) | 	copy(m.canonical, b) | ||||||
| 
 | 
 | ||||||
| 	// Unmarshal canonical JSON into Manifest object
 | 	// Unmarshal canonical JSON into Manifest object
 | ||||||
| 	var manifest Manifest | 	var mfst Manifest | ||||||
| 	if err := json.Unmarshal(m.canonical, &manifest); err != nil { | 	if err := json.Unmarshal(m.canonical, &mfst); err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if manifest.MediaType != "" && manifest.MediaType != v1.MediaTypeImageManifest { | 	if mfst.MediaType != "" && mfst.MediaType != v1.MediaTypeImageManifest { | ||||||
| 		return fmt.Errorf("if present, mediaType in manifest should be '%s' not '%s'", | 		return fmt.Errorf("if present, mediaType in manifest should be '%s' not '%s'", | ||||||
| 			v1.MediaTypeImageManifest, manifest.MediaType) | 			v1.MediaTypeImageManifest, mfst.MediaType) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	m.Manifest = manifest | 	m.Manifest = mfst | ||||||
| 
 | 
 | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -64,9 +64,9 @@ func makeTestManifest(mediaType string) Manifest { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func TestManifest(t *testing.T) { | func TestManifest(t *testing.T) { | ||||||
| 	manifest := makeTestManifest(v1.MediaTypeImageManifest) | 	mfst := makeTestManifest(v1.MediaTypeImageManifest) | ||||||
| 
 | 
 | ||||||
| 	deserialized, err := FromStruct(manifest) | 	deserialized, err := FromStruct(mfst) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("error creating DeserializedManifest: %v", err) | 		t.Fatalf("error creating DeserializedManifest: %v", err) | ||||||
| 	} | 	} | ||||||
|  | @ -79,7 +79,7 @@ func TestManifest(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 	// Check that the canonical field is the same as json.MarshalIndent
 | 	// Check that the canonical field is the same as json.MarshalIndent
 | ||||||
| 	// with these parameters.
 | 	// with these parameters.
 | ||||||
| 	p, err := json.MarshalIndent(&manifest, "", "   ") | 	p, err := json.MarshalIndent(&mfst, "", "   ") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("error marshaling manifest: %v", err) | 		t.Fatalf("error marshaling manifest: %v", err) | ||||||
| 	} | 	} | ||||||
|  | @ -143,9 +143,9 @@ func TestManifest(t *testing.T) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func mediaTypeTest(t *testing.T, mediaType string, shouldError bool) { | func mediaTypeTest(t *testing.T, mediaType string, shouldError bool) { | ||||||
| 	manifest := makeTestManifest(mediaType) | 	mfst := makeTestManifest(mediaType) | ||||||
| 
 | 
 | ||||||
| 	deserialized, err := FromStruct(manifest) | 	deserialized, err := FromStruct(mfst) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("error creating DeserializedManifest: %v", err) | 		t.Fatalf("error creating DeserializedManifest: %v", err) | ||||||
| 	} | 	} | ||||||
|  | @ -186,7 +186,7 @@ func TestMediaTypes(t *testing.T) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func TestValidateManifest(t *testing.T) { | func TestValidateManifest(t *testing.T) { | ||||||
| 	manifest := Manifest{ | 	mfst := Manifest{ | ||||||
| 		Config: distribution.Descriptor{Size: 1}, | 		Config: distribution.Descriptor{Size: 1}, | ||||||
| 		Layers: []distribution.Descriptor{{Size: 2}}, | 		Layers: []distribution.Descriptor{{Size: 2}}, | ||||||
| 	} | 	} | ||||||
|  | @ -196,7 +196,7 @@ func TestValidateManifest(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
| 	t.Run("valid", func(t *testing.T) { | 	t.Run("valid", func(t *testing.T) { | ||||||
| 		b, err := json.Marshal(manifest) | 		b, err := json.Marshal(mfst) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			t.Fatal("unexpected error marshaling manifest", err) | 			t.Fatal("unexpected error marshaling manifest", err) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -126,12 +126,12 @@ func (sm *SignedManifest) UnmarshalJSON(b []byte) error { | ||||||
| 	copy(sm.Canonical, bytes) | 	copy(sm.Canonical, bytes) | ||||||
| 
 | 
 | ||||||
| 	// Unmarshal canonical JSON into Manifest object
 | 	// Unmarshal canonical JSON into Manifest object
 | ||||||
| 	var manifest Manifest | 	var mfst Manifest | ||||||
| 	if err := json.Unmarshal(sm.Canonical, &manifest); err != nil { | 	if err := json.Unmarshal(sm.Canonical, &mfst); err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	sm.Manifest = manifest | 	sm.Manifest = mfst | ||||||
| 
 | 
 | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -109,17 +109,17 @@ func (m *DeserializedManifest) UnmarshalJSON(b []byte) error { | ||||||
| 	copy(m.canonical, b) | 	copy(m.canonical, b) | ||||||
| 
 | 
 | ||||||
| 	// Unmarshal canonical JSON into Manifest object
 | 	// Unmarshal canonical JSON into Manifest object
 | ||||||
| 	var manifest Manifest | 	var mfst Manifest | ||||||
| 	if err := json.Unmarshal(m.canonical, &manifest); err != nil { | 	if err := json.Unmarshal(m.canonical, &mfst); err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if manifest.MediaType != MediaTypeManifest { | 	if mfst.MediaType != MediaTypeManifest { | ||||||
| 		return fmt.Errorf("mediaType in manifest should be '%s' not '%s'", | 		return fmt.Errorf("mediaType in manifest should be '%s' not '%s'", | ||||||
| 			MediaTypeManifest, manifest.MediaType) | 			MediaTypeManifest, mfst.MediaType) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	m.Manifest = manifest | 	m.Manifest = mfst | ||||||
| 
 | 
 | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -49,9 +49,9 @@ func makeTestManifest(mediaType string) Manifest { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func TestManifest(t *testing.T) { | func TestManifest(t *testing.T) { | ||||||
| 	manifest := makeTestManifest(MediaTypeManifest) | 	mfst := makeTestManifest(MediaTypeManifest) | ||||||
| 
 | 
 | ||||||
| 	deserialized, err := FromStruct(manifest) | 	deserialized, err := FromStruct(mfst) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("error creating DeserializedManifest: %v", err) | 		t.Fatalf("error creating DeserializedManifest: %v", err) | ||||||
| 	} | 	} | ||||||
|  | @ -64,7 +64,7 @@ func TestManifest(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 	// Check that the canonical field is the same as json.MarshalIndent
 | 	// Check that the canonical field is the same as json.MarshalIndent
 | ||||||
| 	// with these parameters.
 | 	// with these parameters.
 | ||||||
| 	p, err := json.MarshalIndent(&manifest, "", "   ") | 	p, err := json.MarshalIndent(&mfst, "", "   ") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("error marshaling manifest: %v", err) | 		t.Fatalf("error marshaling manifest: %v", err) | ||||||
| 	} | 	} | ||||||
|  | @ -119,9 +119,9 @@ func TestManifest(t *testing.T) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func mediaTypeTest(t *testing.T, mediaType string, shouldError bool) { | func mediaTypeTest(t *testing.T, mediaType string, shouldError bool) { | ||||||
| 	manifest := makeTestManifest(mediaType) | 	mfst := makeTestManifest(mediaType) | ||||||
| 
 | 
 | ||||||
| 	deserialized, err := FromStruct(manifest) | 	deserialized, err := FromStruct(mfst) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("error creating DeserializedManifest: %v", err) | 		t.Fatalf("error creating DeserializedManifest: %v", err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue