Merge pull request #15514 from nextcloud/feature/noid/add-enterprise-channel

Update channels for updater server
This commit is contained in:
Morris Jobke 2019-07-11 12:42:34 +02:00 committed by GitHub
commit 79e0b5c4ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 121 additions and 33 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -34,6 +34,7 @@ use OCP\IGroupManager;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\L10N\IFactory; use OCP\L10N\IFactory;
use OCP\Settings\ISettings; use OCP\Settings\ISettings;
use OCP\Support\Subscription\IRegistry;
use OCP\Util; use OCP\Util;
class Admin implements ISettings { class Admin implements ISettings {
@ -47,19 +48,23 @@ class Admin implements ISettings {
private $dateTimeFormatter; private $dateTimeFormatter;
/** @var IFactory */ /** @var IFactory */
private $l10nFactory; private $l10nFactory;
/** @var IRegistry */
private $subscriptionRegistry;
public function __construct( public function __construct(
IConfig $config, IConfig $config,
UpdateChecker $updateChecker, UpdateChecker $updateChecker,
IGroupManager $groupManager, IGroupManager $groupManager,
IDateTimeFormatter $dateTimeFormatter, IDateTimeFormatter $dateTimeFormatter,
IFactory $l10nFactory IFactory $l10nFactory,
IRegistry $subscriptionRegistry
) { ) {
$this->config = $config; $this->config = $config;
$this->updateChecker = $updateChecker; $this->updateChecker = $updateChecker;
$this->groupManager = $groupManager; $this->groupManager = $groupManager;
$this->dateTimeFormatter = $dateTimeFormatter; $this->dateTimeFormatter = $dateTimeFormatter;
$this->l10nFactory = $l10nFactory; $this->l10nFactory = $l10nFactory;
$this->subscriptionRegistry = $subscriptionRegistry;
} }
/** /**
@ -86,6 +91,12 @@ class Admin implements ISettings {
$defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/'; $defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/';
$updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL); $updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL);
$defaultCustomerUpdateServerURLPrefix = 'https://updates.nextcloud.com/customers/';
$isDefaultUpdateServerURL = $updateServerURL === $defaultUpdateServerURL
|| $updateServerURL === substr($updateServerURL, 0, strlen($defaultCustomerUpdateServerURLPrefix));
$hasValidSubscription = $this->subscriptionRegistry->delegateHasValidSubscription();
$params = [ $params = [
'isNewVersionAvailable' => !empty($updateState['updateAvailable']), 'isNewVersionAvailable' => !empty($updateState['updateAvailable']),
@ -99,9 +110,10 @@ class Admin implements ISettings {
'changes' => $this->filterChanges($updateState['changes'] ?? []), 'changes' => $this->filterChanges($updateState['changes'] ?? []),
'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'], 'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],
'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'], 'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'],
'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL, 'isDefaultUpdateServerURL' => $isDefaultUpdateServerURL,
'updateServerURL' => $updateServerURL, 'updateServerURL' => $updateServerURL,
'notifyGroups' => $this->getSelectedGroups($notifyGroups), 'notifyGroups' => $this->getSelectedGroups($notifyGroups),
'hasValidSubscription' => $hasValidSubscription,
]; ];
$params = [ $params = [

View File

@ -115,6 +115,7 @@
versionIsEol: false, versionIsEol: false,
downloadLink: '', downloadLink: '',
isNewVersionAvailable: false, isNewVersionAvailable: false,
hasValidSubscription: false,
updateServerURL: '', updateServerURL: '',
changelogURL: '', changelogURL: '',
whatsNewData: [], whatsNewData: [],
@ -224,7 +225,7 @@
if(this.changelogURL) { if(this.changelogURL) {
whatsNew.push({ whatsNew.push({
href: this.changelogURL, href: this.changelogURL,
text: t('updatenotificaiton', 'View changelog'), text: t('updatenotification', 'View changelog'),
icon: 'icon-link', icon: 'icon-link',
target: '_blank', target: '_blank',
action: '' action: ''
@ -237,7 +238,16 @@
let channelList = []; let channelList = [];
channelList.push({ channelList.push({
text: t('updatenotificaiton', 'Stable'), text: t('updatenotification', 'Enterprise'),
longtext: t('updatenotification', 'For enterprise use. Provides always the latest patch level, but will not update to the next major release immediately. That update happens once Nextcloud GmbH has done additional hardening and testing for large-scale and mission-critical deployments. This channel is only available to customers and provides the Nextcloud Enterprise package.'),
icon: 'icon-star',
active: this.currentChannel === 'enterprise',
disabled: !this.hasValidSubscription,
action: this.changeReleaseChannelToEnterprise
});
channelList.push({
text: t('updatenotification', 'Stable'),
longtext: t('updatenotification', 'The most recent stable version. It is suited for regular use and will always update to the latest major version.'), longtext: t('updatenotification', 'The most recent stable version. It is suited for regular use and will always update to the latest major version.'),
icon: 'icon-checkmark', icon: 'icon-checkmark',
active: this.currentChannel === 'stable', active: this.currentChannel === 'stable',
@ -245,15 +255,7 @@
}); });
channelList.push({ channelList.push({
text: t('updatenotificaiton', 'Production'), text: t('updatenotification', 'Beta'),
longtext: t('updatenotification', 'Will always provide the latest patch level, but not update to the next major release immediately. That update usually happens with the second minor release (x.0.2) and only if the instance is already on the latest minor version.'),
icon: 'icon-star',
active: this.currentChannel === 'production',
action: this.changeReleaseChannelToProduction
});
channelList.push({
text: t('updatenotificaiton', 'Beta'),
longtext: t('updatenotification', 'A pre-release version only for testing new features, not for production environments.'), longtext: t('updatenotification', 'A pre-release version only for testing new features, not for production environments.'),
icon: 'icon-category-customization', icon: 'icon-category-customization',
active: this.currentChannel === 'beta', active: this.currentChannel === 'beta',
@ -272,19 +274,19 @@
}, },
isNonDefaultChannel: function() { isNonDefaultChannel: function() {
return this.currentChannel !== 'production' && this.currentChannel !== 'stable' && this.currentChannel !== 'beta'; return this.currentChannel !== 'enterprise' && this.currentChannel !== 'stable' && this.currentChannel !== 'beta';
}, },
localizedChannelName: function() { localizedChannelName: function() {
switch (this.currentChannel) { switch (this.currentChannel) {
case 'production': case 'enterprise':
return t('updatenotificaiton', 'Production'); return t('updatenotification', 'Enterprise');
break; break;
case 'stable': case 'stable':
return t('updatenotificaiton', 'Stable'); return t('updatenotification', 'Stable');
break; break;
case 'beta': case 'beta':
return t('updatenotificaiton', 'Beta'); return t('updatenotification', 'Beta');
break; break;
default: default:
return this.currentChannel; return this.currentChannel;
@ -317,12 +319,12 @@
form.submit(); form.submit();
}.bind(this)); }.bind(this));
}, },
changeReleaseChannelToEnterprise: function() {
this.changeReleaseChannel('enterprise')
},
changeReleaseChannelToStable: function() { changeReleaseChannelToStable: function() {
this.changeReleaseChannel('stable') this.changeReleaseChannel('stable')
}, },
changeReleaseChannelToProduction: function() {
this.changeReleaseChannel('production')
},
changeReleaseChannelToBeta: function() { changeReleaseChannelToBeta: function() {
this.changeReleaseChannel('beta') this.changeReleaseChannel('beta')
}, },
@ -375,6 +377,7 @@
this.notifyGroups = data.notifyGroups; this.notifyGroups = data.notifyGroups;
this.isDefaultUpdateServerURL = data.isDefaultUpdateServerURL; this.isDefaultUpdateServerURL = data.isDefaultUpdateServerURL;
this.versionIsEol = data.versionIsEol; this.versionIsEol = data.versionIsEol;
this.hasValidSubscription = data.hasValidSubscription;
if(data.changes && data.changes.changelogURL) { if(data.changes && data.changes.changelogURL) {
this.changelogURL = data.changes.changelogURL; this.changelogURL = data.changes.changelogURL;
} }

View File

@ -35,6 +35,7 @@ use OCP\IGroupManager;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\L10N\IFactory; use OCP\L10N\IFactory;
use OCP\L10N\ILanguageIterator; use OCP\L10N\ILanguageIterator;
use OCP\Support\Subscription\IRegistry;
use OCP\Util; use OCP\Util;
use Test\TestCase; use Test\TestCase;
@ -51,6 +52,8 @@ class AdminTest extends TestCase {
private $groupManager; private $groupManager;
/** @var IDateTimeFormatter|\PHPUnit_Framework_MockObject_MockObject */ /** @var IDateTimeFormatter|\PHPUnit_Framework_MockObject_MockObject */
private $dateTimeFormatter; private $dateTimeFormatter;
/** @var IRegistry|\PHPUnit_Framework_MockObject_MockObject */
private $subscriptionRegistry;
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
@ -60,9 +63,10 @@ class AdminTest extends TestCase {
$this->groupManager = $this->createMock(IGroupManager::class); $this->groupManager = $this->createMock(IGroupManager::class);
$this->dateTimeFormatter = $this->createMock(IDateTimeFormatter::class); $this->dateTimeFormatter = $this->createMock(IDateTimeFormatter::class);
$this->l10nFactory = $this->createMock(IFactory::class); $this->l10nFactory = $this->createMock(IFactory::class);
$this->subscriptionRegistry = $this->createMock(IRegistry::class);
$this->admin = new Admin( $this->admin = new Admin(
$this->config, $this->updateChecker, $this->groupManager, $this->dateTimeFormatter, $this->l10nFactory $this->config, $this->updateChecker, $this->groupManager, $this->dateTimeFormatter, $this->l10nFactory, $this->subscriptionRegistry
); );
} }
@ -120,6 +124,11 @@ class AdminTest extends TestCase {
->with('admin') ->with('admin')
->willReturn($group); ->willReturn($group);
$this->subscriptionRegistry
->expects($this->once())
->method('delegateHasValidSubscription')
->willReturn(true);
$params = [ $params = [
'json' => json_encode([ 'json' => json_encode([
'isNewVersionAvailable' => true, 'isNewVersionAvailable' => true,
@ -138,6 +147,7 @@ class AdminTest extends TestCase {
'notifyGroups' => [ 'notifyGroups' => [
['value' => 'admin', 'label' => 'Administrators'], ['value' => 'admin', 'label' => 'Administrators'],
], ],
'hasValidSubscription' => true,
]), ]),
]; ];

View File

@ -653,7 +653,6 @@ $CONFIG = array(
* - ``daily`` * - ``daily``
* - ``beta`` * - ``beta``
* - ``stable`` * - ``stable``
* - ``production``
*/ */
'updater.release.channel' => 'stable', 'updater.release.channel' => 'stable',

View File

@ -1065,6 +1065,7 @@ return array(
'OC\\Repair\\NC16\\AddClenupLoginFlowV2BackgroundJob' => $baseDir . '/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php', 'OC\\Repair\\NC16\\AddClenupLoginFlowV2BackgroundJob' => $baseDir . '/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php',
'OC\\Repair\\NC16\\CleanupCardDAVPhotoCache' => $baseDir . '/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php', 'OC\\Repair\\NC16\\CleanupCardDAVPhotoCache' => $baseDir . '/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php',
'OC\\Repair\\NC16\\RemoveCypressFiles' => $baseDir . '/lib/private/Repair/NC16/RemoveCypressFiles.php', 'OC\\Repair\\NC16\\RemoveCypressFiles' => $baseDir . '/lib/private/Repair/NC16/RemoveCypressFiles.php',
'OC\\Repair\\NC17\\SwitchUpdateChannel' => $baseDir . '/lib/private/Repair/NC17/SwitchUpdateChannel.php',
'OC\\Repair\\OldGroupMembershipShares' => $baseDir . '/lib/private/Repair/OldGroupMembershipShares.php', 'OC\\Repair\\OldGroupMembershipShares' => $baseDir . '/lib/private/Repair/OldGroupMembershipShares.php',
'OC\\Repair\\Owncloud\\DropAccountTermsTable' => $baseDir . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php', 'OC\\Repair\\Owncloud\\DropAccountTermsTable' => $baseDir . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php',
'OC\\Repair\\Owncloud\\SaveAccountsTableData' => $baseDir . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php', 'OC\\Repair\\Owncloud\\SaveAccountsTableData' => $baseDir . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php',

View File

@ -1099,6 +1099,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Repair\\NC16\\AddClenupLoginFlowV2BackgroundJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php', 'OC\\Repair\\NC16\\AddClenupLoginFlowV2BackgroundJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php',
'OC\\Repair\\NC16\\CleanupCardDAVPhotoCache' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php', 'OC\\Repair\\NC16\\CleanupCardDAVPhotoCache' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php',
'OC\\Repair\\NC16\\RemoveCypressFiles' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/RemoveCypressFiles.php', 'OC\\Repair\\NC16\\RemoveCypressFiles' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/RemoveCypressFiles.php',
'OC\\Repair\\NC17\\SwitchUpdateChannel' => __DIR__ . '/../../..' . '/lib/private/Repair/NC17/SwitchUpdateChannel.php',
'OC\\Repair\\OldGroupMembershipShares' => __DIR__ . '/../../..' . '/lib/private/Repair/OldGroupMembershipShares.php', 'OC\\Repair\\OldGroupMembershipShares' => __DIR__ . '/../../..' . '/lib/private/Repair/OldGroupMembershipShares.php',
'OC\\Repair\\Owncloud\\DropAccountTermsTable' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php', 'OC\\Repair\\Owncloud\\DropAccountTermsTable' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php',
'OC\\Repair\\Owncloud\\SaveAccountsTableData' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php', 'OC\\Repair\\Owncloud\\SaveAccountsTableData' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php',

View File

@ -43,6 +43,7 @@ use OC\Repair\NC14\AddPreviewBackgroundCleanupJob;
use OC\Repair\NC16\AddClenupLoginFlowV2BackgroundJob; use OC\Repair\NC16\AddClenupLoginFlowV2BackgroundJob;
use OC\Repair\NC16\CleanupCardDAVPhotoCache; use OC\Repair\NC16\CleanupCardDAVPhotoCache;
use OC\Repair\NC16\RemoveCypressFiles; use OC\Repair\NC16\RemoveCypressFiles;
use OC\Repair\NC17\SwitchUpdateChannel;
use OC\Repair\OldGroupMembershipShares; use OC\Repair\OldGroupMembershipShares;
use OC\Repair\Owncloud\DropAccountTermsTable; use OC\Repair\Owncloud\DropAccountTermsTable;
use OC\Repair\Owncloud\SaveAccountsTableData; use OC\Repair\Owncloud\SaveAccountsTableData;
@ -149,6 +150,7 @@ class Repair implements IOutput {
new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()), new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)), new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
\OC::$server->query(RemoveCypressFiles::class), \OC::$server->query(RemoveCypressFiles::class),
\OC::$server->query(SwitchUpdateChannel::class),
]; ];
} }

View File

@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, Morris Jobke <hey@morrisjobke.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OC\Repair\NC17;
use OCP\IConfig;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use OCP\Support\Subscription\IRegistry;
/**
* @deprecated - can be removed in 18
*/
class SwitchUpdateChannel implements IRepairStep {
/** @var IConfig */
private $config;
/** @var IRegistry */
private $subscriptionRegistry;
public function __construct(IConfig $config, IRegistry $subscriptionRegistry) {
$this->config = $config;
$this->subscriptionRegistry = $subscriptionRegistry;
}
public function getName(): string {
return 'Switches from deprecated "production" to "stable" update channel';
}
public function run(IOutput $output): void {
$currentChannel = $this->config->getSystemValue('updater.release.channel', 'stable');
if ($currentChannel === 'production') {
if ($this->subscriptionRegistry->delegateHasValidSubscription()) {
$this->config->setSystemValue('updater.release.channel', 'enterprise');
} else {
$this->config->setSystemValue('updater.release.channel', 'stable');
}
}
}
}