Skip to content

Resolve short Elasticsearch/OpenSearch versions to full patch versions for Docker images - #62

Merged
peterjaap merged 4 commits into
mainfrom
copilot/fix-elasticsearch-version
Apr 3, 2026
Merged

peterjaap merged 4 commits into
mainfrom
copilot/fix-elasticsearch-version

Conversation

Copilot AI commented Apr 3, 2026 •

Copy link
Copy Markdown
Contributor
  • Add ResolveElasticsearchVersion / ResolveOpenSearchVersion using dynamic Docker Hub tag API queries
  • Add internal/docker/registry.go with resolveDockerTagVersion, queryDockerHubLatestTag, compareVersionStrings, in-memory sync.Map cache
  • Remove hardcoded version maps from compose.go
  • Update tests to use httptest mock server
  • Fix errcheck lint failure: use two-value type assertion cached.(string) → v, ok := cached.(string) in resolveDockerTagVersion
  • All tests pass, lint clean (0 issues with golangci-lint v2.11.4)

Copilot AI linked an issue Apr 3, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix elasticsearch version resolution to available version Resolve short Elasticsearch/OpenSearch versions to full patch versions for Docker images Apr 3, 2026
Copilot AI requested a review from peterjaap April 3, 2026 09:07
@peterjaap
peterjaap marked this pull request as ready for review April 3, 2026 14:11
@peterjaap

Copy link
Copy Markdown
Collaborator

@copilot is there any way to not make this depend on a hardcoded mapping?

Copilot AI commented Apr 3, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot is there any way to not make this depend on a hardcoded mapping?

Yes — replaced the hardcoded map with a live Docker Hub tags API query (commit d307dd6).

When the user writes elasticsearch: "7.17", the compose generator now calls https://registry.hub.docker.com/v2/repositories/library/elasticsearch/tags?name=7.17.&page_size=50 and picks the highest 7.17.X tag numerically. The result is cached in a sync.Map for the lifetime of the process so each minor version is resolved at most once per magebox run. On any network / parse error the input version is returned unchanged, which keeps the same graceful-degradation behaviour as before.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • github.com (HTTP Only)
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL [email protected] git-upload-pack 'org/repo.git' ApFAaMi8b ./cmd/magebox/ligithub.com/charmbracelet/bubbles/textarea/memoization ache/go/1.24.13/-lang=go1.23 t/http ays/manager.go /home/REDACTED/.lo/tmp/go-build562828070/b282/_pkg_.a ortcfg -l in.so /lto-wrapper (packet block)
  • nonexistent.invalid.host
    • Triggering command: /tmp/go-build562828070/b368/teamserver.test /tmp/go-build562828070/b368/teamserver.test -test.testlogfile=/tmp/go-build562828070/b368/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build562828070/b281/vet.cfg 3/x64=/_/GOROOT http/httpproxy/p--gdwarf2 ux_amd64/compile--64 t/http ays/manager.go cal/bin/grep ux_amd64/compile-trimpath ortc�� 6523235/b018/_pk-p x64/src/runtime/github.com/charmbracelet/bubbletea (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@peterjaap

Copy link
Copy Markdown
Collaborator

@copilot linting failed

Copilot AI commented Apr 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot linting failed

Fixed in 686d97f. The errcheck linter flagged the unchecked type assertion cached.(string) because check-type-assertions: true is set in .golangci.yml. Changed it to the two-value form v, ok := cached.(string). Lint now passes with 0 issues.

@peterjaap
peterjaap merged commit 54e56b5 into main Apr 3, 2026
10 checks passed
@peterjaap
peterjaap deleted the copilot/fix-elasticsearch-version branch April 3, 2026 14:35
@peterjaap

Copy link
Copy Markdown
Collaborator

@copilot pleaser also make sure "7" works, not just "7.17"

@peterjaap
peterjaap restored the copilot/fix-elasticsearch-version branch May 12, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make versions resolve to available version

2 participants