mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Let image manager return a copy of image list.
This commit is contained in:
		@@ -124,7 +124,7 @@ func (i *imageCache) set(images []container.Image) {
 | 
				
			|||||||
func (i *imageCache) get() []container.Image {
 | 
					func (i *imageCache) get() []container.Image {
 | 
				
			||||||
	i.RLock()
 | 
						i.RLock()
 | 
				
			||||||
	defer i.RUnlock()
 | 
						defer i.RUnlock()
 | 
				
			||||||
	return i.images
 | 
						return append([]container.Image{}, i.images...)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Information about the images we track.
 | 
					// Information about the images we track.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -548,6 +548,16 @@ func TestValidateImageGCPolicy(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func TestImageCacheReturnCopiedList(t *testing.T) {
 | 
				
			||||||
 | 
						cache := &imageCache{}
 | 
				
			||||||
 | 
						testList := []container.Image{{ID: "1"}, {ID: "2"}}
 | 
				
			||||||
 | 
						cache.set(testList)
 | 
				
			||||||
 | 
						list := cache.get()
 | 
				
			||||||
 | 
						assert.Len(t, list, 2)
 | 
				
			||||||
 | 
						list[0].ID = "3"
 | 
				
			||||||
 | 
						assert.Equal(t, cache.get(), testList)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func uint64Ptr(i uint64) *uint64 {
 | 
					func uint64Ptr(i uint64) *uint64 {
 | 
				
			||||||
	return &i
 | 
						return &i
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user