Skip to content

Commit bb2205a

Browse files
authored
docker host is trimmed too much in the docs (git-pkgs#317)
1 parent 2fef446 commit bb2205a

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

internal/server/dashboard.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ func getRegistryConfigs(baseURL string) []RegistryConfig {
207207
if strings.HasPrefix(strings.ToLower(baseURL), "http://") {
208208
swiftInsecureFlag = "--allow-insecure-http "
209209
}
210+
dockerHost := strings.TrimPrefix(strings.TrimPrefix(baseURL, "https://"), "http://")
210211

211212
return []RegistryConfig{
212213
{
@@ -433,7 +434,7 @@ using Pkg; Pkg.update()</code></pre>`),
433434
sudo systemctl restart docker
434435
435436
# Or pull directly
436-
docker pull ` + baseURL[8:] + `/library/nginx:latest</code></pre>`),
437+
docker pull ` + dockerHost + `/library/nginx:latest</code></pre>`),
437438
},
438439
{
439440
ID: "deb",

internal/server/templates_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,21 @@ func TestEcosystemBadgeLabel(t *testing.T) {
519519
}
520520
}
521521

522+
func TestOCIRegistryInstructionsDockerPull(t *testing.T) {
523+
registries := getRegistryConfigs("http://package-proxy:8080")
524+
for _, registry := range registries {
525+
if registry.ID != "oci" {
526+
continue
527+
}
528+
want := "docker pull package-proxy:8080/library/nginx:latest"
529+
if !strings.Contains(string(registry.Instructions), want) {
530+
t.Errorf("OCI instructions = %q, want substring %q", registry.Instructions, want)
531+
}
532+
return
533+
}
534+
t.Fatal("OCI registry instructions not found")
535+
}
536+
522537
func TestSwiftRegistryInstructionsAllowLocalHTTP(t *testing.T) {
523538
registries := getRegistryConfigs("http://localhost:8080")
524539
for _, registry := range registries {

0 commit comments

Comments
 (0)