2018-06-19 21:39:08 +03:00
|
|
|
<?php
|
|
|
|
class ContainerLinuxReleasesBridge extends BridgeAbstract {
|
|
|
|
|
2018-07-16 15:54:52 +03:00
|
|
|
const MAINTAINER = 'captn3m0';
|
2018-06-19 21:39:08 +03: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';
|
|
|
|
|
|
|
|
const PARAMETERS = [
|
|
|
|
[
|
|
|
|
'channel' => [
|
|
|
|
'name' => 'Release Channel',
|
|
|
|
'type' => 'list',
|
|
|
|
'required' => true,
|
|
|
|
'defaultValue' => self::STABLE,
|
|
|
|
'values' => [
|
|
|
|
'Stable' => self::STABLE,
|
|
|
|
'Beta' => self::BETA,
|
|
|
|
'Alpha' => self::ALPHA,
|
|
|
|
],
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
2018-08-05 16:53:45 +03:00
|
|
|
private function getReleaseFeed($jsonUrl) {
|
2018-06-19 21:39:08 +03:00
|
|
|
$json = getContents($jsonUrl)
|
|
|
|
or returnServerError('Could not request Core OS Website.');
|
|
|
|
return json_decode($json, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function collectData() {
|
|
|
|
$data = $this->getReleaseFeed($this->getJsonUri());
|
|
|
|
|
|
|
|
foreach ($data as $releaseVersion => $release) {
|
|
|
|
$item = [];
|
|
|
|
|
|
|
|
$item['uri'] = "https://coreos.com/releases/#$releaseVersion";
|
|
|
|
$item['title'] = $releaseVersion;
|
|
|
|
|
2018-06-28 21:54:42 +03:00
|
|
|
$content = $release['release_notes'];
|
|
|
|
$content .= <<<EOT
|
|
|
|
|
2018-06-19 21:39:08 +03:00
|
|
|
Major Software:
|
2018-06-28 21:54:42 +03:00
|
|
|
* Kernel: {$release['major_software']['kernel'][0]}
|
|
|
|
* Docker: {$release['major_software']['docker'][0]}
|
|
|
|
* etcd: {$release['major_software']['etcd'][0]}
|
2018-06-19 21:39:08 +03:00
|
|
|
EOT;
|
|
|
|
$item['timestamp'] = strtotime($release['release_date']);
|
|
|
|
|
2018-06-28 21:54:42 +03: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 01:15:22 +03:00
|
|
|
return sprintf ('<ul><li>%s</li></ul>', trim ($item));
|
2018-06-28 21:54:42 +03:00
|
|
|
}, $item['content']);
|
|
|
|
|
2018-06-19 21:39:08 +03: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();
|
|
|
|
}
|
|
|
|
}
|