Enhanced log output when mirroring is replaced

Signed-off-by: wawa0210 <zhangxiao@xiaozhangs-MacBook-Pro.local>
This commit is contained in:
wawa0210
2023-06-01 09:00:26 +08:00
parent d6f5e3832a
commit 95d8a93a9c

View File

@@ -153,19 +153,19 @@ func (a *ChangeImageNameAction) replaceImageName(obj *unstructured.Unstructured,
needUpdateObj := false
containers, _, err := unstructured.NestedSlice(obj.UnstructuredContent(), filed...)
if err != nil {
a.logger.Infof("UnstructuredConverter meet error: %v", err)
log.Infof("UnstructuredConverter meet error: %v", err)
return errors.Wrap(err, "error getting item's spec.containers")
}
if len(containers) == 0 {
return nil
}
for i, container := range containers {
a.logger.Infoln("container:", container)
log.Infoln("container:", container)
if image, ok := container.(map[string]interface{})["image"]; ok {
imageName := image.(string)
if exists, newImageName, err := a.isImageReplaceRuleExist(log, imageName, config); exists && err == nil {
needUpdateObj = true
a.logger.Infof("Updating item's image from %s to %s", imageName, newImageName)
log.Infof("Updating item's image from %s to %s", imageName, newImageName)
container.(map[string]interface{})["image"] = newImageName
containers[i] = container
}