From 9fa74a36c63b8f006f9a524d21b40f9ebca696c8 Mon Sep 17 00:00:00 2001 From: Nemo Date: Wed, 20 Jun 2018 00:09:08 +0530 Subject: [PATCH] Adds Container Linux releases RSS Feed (#718) * Adds Container Linux releases RSS Feed --- bridges/ContainerLinuxReleasesBridge.php | 76 ++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 bridges/ContainerLinuxReleasesBridge.php diff --git a/bridges/ContainerLinuxReleasesBridge.php b/bridges/ContainerLinuxReleasesBridge.php new file mode 100644 index 0000000..c5f64a1 --- /dev/null +++ b/bridges/ContainerLinuxReleasesBridge.php @@ -0,0 +1,76 @@ + [ + 'name' => 'Release Channel', + 'type' => 'list', + 'required' => true, + 'defaultValue' => self::STABLE, + 'values' => [ + 'Stable' => self::STABLE, + 'Beta' => self::BETA, + 'Alpha' => self::ALPHA, + ], + ] + ] + ]; + + public function getReleaseFeed($jsonUrl) { + $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; + $item['content'] = nl2br($release['release_notes']); + + $item['content'] .= << +Major Software: +
+- Kernel: {$release['major_software']['kernel'][0]}
+- Docker: {$release['major_software']['docker'][0]}
+- etcd: {$release['major_software']['etcd'][0]}
+EOT; + $item['timestamp'] = strtotime($release['release_date']); + + $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(); + } +}