push based on push-extra-tags list of tags
This commit is contained in:
@@ -81,6 +81,15 @@ func incrementTagVersion(appName string) (int, error) {
|
|||||||
return version, nil
|
return version, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getRegistryPushExtraTagsForApp(appName string) string {
|
||||||
|
value := common.PropertyGet("registry", appName, "push-extra-tags")
|
||||||
|
common.LogVerboseQuiet(fmt.Sprintf("VALUE IS: %s", value))
|
||||||
|
if value == "" {
|
||||||
|
value = common.PropertyGet("registry", "--global", "push-extra-tags")
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
func pushToRegistry(appName string, tag int, imageID string, imageRepo string) error {
|
func pushToRegistry(appName string, tag int, imageID string, imageRepo string) error {
|
||||||
common.LogVerboseQuiet("Retrieving image info for app")
|
common.LogVerboseQuiet("Retrieving image info for app")
|
||||||
|
|
||||||
@@ -88,7 +97,6 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e
|
|||||||
imageTag, _ := common.GetRunningImageTag(appName, "")
|
imageTag, _ := common.GetRunningImageTag(appName, "")
|
||||||
|
|
||||||
fullImage := fmt.Sprintf("%s%s:%d", registryServer, imageRepo, tag)
|
fullImage := fmt.Sprintf("%s%s:%d", registryServer, imageRepo, tag)
|
||||||
latestImage := fmt.Sprintf("%s%s:latest", registryServer, imageRepo)
|
|
||||||
|
|
||||||
common.LogVerboseQuiet(fmt.Sprintf("Tagging %s:%d in registry format", imageRepo, tag))
|
common.LogVerboseQuiet(fmt.Sprintf("Tagging %s:%d in registry format", imageRepo, tag))
|
||||||
if !dockerTag(imageID, fullImage) {
|
if !dockerTag(imageID, fullImage) {
|
||||||
@@ -101,10 +109,20 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e
|
|||||||
return errors.New("Unable to tag image")
|
return errors.New("Unable to tag image")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tagging the image as latest
|
extraTags := getRegistryPushExtraTagsForApp(appName)
|
||||||
common.LogVerboseQuiet(fmt.Sprintf("Tagging %s as latest in registry format", imageRepo))
|
if extraTags != "" {
|
||||||
if !dockerTag(imageID, latestImage) {
|
extraTagsArray := strings.Split(extraTags, ",")
|
||||||
return errors.New("Unable to tag image as latest")
|
for _, extraTag := range extraTagsArray {
|
||||||
|
extraTagImage := fmt.Sprintf("%s%s:%s", registryServer, imageRepo, extraTag)
|
||||||
|
common.LogVerboseQuiet(fmt.Sprintf("Tagging %s as %s in registry format", imageRepo, extraTag))
|
||||||
|
if !dockerTag(imageID, extraTagImage) {
|
||||||
|
return errors.New(fmt.Sprintf("Unable to tag image as %s", extraTag))
|
||||||
|
}
|
||||||
|
common.LogVerboseQuiet(fmt.Sprintf("Pushing %s", extraTagImage))
|
||||||
|
if !dockerPush(extraTagImage) {
|
||||||
|
return errors.New(fmt.Sprintf("Unable to push image with %s tag", tag))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common.LogVerboseQuiet(fmt.Sprintf("Pushing %s", fullImage))
|
common.LogVerboseQuiet(fmt.Sprintf("Pushing %s", fullImage))
|
||||||
@@ -113,12 +131,6 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e
|
|||||||
return errors.New("Unable to push image")
|
return errors.New("Unable to push image")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pushing the latest tag
|
|
||||||
common.LogVerboseQuiet(fmt.Sprintf("Pushing %s", latestImage))
|
|
||||||
if !dockerPush(latestImage) {
|
|
||||||
return errors.New("Unable to push image with latest tag")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only clean up when the scheduler is not docker-local
|
// Only clean up when the scheduler is not docker-local
|
||||||
// other schedulers do not retire local images
|
// other schedulers do not retire local images
|
||||||
if common.GetAppScheduler(appName) != "docker-local" {
|
if common.GetAppScheduler(appName) != "docker-local" {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ var (
|
|||||||
"image-repo": "",
|
"image-repo": "",
|
||||||
"push-on-release": "false",
|
"push-on-release": "false",
|
||||||
"server": "",
|
"server": "",
|
||||||
|
"push-extra-tags": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
// GlobalProperties is a map of all valid global registry properties
|
// GlobalProperties is a map of all valid global registry properties
|
||||||
@@ -13,5 +14,6 @@ var (
|
|||||||
"image-repo-template": true,
|
"image-repo-template": true,
|
||||||
"push-on-release": true,
|
"push-on-release": true,
|
||||||
"server": true,
|
"server": true,
|
||||||
|
"push-extra-tags": true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
|
|||||||
"--registry-global-image-repo-template": reportGlobalImageRepoTemplate,
|
"--registry-global-image-repo-template": reportGlobalImageRepoTemplate,
|
||||||
"--registry-server": reportServer,
|
"--registry-server": reportServer,
|
||||||
"--registry-tag-version": reportTagVersion,
|
"--registry-tag-version": reportTagVersion,
|
||||||
|
"--registry-push-extra-tags": reportPushExtraTags,
|
||||||
}
|
}
|
||||||
|
|
||||||
flagKeys := []string{}
|
flagKeys := []string{}
|
||||||
@@ -96,3 +97,7 @@ func reportTagVersion(appName string) string {
|
|||||||
tagVersion := common.PropertyGet("registry", appName, "tag-version")
|
tagVersion := common.PropertyGet("registry", appName, "tag-version")
|
||||||
return strings.TrimSpace(tagVersion)
|
return strings.TrimSpace(tagVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func reportPushExtraTags(appName string) string {
|
||||||
|
return common.PropertyGet("registry", appName, "push-extra-tags")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user