Implements image overrides
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
This commit is contained in:
parent
5b3d8df5b5
commit
5e62583cec
|
|
@ -96,6 +96,19 @@ func (kg *KustomizeGenerator) WriteFile(dirPath string) (string, error) {
|
|||
kus.Namespace = kg.kustomization.Spec.TargetNamespace
|
||||
}
|
||||
|
||||
for _, image := range kg.kustomization.Spec.Images {
|
||||
newImage := kustypes.Image{
|
||||
Name: image.Name,
|
||||
NewName: image.NewName,
|
||||
NewTag: image.NewTag,
|
||||
}
|
||||
if exists, index := checkKustomizeImageExists(kus.Images, image.Name); exists {
|
||||
kus.Images[index] = newImage
|
||||
} else {
|
||||
kus.Images = append(kus.Images, newImage)
|
||||
}
|
||||
}
|
||||
|
||||
kd, err := yaml.Marshal(kus)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
@ -104,6 +117,16 @@ func (kg *KustomizeGenerator) WriteFile(dirPath string) (string, error) {
|
|||
return checksum, ioutil.WriteFile(kfile, kd, os.ModePerm)
|
||||
}
|
||||
|
||||
func checkKustomizeImageExists(images []kustypes.Image, imageName string) (bool, int) {
|
||||
for i, image := range images {
|
||||
if imageName == image.Name {
|
||||
return true, i
|
||||
}
|
||||
}
|
||||
|
||||
return false, -1
|
||||
}
|
||||
|
||||
func (kg *KustomizeGenerator) generateKustomization(dirPath string) error {
|
||||
fs := filesys.MakeFsOnDisk()
|
||||
kfile := filepath.Join(dirPath, kustomizationFileName)
|
||||
|
|
|
|||
Loading…
Reference in New Issue