[ Cmii ] [ Octopus ] - project a lot
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
"time"
|
||||
"wdd.io/agent-go/logger"
|
||||
"wdd.io/agent-go/utils"
|
||||
"wdd.io/cmii_operator/image"
|
||||
)
|
||||
|
||||
var log = logger.Log
|
||||
@@ -397,10 +398,19 @@ func (op *CmiiK8sOperator) DeploymentUpdateTag(cmiiEnv, appName, newTag string)
|
||||
if len(containers) == 1 {
|
||||
// only update this kind
|
||||
container := containers[0]
|
||||
split := strings.Split(container.Image, ":")
|
||||
|
||||
container.Image = split[0] + ":" + newTag
|
||||
log.InfoF("[DeploymentUpdateTag] - update [%s] [%s] from [%s] to [%s]", op.CurrentNamespace, appName, split[1], container.Image)
|
||||
oldName := container.Image
|
||||
|
||||
split := strings.Split(container.Image, ":")
|
||||
if strings.HasPrefix(container.Image, image.CmiiHarborPrefix) {
|
||||
// harbor
|
||||
container.Image = split[0] + ":" + newTag
|
||||
} else if strings.Contains(container.Image, "8033") {
|
||||
// 192.168.6.6:8033/rancher/k8s-dns-sidecar:v1.0.2
|
||||
container.Image = split[0] + ":" + split[1] + ":" + newTag
|
||||
}
|
||||
|
||||
log.DebugF("[DeploymentUpdateTag] - update [%s] [%s] from [%s] to [%s]", op.CurrentNamespace, appName, oldName, container.Image)
|
||||
|
||||
// re assign
|
||||
deployment.Spec.Template.Spec.Containers[0] = container
|
||||
@@ -411,6 +421,9 @@ func (op *CmiiK8sOperator) DeploymentUpdateTag(cmiiEnv, appName, newTag string)
|
||||
log.ErrorF("[DeploymentUpdateTag] - update [%s] [%s] from [%s] to [%s] error ! %s", op.CurrentNamespace, appName, split[1], container.Image, err.Error())
|
||||
return false
|
||||
}
|
||||
} else if len(containers) == 2 {
|
||||
log.ErrorF("[DeploymentUpdateTag] - cant update app with 2 containers !")
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user