mirror of
https://github.com/dokku/dokku.git
synced 2026-02-23 19:50:34 +01:00
feat: implement more of the registry plugin
This commit is contained in:
@@ -3,10 +3,29 @@ package registry
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
func getRegistryServerForApp(appName string) string {
|
||||
value := common.PropertyGet("registry", appName, "server")
|
||||
if value == "" {
|
||||
value = common.PropertyGet("registry", "--global", "server")
|
||||
}
|
||||
|
||||
if value == "" {
|
||||
value = DefaultProperties["server"]
|
||||
}
|
||||
|
||||
value = strings.TrimSuffix(value, "/") + "/"
|
||||
if value == "hub.docker.com/" || value == "docker.io/" {
|
||||
value = ""
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
func isPushEnabled(appName string) bool {
|
||||
return reportComputedPushOnRelease(appName) == "true"
|
||||
}
|
||||
|
||||
@@ -82,16 +82,7 @@ func reportPushOnRelease(appName string) string {
|
||||
}
|
||||
|
||||
func reportComputedServer(appName string) string {
|
||||
value := reportServer(appName)
|
||||
if value == "" {
|
||||
value = reportGlobalServer(appName)
|
||||
}
|
||||
|
||||
if value == "" {
|
||||
value = DefaultProperties["server"]
|
||||
}
|
||||
|
||||
return value
|
||||
return getRegistryServerForApp(appName)
|
||||
}
|
||||
|
||||
func reportGlobalServer(appName string) string {
|
||||
|
||||
@@ -18,6 +18,12 @@ func main() {
|
||||
|
||||
var err error
|
||||
switch trigger {
|
||||
case "deployed-app-image-repo":
|
||||
appName := flag.Arg(0)
|
||||
err = registry.TriggerDeployedAppImageRepo(appName)
|
||||
case "deployed-app-image-tag":
|
||||
appName := flag.Arg(0)
|
||||
err = registry.TriggerDeployedAppImageTag(appName)
|
||||
case "deployed-app-repository":
|
||||
appName := flag.Arg(0)
|
||||
err = registry.TriggerDeployedAppRepository(appName)
|
||||
|
||||
@@ -6,9 +6,31 @@ import (
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// TriggerDeployedAppImageRepo outputs the associated image repo to stdout
|
||||
func TriggerDeployedAppImageRepo(appName string) error {
|
||||
imageRepo := common.PropertyGet("registry", appName, "image-repo")
|
||||
if imageRepo == "" {
|
||||
imageRepo = common.GetAppImageRepo(appName)
|
||||
}
|
||||
|
||||
fmt.Println(imageRepo)
|
||||
return nil
|
||||
}
|
||||
|
||||
// TriggerDeployedAppImageTag outputs the associated image tag to stdout
|
||||
func TriggerDeployedAppImageTag(appName string) error {
|
||||
tagVersion := common.PropertyGet("registry", appName, "tag-version")
|
||||
if tagVersion == "" {
|
||||
tagVersion = "1"
|
||||
}
|
||||
|
||||
fmt.Println(tagVersion)
|
||||
return nil
|
||||
}
|
||||
|
||||
// TriggerDeployedAppRepository outputs the associated registry repository to stdout
|
||||
func TriggerDeployedAppRepository(appName string) error {
|
||||
// TODO
|
||||
fmt.Println(getRegistryServerForApp(appName))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user