mirror of https://github.com/containers/podman.git
				
				
				
			Merge pull request #18327 from rhatdan/docker
Add sha256: to images history id for docker compatibility
This commit is contained in:
		
						commit
						c50d223b84
					
				|  | @ -33,13 +33,17 @@ func HistoryImage(w http.ResponseWriter, r *http.Request) { | |||
| 	allHistory := make([]handlers.HistoryResponse, 0, len(history)) | ||||
| 	for _, h := range history { | ||||
| 		l := handlers.HistoryResponse{ | ||||
| 			ID:        h.ID, | ||||
| 			Created:   h.Created.Unix(), | ||||
| 			CreatedBy: h.CreatedBy, | ||||
| 			Tags:      h.Tags, | ||||
| 			Size:      h.Size, | ||||
| 			Comment:   h.Comment, | ||||
| 		} | ||||
| 		if utils.IsLibpodRequest(r) { | ||||
| 			l.ID = h.ID | ||||
| 		} else { | ||||
| 			l.ID = "sha256:" + h.ID | ||||
| 		} | ||||
| 		allHistory = append(allHistory, l) | ||||
| 	} | ||||
| 	utils.WriteResponse(w, http.StatusOK, allHistory) | ||||
|  |  | |||
|  | @ -78,6 +78,15 @@ for i in $iid ${iid:0:12} $PODMAN_TEST_IMAGE_NAME; do | |||
|     .[0].Comment= | ||||
| done | ||||
| 
 | ||||
| for i in $iid ${iid:0:12} $PODMAN_TEST_IMAGE_NAME; do | ||||
|   t GET images/$i/history 200 \ | ||||
|     .[0].Id="sha256:"$iid \ | ||||
|     .[0].Created~[0-9]\\{10\\} \ | ||||
|     .[0].Tags=null \ | ||||
|     .[0].Size=0 \ | ||||
|     .[0].Comment= | ||||
| done | ||||
| 
 | ||||
| # Export an image on the local | ||||
| t GET libpod/images/nonesuch/get 404 | ||||
| t GET libpod/images/$iid/get?format=foo 500 | ||||
|  |  | |||
|  | @ -70,12 +70,11 @@ class TestImages(common.DockerTestCase): | |||
|         """Image history""" | ||||
|         img = self.docker.images.get(constant.ALPINE) | ||||
|         history = img.history() | ||||
|         image_id = img.id[7:] if img.id.startswith("sha256:") else img.id | ||||
| 
 | ||||
|         found = False | ||||
|         for change in history: | ||||
|             found |= image_id in change.values() | ||||
|         self.assertTrue(found, f"image id {image_id} not found in history") | ||||
|             found |= img.id in change.values() | ||||
|         self.assertTrue(found, f"image id {img.id} not found in history") | ||||
| 
 | ||||
|     def test_get_image_exists_not(self): | ||||
|         """Negative test for get image""" | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue