mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
[DockerHubBridge] Add tag filter option (#3258)
* [DockerHubBridge] Add tag filter option * [DockerHubBridge] Add example value * [DockerHubBridge] lint * [DockerHubBridge] Fix * Update DockerHubBridge.php * [DockerHubBridge] Make repo required * [DockerHubBridge] Add filter example value for user images
This commit is contained in:
parent
17fcc72b09
commit
787b4d7cad
@ -19,6 +19,12 @@ class DockerHubBridge extends BridgeAbstract
|
|||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'exampleValue' => 'rss-bridge',
|
'exampleValue' => 'rss-bridge',
|
||||||
|
],
|
||||||
|
'filter' => [
|
||||||
|
'name' => 'Filter tag',
|
||||||
|
'type' => 'text',
|
||||||
|
'required' => false,
|
||||||
|
'exampleValue' => 'latest',
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'Official Image' => [
|
'Official Image' => [
|
||||||
@ -27,8 +33,14 @@ class DockerHubBridge extends BridgeAbstract
|
|||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'exampleValue' => 'postgres',
|
'exampleValue' => 'postgres',
|
||||||
|
],
|
||||||
|
'filter' => [
|
||||||
|
'name' => 'Filter tag',
|
||||||
|
'type' => 'text',
|
||||||
|
'required' => false,
|
||||||
|
'exampleValue' => 'alpine3.17',
|
||||||
]
|
]
|
||||||
],
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
const CACHE_TIMEOUT = 3600; // 1 hour
|
const CACHE_TIMEOUT = 3600; // 1 hour
|
||||||
@ -90,21 +102,33 @@ EOD;
|
|||||||
|
|
||||||
public function getURI()
|
public function getURI()
|
||||||
{
|
{
|
||||||
|
$uri = parent::getURI();
|
||||||
|
|
||||||
if ($this->queriedContext === 'Official Image') {
|
if ($this->queriedContext === 'Official Image') {
|
||||||
return self::URI . '/_/' . $this->getRepo();
|
$uri = self::URI . '/_/' . $this->getRepo();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getInput('repo')) {
|
if ($this->queriedContext === 'User Submitted Image') {
|
||||||
return self::URI . '/r/' . $this->getRepo();
|
$uri = '/r/' . $this->getRepo();
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getURI();
|
if ($this->getInput('filter')) {
|
||||||
|
$uri .= '/tags/?&page=1&name=' . $this->getInput('filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
if ($this->getInput('repo')) {
|
if ($this->getInput('repo')) {
|
||||||
return $this->getRepo() . ' - Docker Hub';
|
$name = $this->getRepo();
|
||||||
|
|
||||||
|
if ($this->getInput('filter')) {
|
||||||
|
$name .= ':' . $this->getInput('filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $name . ' - Docker Hub';
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getName();
|
return parent::getName();
|
||||||
@ -121,11 +145,21 @@ EOD;
|
|||||||
|
|
||||||
private function getApiUrl()
|
private function getApiUrl()
|
||||||
{
|
{
|
||||||
|
$url = '';
|
||||||
|
|
||||||
if ($this->queriedContext === 'Official Image') {
|
if ($this->queriedContext === 'Official Image') {
|
||||||
return $this->apiURL . 'library/' . $this->getRepo() . '/tags/?page_size=25&page=1';
|
$url = $this->apiURL . 'library/' . $this->getRepo() . '/tags/?page_size=25&page=1';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->apiURL . $this->getRepo() . '/tags/?page_size=25&page=1';
|
if ($this->queriedContext === 'User Submitted Image') {
|
||||||
|
$url = $this->apiURL . $this->getRepo() . '/tags/?page_size=25&page=1';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->getInput('filter')) {
|
||||||
|
$url .= '&name=' . $this->getInput('filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getLayerUrl($name, $digest)
|
private function getLayerUrl($name, $digest)
|
||||||
@ -140,11 +174,17 @@ EOD;
|
|||||||
|
|
||||||
private function getTagUrl($name)
|
private function getTagUrl($name)
|
||||||
{
|
{
|
||||||
|
$url = '';
|
||||||
|
|
||||||
if ($this->queriedContext === 'Official Image') {
|
if ($this->queriedContext === 'Official Image') {
|
||||||
return self::URI . '/_/' . $this->getRepo() . '?tab=tags&name=' . $name;
|
$url = self::URI . '/_/' . $this->getRepo();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::URI . '/r/' . $this->getRepo() . '/tags?name=' . $name;
|
if ($this->queriedContext === 'User Submitted Image') {
|
||||||
|
$url = self::URI . '/r/' . $this->getRepo();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url . '/tags/?&name=' . $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getImages($result)
|
private function getImages($result)
|
||||||
|
Loading…
Reference in New Issue
Block a user