2018-06-19 20:39:08 +02:00
|
|
|
<?php
|
|
|
|
class ContainerLinuxReleasesBridge extends BridgeAbstract {
|
|
|
|
|
2018-07-16 14:54:52 +02:00
|
|
|
const MAINTAINER = 'captn3m0';
|
2018-06-19 20:39:08 +02:00
|
|
|
const NAME = 'Core OS Container Linux Releases Bridge';
|
|
|
|
const URI = 'https://coreos.com/releases/';
|
|
|
|
const DESCRIPTION = 'Returns the releases notes for Container Linux';
|
|
|
|
|
|
|
|
const STABLE = 'stable';
|
|
|
|
const BETA = 'beta';
|
|
|
|
const ALPHA = 'alpha';
|
|
|
|
|
2019-11-01 18:06:38 +01:00
|
|
|
const PARAMETERS = array(
|
|
|
|
array(
|
|
|
|
'channel' => array(
|
2018-06-19 20:39:08 +02:00
|
|
|
'name' => 'Release Channel',
|
|
|
|
'type' => 'list',
|
|
|
|
'defaultValue' => self::STABLE,
|
2019-11-01 18:06:38 +01:00
|
|
|
'values' => array(
|
2018-06-19 20:39:08 +02:00
|
|
|
'Stable' => self::STABLE,
|
|
|
|
'Beta' => self::BETA,
|
|
|
|
'Alpha' => self::ALPHA,
|
2019-11-01 18:06:38 +01:00
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2018-06-19 20:39:08 +02:00
|
|
|
|
2018-08-05 15:53:45 +02:00
|
|
|
private function getReleaseFeed($jsonUrl) {
|
2018-06-19 20:39:08 +02:00
|
|
|
$json = getContents($jsonUrl)
|
|
|
|
or returnServerError('Could not request Core OS Website.');
|
|
|
|
return json_decode($json, true);
|
|
|
|
}
|
|
|
|
|
2018-10-26 18:07:34 +02:00
|
|
|
public function getIcon() {
|
|
|
|
return 'https://coreos.com/assets/ico/favicon.png';
|
|
|
|
}
|
|
|
|
|
2018-06-19 20:39:08 +02:00
|
|
|
public function collectData() {
|
|
|
|
$data = $this->getReleaseFeed($this->getJsonUri());
|
|
|
|
|
|
|
|
foreach ($data as $releaseVersion => $release) {
|
2019-11-01 18:06:38 +01:00
|
|
|
$item = array();
|
2018-06-19 20:39:08 +02:00
|
|
|
|
|
|
|
$item['uri'] = "https://coreos.com/releases/#$releaseVersion";
|
|
|
|
$item['title'] = $releaseVersion;
|
|
|
|
|
2018-06-28 20:54:42 +02:00
|
|
|
$content = $release['release_notes'];
|
|
|
|
$content .= <<<EOT
|
|
|
|
|
2018-06-19 20:39:08 +02:00
|
|
|
Major Software:
|
2018-06-28 20:54:42 +02:00
|
|
|
* Kernel: {$release['major_software']['kernel'][0]}
|
|
|
|
* Docker: {$release['major_software']['docker'][0]}
|
|
|
|
* etcd: {$release['major_software']['etcd'][0]}
|
2018-06-19 20:39:08 +02:00
|
|
|
EOT;
|
|
|
|
$item['timestamp'] = strtotime($release['release_date']);
|
|
|
|
|
2018-06-28 20:54:42 +02:00
|
|
|
// Based on https://gist.github.com/jbroadway/2836900
|
|
|
|
// Links
|
|
|
|
$regex = '/\[([^\[]+)\]\(([^\)]+)\)/';
|
|
|
|
$replacement = '<a href=\'\2\'>\1</a>';
|
|
|
|
$item['content'] = preg_replace($regex, $replacement, $content);
|
|
|
|
|
|
|
|
// Headings
|
|
|
|
$regex = '/^(.*)\:\s?$/m';
|
|
|
|
$replacement = '<h3>\1</h3>';
|
|
|
|
$item['content'] = preg_replace($regex, $replacement, $item['content']);
|
|
|
|
|
|
|
|
// Lists
|
|
|
|
$regex = '/\n\s*[\*|\-](.*)/';
|
|
|
|
$item['content'] = preg_replace_callback ($regex, function($regs) {
|
|
|
|
$item = $regs[1];
|
2018-06-30 00:15:22 +02:00
|
|
|
return sprintf ('<ul><li>%s</li></ul>', trim ($item));
|
2018-06-28 20:54:42 +02:00
|
|
|
}, $item['content']);
|
|
|
|
|
2018-06-19 20:39:08 +02:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getJsonUri() {
|
|
|
|
$channel = $this->getInput('channel');
|
|
|
|
|
|
|
|
return "https://coreos.com/releases/releases-$channel.json";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getURI() {
|
|
|
|
return self::URI;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(){
|
|
|
|
if(!is_null($this->getInput('channel'))) {
|
|
|
|
return 'Container Linux Releases: ' . $this->getInput('channel') . ' Channel';
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getName();
|
|
|
|
}
|
|
|
|
}
|