feat: implement more of the registry plugin
This commit is contained in:
@@ -3,10 +3,29 @@ package registry
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/dokku/dokku/plugins/common"
|
"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 {
|
func isPushEnabled(appName string) bool {
|
||||||
return reportComputedPushOnRelease(appName) == "true"
|
return reportComputedPushOnRelease(appName) == "true"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,16 +82,7 @@ func reportPushOnRelease(appName string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func reportComputedServer(appName string) string {
|
func reportComputedServer(appName string) string {
|
||||||
value := reportServer(appName)
|
return getRegistryServerForApp(appName)
|
||||||
if value == "" {
|
|
||||||
value = reportGlobalServer(appName)
|
|
||||||
}
|
|
||||||
|
|
||||||
if value == "" {
|
|
||||||
value = DefaultProperties["server"]
|
|
||||||
}
|
|
||||||
|
|
||||||
return value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func reportGlobalServer(appName string) string {
|
func reportGlobalServer(appName string) string {
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ func main() {
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
switch trigger {
|
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":
|
case "deployed-app-repository":
|
||||||
appName := flag.Arg(0)
|
appName := flag.Arg(0)
|
||||||
err = registry.TriggerDeployedAppRepository(appName)
|
err = registry.TriggerDeployedAppRepository(appName)
|
||||||
|
|||||||
@@ -6,9 +6,31 @@ import (
|
|||||||
"github.com/dokku/dokku/plugins/common"
|
"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
|
// TriggerDeployedAppRepository outputs the associated registry repository to stdout
|
||||||
func TriggerDeployedAppRepository(appName string) error {
|
func TriggerDeployedAppRepository(appName string) error {
|
||||||
// TODO
|
fmt.Println(getRegistryServerForApp(appName))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user