diff --git a/internal/server/dashboard.go b/internal/server/dashboard.go index ec5eb7f..a3ac9eb 100644 --- a/internal/server/dashboard.go +++ b/internal/server/dashboard.go @@ -207,6 +207,7 @@ func getRegistryConfigs(baseURL string) []RegistryConfig { if strings.HasPrefix(strings.ToLower(baseURL), "http://") { swiftInsecureFlag = "--allow-insecure-http " } + dockerHost := strings.TrimPrefix(strings.TrimPrefix(baseURL, "https://"), "http://") return []RegistryConfig{ { @@ -433,7 +434,7 @@ using Pkg; Pkg.update()`), sudo systemctl restart docker # Or pull directly -docker pull ` + baseURL[8:] + `/library/nginx:latest`), +docker pull ` + dockerHost + `/library/nginx:latest`), }, { ID: "deb", diff --git a/internal/server/templates_test.go b/internal/server/templates_test.go index 11e4b19..a2d3b7d 100644 --- a/internal/server/templates_test.go +++ b/internal/server/templates_test.go @@ -519,6 +519,21 @@ func TestEcosystemBadgeLabel(t *testing.T) { } } +func TestOCIRegistryInstructionsDockerPull(t *testing.T) { + registries := getRegistryConfigs("http://package-proxy:8080") + for _, registry := range registries { + if registry.ID != "oci" { + continue + } + want := "docker pull package-proxy:8080/library/nginx:latest" + if !strings.Contains(string(registry.Instructions), want) { + t.Errorf("OCI instructions = %q, want substring %q", registry.Instructions, want) + } + return + } + t.Fatal("OCI registry instructions not found") +} + func TestSwiftRegistryInstructionsAllowLocalHTTP(t *testing.T) { registries := getRegistryConfigs("http://localhost:8080") for _, registry := range registries {