-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix "latest" tag fallback #242
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What wonderful code. Whoever you work for is so freaking lucky ;) OH WAIT THAT IS YOU
} | ||
|
||
public function getTags(): Collection | ||
{ | ||
$response = json_decode($this->getTagsResponse()->getContents(), true); | ||
|
||
return collect($response['results']) | ||
[$numericTags, $alphaTags] = collect($response['results']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So clean!
return is_numeric($tag[0]); | ||
}); | ||
|
||
$sortedTags = $alphaTags->sortDesc(SORT_NATURAL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also so clean!
if ($sortedTags->contains('latest')) { | ||
$sortedTags->splice($sortedTags->search('latest'), 1); | ||
$sortedTags->prepend('latest'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DAMN this is so clean.
@@ -69,6 +79,6 @@ protected function buildTagsUrl(): string | |||
|
|||
protected function tagsUrlTemplate(): string | |||
{ | |||
return 'https://registry.hub.docker.com/v2/repositories/%s/%s/tags'; | |||
return 'https://registry.hub.docker.com/v2/repositories/%s/%s/tags?page_size=1024'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha that was an easy way to do it!
Thank you so much @josecanhelp! |
@mattstauffer looks like you're only option is for Tighten to purchase Troika and reabsorb @josecanhelp 🤡 |
Docker Hub paginates the tag list page and in order to pull the full list of tags, we would need to authenticate, which I've been trying to avoid for complexity sake. Luckily, we can expand the
page_size
parameter and bump it up to read more tags without needing to authenticate.The next step to my solution is to partition the named tags and the numerical tags. We can rely on the higher numerical tags to be the "actual latest" tags and we can ignore the named tags when takeout is searching for "actual latest".