From fe351eecab474b4cd965d22e4880f58c0523bb4a Mon Sep 17 00:00:00 2001 From: KArtHiK Date: Fri, 2 Jan 2026 15:50:28 +0100 Subject: [PATCH] Bugfix:Fix image url for docker registry source --- app/web/views/components/vsource/common.templ | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/app/web/views/components/vsource/common.templ b/app/web/views/components/vsource/common.templ index 7f495a2..06d8ee7 100644 --- a/app/web/views/components/vsource/common.templ +++ b/app/web/views/components/vsource/common.templ @@ -5,6 +5,7 @@ import "github.com/cloudness-io/cloudness/types" import "github.com/cloudness-io/cloudness/app/web/views/shared" import "github.com/cloudness-io/cloudness/helpers" import "github.com/cloudness-io/cloudness/app/services/spec" +import "strings" templ Image(app *types.Application) { @shared.Icon(spec.GetSourceIcon(app), "") @@ -34,14 +35,25 @@ func getSourceLink(spec *types.ApplicationSpec) templ.Component { return gitLink(owner+"/"+repo, httpUrl, branch, commit, commitUrl) } else if spec.IsRegistry() { - return getRegistryLink(spec.Build.Source.Registry.Image) + imageUrl := spec.Build.Source.Registry.Image + if !strings.HasPrefix(imageUrl, "https://") { + imageUrl = "https://hub.docker.com/r/" + strings.TrimSpace(imageUrl) + } + //remove tag if present + imageUrl = removeTag(imageUrl) + return getRegistryLink(spec.Build.Source.Registry.Image, imageUrl) } return emptyLink("unknow source") } -templ getRegistryLink(image string) { - -

{ image }

+templ getRegistryLink(imageName string, imageUrl string) { +
+

{ imageName }

} @@ -68,3 +80,14 @@ templ gitLink(name string, httpURL string, branch string, commit string, commitU templ emptyLink(errMsg string) {

} + +func removeTag(imageName string) string { + // Find the last colon, which typically separates name and tag + if i := strings.LastIndex(imageName, ":"); i != -1 { + // Ensure we don't accidentally split a port in a registry URL (e.g., localhost:5000/img) + if !strings.Contains(imageName[i:], "/") { + return imageName[:i] + } + } + return imageName +}