Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6718211
Pull images used in volumes with type=image
Divyanshupandey007 Jul 30, 2026
e40864b
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Jul 31, 2026
cdcb6f4
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 1, 2026
3498f6c
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 3, 2026
29e7bf4
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 5, 2026
a33e87f
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 8, 2026
9d33f72
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 12, 2026
418dec2
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 17, 2026
833d3c1
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 18, 2026
a215fa5
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 19, 2026
456f546
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 19, 2026
23ad7ff
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 21, 2026
9c26897
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 24, 2026
87aaf0d
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 26, 2026
be49620
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Aug 28, 2026
4231061
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Sep 7, 2026
39fa80d
Merge branch 'main' into 13809-pull-volume-images
Divyanshupandey007 Sep 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,9 @@ func GetImageNameOrDefault(service types.ServiceConfig, projectName string) stri
}

// GetDependentImages returns the additional images a service depends on beyond
// its main image. Currently this is the set of pre_start hook images, which run
// as ephemeral init containers with their own image. A hook without an explicit
// image, or one reusing the service image, is skipped as that image is already
// accounted for as the service image.
// its main image. This includes pre_start hook images and type=image volume
// sources. Images that match the service image are skipped as they are already
// accounted for.
func GetDependentImages(service types.ServiceConfig, projectName string) []string {
serviceImage := GetImageNameOrDefault(service, projectName)
var images []string
Expand All @@ -819,5 +818,10 @@ func GetDependentImages(service types.ServiceConfig, projectName string) []strin
images = append(images, hook.Image)
}
}
for _, vol := range service.Volumes {
if vol.Type == types.VolumeTypeImage && vol.Source != serviceImage {
images = append(images, vol.Source)
}
}
return images
}
44 changes: 44 additions & 0 deletions pkg/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,50 @@ func TestGetDependentImages(t *testing.T) {
},
expected: nil,
},
{
name: "type=image volume source is collected",
service: types.ServiceConfig{
Image: "nginx:alpine",
Volumes: []types.ServiceVolumeConfig{
{Type: types.VolumeTypeImage, Source: "myorg/assets:latest", Target: "/srv/static"},
},
},
expected: []string{"myorg/assets:latest"},
},
{
name: "type=image volume reusing the service image is ignored",
service: types.ServiceConfig{
Image: "myorg/shared:latest",
Volumes: []types.ServiceVolumeConfig{
{Type: types.VolumeTypeImage, Source: "myorg/shared:latest", Target: "/data"},
},
},
expected: nil,
},
{
name: "non-image volume types are ignored",
service: types.ServiceConfig{
Image: "alpine:3.20",
Volumes: []types.ServiceVolumeConfig{
{Type: types.VolumeTypeBind, Source: "/host/path", Target: "/container"},
{Type: types.VolumeTypeVolume, Source: "myvolume", Target: "/data"},
},
},
expected: nil,
},
{
name: "hook and volume images are both collected",
service: types.ServiceConfig{
Image: "alpine:3.20",
PreStart: []types.ServiceHook{
{Image: "init:latest", Command: types.ShellCommand{"echo", "init"}},
},
Volumes: []types.ServiceVolumeConfig{
{Type: types.VolumeTypeImage, Source: "myorg/data:1.0", Target: "/data"},
},
},
expected: []string{"init:latest", "myorg/data:1.0"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down