chore: address review comments
- Remove outdated BUG comment from test (bug is now fixed) - Simplify colon check in buildImageRef (sha256 check was redundant)
- commit
- 1b9113baaa3dbf019431d47406a6e2692fcb7a80
- author
- bnema · · 2026-02-03 20:03 UTC
- parent
- c031e6f
- signature
- unsigned
2 files · +3 -3
M internal/usecase/container/service.go +2 -2
| @@ -649,9 +649,9 @@ func (s *Service) buildImageRef(image string) string { | |||
| 649 | 649 | // For "localhost:5000/myapp:latest" -> "localhost:5000/myapp" (already handled above) | |
| 650 | 650 | repoPart := image | |
| 651 | 651 | if idx := strings.LastIndex(image, ":"); idx != -1 { | |
| 652 | - | // Check if this colon is a tag separator (not part of a digest or port) | |
| 652 | + | // Check if this colon is a tag separator (not part of a port) | |
| 653 | 653 | afterColon := image[idx+1:] | |
| 654 | - | if !strings.HasPrefix(afterColon, "sha256:") && !strings.Contains(afterColon, "/") { | |
| 654 | + | if !strings.Contains(afterColon, "/") { | |
| 655 | 655 | repoPart = image[:idx] | |
| 656 | 656 | } | |
| 657 | 657 | } | |
| @@ -649,9 +649,9 @@ func (s *Service) buildImageRef(image string) string { | |||||
| 649 | // For "localhost:5000/myapp:latest" -> "localhost:5000/myapp" (already handled above) | 649 | // For "localhost:5000/myapp:latest" -> "localhost:5000/myapp" (already handled above) | ||
| 650 | repoPart := image | 650 | repoPart := image | ||
| 651 | if idx := strings.LastIndex(image, ":"); idx != -1 { | 651 | if idx := strings.LastIndex(image, ":"); idx != -1 { | ||
| 652 | - | // Check if this colon is a tag separator (not part of a digest or port) | 652 | + | // Check if this colon is a tag separator (not part of a port) |
| 653 | afterColon := image[idx+1:] | 653 | afterColon := image[idx+1:] | ||
| 654 | - | if !strings.HasPrefix(afterColon, "sha256:") && !strings.Contains(afterColon, "/") { | 654 | + | if !strings.Contains(afterColon, "/") { |
| 655 | repoPart = image[:idx] | 655 | repoPart = image[:idx] | ||
| 656 | } | 656 | } | ||
| 657 | } | 657 | } | ||
M internal/usecase/container/service_test.go +1 -1
| @@ -791,7 +791,7 @@ func TestBuildImageRef(t *testing.T) { | |||
| 791 | 791 | image: "localhost:5000/myapp:latest", | |
| 792 | 792 | registryAuthEnabled: true, | |
| 793 | 793 | registryDomain: "localhost:5000", | |
| 794 | - | wantRef: "localhost:5000/myapp:latest", // BUG: currently returns localhost:5000/localhost:5000/myapp:latest | |
| 794 | + | wantRef: "localhost:5000/myapp:latest", | |
| 795 | 795 | }, | |
| 796 | 796 | } | |
| 797 | 797 | ||
| @@ -791,7 +791,7 @@ func TestBuildImageRef(t *testing.T) { | |||||
| 791 | image: "localhost:5000/myapp:latest", | 791 | image: "localhost:5000/myapp:latest", | ||
| 792 | registryAuthEnabled: true, | 792 | registryAuthEnabled: true, | ||
| 793 | registryDomain: "localhost:5000", | 793 | registryDomain: "localhost:5000", | ||
| 794 | - | wantRef: "localhost:5000/myapp:latest", // BUG: currently returns localhost:5000/localhost:5000/myapp:latest | 794 | + | wantRef: "localhost:5000/myapp:latest", |
| 795 | }, | 795 | }, | ||
| 796 | } | 796 | } | ||
| 797 | 797 | ||||