fix: trim whitespace on registry property values

When upgrading from an older install of Dokku with the old community registry plugin, newlines could be available in the properties set on disk. Trim them so any usage of the properties continues to work as expected by users.
This commit is contained in:
Jose Diaz-Gonzalez
2023-06-02 19:35:23 -04:00
parent 09aa6ad874
commit f90ef17338
3 changed files with 12 additions and 2 deletions

View File

@@ -16,6 +16,7 @@ func getRegistryServerForApp(appName string) string {
if value == "" {
value = common.PropertyGet("registry", "--global", "server")
}
value = strings.TrimSpace(value)
value = strings.TrimSuffix(value, "/")
if value == "hub.docker.com" || value == "docker.io" {
@@ -39,6 +40,7 @@ func incrementTagVersion(appName string) (int, error) {
tag = "0"
}
tag = strings.TrimSpace(tag)
version, err := strconv.Atoi(tag)
if err != nil {
return 0, fmt.Errorf("Unable to convert existing tag version (%s) to integer: %v", tag, err)