From 32e82514a8d718ccbe690011145938ebd844627c Mon Sep 17 00:00:00 2001 From: ThisIsQasim <18313886+ThisIsQasim@users.noreply.github.com> Date: Mon, 2 Jun 2025 14:54:54 +0500 Subject: [PATCH] feat: Add suport for Image Volume --- api/filters/imagetag/imagetag_test.go | 78 +++++++++++++++++++ .../konfig/builtinpluginconsts/images.go | 4 + 2 files changed, 82 insertions(+) diff --git a/api/filters/imagetag/imagetag_test.go b/api/filters/imagetag/imagetag_test.go index a9aec8604..08cce229d 100644 --- a/api/filters/imagetag/imagetag_test.go +++ b/api/filters/imagetag/imagetag_test.go @@ -879,6 +879,84 @@ spec: }, }, }, + "update image volume in pod template": { + input: ` +group: apps +apiVersion: v1 +kind: Deployment +metadata: + name: imagevolume +spec: + template: + spec: + volumes: + - name: volume + image: + reference: nginx +`, + expectedOutput: ` +group: apps +apiVersion: v1 +kind: Deployment +metadata: + name: imagevolume +spec: + template: + spec: + volumes: + - name: volume + image: + reference: apache@12345 +`, + filter: Filter{ + ImageTag: types.Image{ + Name: "nginx", + NewName: "apache", + Digest: "12345", + }, + }, + fsSlice: []types.FieldSpec{ + { + Path: "spec/template/spec/volumes[]/image/reference", + }, + }, + }, + "update image volume in pod spec": { + input: ` +apiVersion: v1 +kind: Pod +metadata: + name: imagevolume +spec: + volumes: + - name: volume + image: + reference: nginx +`, + expectedOutput: ` +apiVersion: v1 +kind: Pod +metadata: + name: imagevolume +spec: + volumes: + - name: volume + image: + reference: apache@12345 +`, + filter: Filter{ + ImageTag: types.Image{ + Name: "nginx", + NewName: "apache", + Digest: "12345", + }, + }, + fsSlice: []types.FieldSpec{ + { + Path: "spec/volumes[]/image/reference", + }, + }, + }, } for tn, tc := range testCases { diff --git a/api/internal/konfig/builtinpluginconsts/images.go b/api/internal/konfig/builtinpluginconsts/images.go index b8d8bf1e3..a60370ef7 100644 --- a/api/internal/konfig/builtinpluginconsts/images.go +++ b/api/internal/konfig/builtinpluginconsts/images.go @@ -10,9 +10,13 @@ images: create: true - path: spec/initContainers[]/image create: true +- path: spec/volumes[]/image/reference + create: true - path: spec/template/spec/containers[]/image create: true - path: spec/template/spec/initContainers[]/image create: true +- path: spec/template/spec/volumes[]/image/reference + create: true ` )