Pārlūkot izejas kodu

Enterprise update channel

Allows to select the enterprise update channel for instances that have a valid subscription.

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
tags/v17.0.0beta1
Morris Jobke pirms 5 gadiem
vecāks
revīzija
39c28bd05b
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam

+ 9
- 9
apps/updatenotification/js/updatenotification.js
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 1
- 1
apps/updatenotification/js/updatenotification.js.map
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 14
- 2
apps/updatenotification/lib/Settings/Admin.php Parādīt failu

@@ -34,6 +34,7 @@ use OCP\IGroupManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Settings\ISettings;
use OCP\Support\Subscription\IRegistry;
use OCP\Util;

class Admin implements ISettings {
@@ -47,19 +48,23 @@ class Admin implements ISettings {
private $dateTimeFormatter;
/** @var IFactory */
private $l10nFactory;
/** @var IRegistry */
private $subscriptionRegistry;

public function __construct(
IConfig $config,
UpdateChecker $updateChecker,
IGroupManager $groupManager,
IDateTimeFormatter $dateTimeFormatter,
IFactory $l10nFactory
IFactory $l10nFactory,
IRegistry $subscriptionRegistry
) {
$this->config = $config;
$this->updateChecker = $updateChecker;
$this->groupManager = $groupManager;
$this->dateTimeFormatter = $dateTimeFormatter;
$this->l10nFactory = $l10nFactory;
$this->subscriptionRegistry = $subscriptionRegistry;
}

/**
@@ -86,6 +91,12 @@ class Admin implements ISettings {

$defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/';
$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 = [
'isNewVersionAvailable' => !empty($updateState['updateAvailable']),
@@ -99,9 +110,10 @@ class Admin implements ISettings {
'changes' => $this->filterChanges($updateState['changes'] ?? []),
'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],
'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'],
'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL,
'isDefaultUpdateServerURL' => $isDefaultUpdateServerURL,
'updateServerURL' => $updateServerURL,
'notifyGroups' => $this->getSelectedGroups($notifyGroups),
'hasValidSubscription' => $hasValidSubscription,
];

$params = [

+ 22
- 19
apps/updatenotification/src/components/root.vue Parādīt failu

@@ -115,6 +115,7 @@
versionIsEol: false,
downloadLink: '',
isNewVersionAvailable: false,
hasValidSubscription: false,
updateServerURL: '',
changelogURL: '',
whatsNewData: [],
@@ -224,7 +225,7 @@
if(this.changelogURL) {
whatsNew.push({
href: this.changelogURL,
text: t('updatenotificaiton', 'View changelog'),
text: t('updatenotification', 'View changelog'),
icon: 'icon-link',
target: '_blank',
action: ''
@@ -237,7 +238,16 @@
let channelList = [];

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.'),
icon: 'icon-checkmark',
active: this.currentChannel === 'stable',
@@ -245,15 +255,7 @@
});

channelList.push({
text: t('updatenotificaiton', 'Production'),
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'),
text: t('updatenotification', 'Beta'),
longtext: t('updatenotification', 'A pre-release version only for testing new features, not for production environments.'),
icon: 'icon-category-customization',
active: this.currentChannel === 'beta',
@@ -272,19 +274,19 @@
},

isNonDefaultChannel: function() {
return this.currentChannel !== 'production' && this.currentChannel !== 'stable' && this.currentChannel !== 'beta';
return this.currentChannel !== 'enterprise' && this.currentChannel !== 'stable' && this.currentChannel !== 'beta';
},

localizedChannelName: function() {
switch (this.currentChannel) {
case 'production':
return t('updatenotificaiton', 'Production');
case 'enterprise':
return t('updatenotification', 'Enterprise');
break;
case 'stable':
return t('updatenotificaiton', 'Stable');
return t('updatenotification', 'Stable');
break;
case 'beta':
return t('updatenotificaiton', 'Beta');
return t('updatenotification', 'Beta');
break;
default:
return this.currentChannel;
@@ -317,12 +319,12 @@
form.submit();
}.bind(this));
},
changeReleaseChannelToEnterprise: function() {
this.changeReleaseChannel('enterprise')
},
changeReleaseChannelToStable: function() {
this.changeReleaseChannel('stable')
},
changeReleaseChannelToProduction: function() {
this.changeReleaseChannel('production')
},
changeReleaseChannelToBeta: function() {
this.changeReleaseChannel('beta')
},
@@ -375,6 +377,7 @@
this.notifyGroups = data.notifyGroups;
this.isDefaultUpdateServerURL = data.isDefaultUpdateServerURL;
this.versionIsEol = data.versionIsEol;
this.hasValidSubscription = data.hasValidSubscription;
if(data.changes && data.changes.changelogURL) {
this.changelogURL = data.changes.changelogURL;
}

+ 11
- 1
apps/updatenotification/tests/Settings/AdminTest.php Parādīt failu

@@ -35,6 +35,7 @@ use OCP\IGroupManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\L10N\ILanguageIterator;
use OCP\Support\Subscription\IRegistry;
use OCP\Util;
use Test\TestCase;

@@ -51,6 +52,8 @@ class AdminTest extends TestCase {
private $groupManager;
/** @var IDateTimeFormatter|\PHPUnit_Framework_MockObject_MockObject */
private $dateTimeFormatter;
/** @var IRegistry|\PHPUnit_Framework_MockObject_MockObject */
private $subscriptionRegistry;

public function setUp() {
parent::setUp();
@@ -60,9 +63,10 @@ class AdminTest extends TestCase {
$this->groupManager = $this->createMock(IGroupManager::class);
$this->dateTimeFormatter = $this->createMock(IDateTimeFormatter::class);
$this->l10nFactory = $this->createMock(IFactory::class);
$this->subscriptionRegistry = $this->createMock(IRegistry::class);

$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')
->willReturn($group);

$this->subscriptionRegistry
->expects($this->once())
->method('delegateHasValidSubscription')
->willReturn(true);

$params = [
'json' => json_encode([
'isNewVersionAvailable' => true,
@@ -138,6 +147,7 @@ class AdminTest extends TestCase {
'notifyGroups' => [
['value' => 'admin', 'label' => 'Administrators'],
],
'hasValidSubscription' => true,
]),
];


+ 0
- 1
config/config.sample.php Parādīt failu

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


+ 1
- 0
lib/composer/composer/autoload_classmap.php Parādīt failu

@@ -1063,6 +1063,7 @@ return array(
'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\\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\\Owncloud\\DropAccountTermsTable' => $baseDir . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php',
'OC\\Repair\\Owncloud\\SaveAccountsTableData' => $baseDir . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php',

+ 1
- 0
lib/composer/composer/autoload_static.php Parādīt failu

@@ -1097,6 +1097,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'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\\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\\Owncloud\\DropAccountTermsTable' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php',
'OC\\Repair\\Owncloud\\SaveAccountsTableData' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php',

+ 2
- 0
lib/private/Repair.php Parādīt failu

@@ -43,6 +43,7 @@ use OC\Repair\NC14\AddPreviewBackgroundCleanupJob;
use OC\Repair\NC16\AddClenupLoginFlowV2BackgroundJob;
use OC\Repair\NC16\CleanupCardDAVPhotoCache;
use OC\Repair\NC16\RemoveCypressFiles;
use OC\Repair\NC17\SwitchUpdateChannel;
use OC\Repair\OldGroupMembershipShares;
use OC\Repair\Owncloud\DropAccountTermsTable;
use OC\Repair\Owncloud\SaveAccountsTableData;
@@ -149,6 +150,7 @@ class Repair implements IOutput {
new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
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(SwitchUpdateChannel::class),
];
}


+ 60
- 0
lib/private/Repair/NC17/SwitchUpdateChannel.php Parādīt failu

@@ -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');
}
}
}
}

Notiek ielāde…
Atcelt
Saglabāt