mirror of
https://github.com/dokku/dokku.git
synced 2026-02-23 19:50:34 +01:00
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
|
||||
}
|
||||
|
||||
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 {
|
||||
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, "")
|
||||
|
||||
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))
|
||||
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")
|
||||
}
|
||||
|
||||
// Tagging the image as latest
|
||||
common.LogVerboseQuiet(fmt.Sprintf("Tagging %s as latest in registry format", imageRepo))
|
||||
if !dockerTag(imageID, latestImage) {
|
||||
return errors.New("Unable to tag image as latest")
|
||||
extraTags := getRegistryPushExtraTagsForApp(appName)
|
||||
if extraTags != "" {
|
||||
extraTagsArray := strings.Split(extraTags, ",")
|
||||
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))
|
||||
@@ -113,12 +131,6 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e
|
||||
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
|
||||
// other schedulers do not retire local images
|
||||
if common.GetAppScheduler(appName) != "docker-local" {
|
||||
|
||||
@@ -6,6 +6,7 @@ var (
|
||||
"image-repo": "",
|
||||
"push-on-release": "false",
|
||||
"server": "",
|
||||
"push-extra-tags": "",
|
||||
}
|
||||
|
||||
// GlobalProperties is a map of all valid global registry properties
|
||||
@@ -13,5 +14,6 @@ var (
|
||||
"image-repo-template": true,
|
||||
"push-on-release": 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-server": reportServer,
|
||||
"--registry-tag-version": reportTagVersion,
|
||||
"--registry-push-extra-tags": reportPushExtraTags,
|
||||
}
|
||||
|
||||
flagKeys := []string{}
|
||||
@@ -96,3 +97,7 @@ func reportTagVersion(appName string) string {
|
||||
tagVersion := common.PropertyGet("registry", appName, "tag-version")
|
||||
return strings.TrimSpace(tagVersion)
|
||||
}
|
||||
|
||||
func reportPushExtraTags(appName string) string {
|
||||
return common.PropertyGet("registry", appName, "push-extra-tags")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user