Skip to content

Commit 79e0b5c

Browse files
authored
Merge pull request #15514 from nextcloud/feature/noid/add-enterprise-channel
Update channels for updater server
2 parents 13e0a95 + 39c28bd commit 79e0b5c

10 files changed

Lines changed: 121 additions & 33 deletions

File tree

apps/updatenotification/js/updatenotification.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/updatenotification/js/updatenotification.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/updatenotification/lib/Settings/Admin.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use OCP\IUserSession;
3535
use OCP\L10N\IFactory;
3636
use OCP\Settings\ISettings;
37+
use OCP\Support\Subscription\IRegistry;
3738
use OCP\Util;
3839

3940
class Admin implements ISettings {
@@ -47,19 +48,23 @@ class Admin implements ISettings {
4748
private $dateTimeFormatter;
4849
/** @var IFactory */
4950
private $l10nFactory;
51+
/** @var IRegistry */
52+
private $subscriptionRegistry;
5053

5154
public function __construct(
5255
IConfig $config,
5356
UpdateChecker $updateChecker,
5457
IGroupManager $groupManager,
5558
IDateTimeFormatter $dateTimeFormatter,
56-
IFactory $l10nFactory
59+
IFactory $l10nFactory,
60+
IRegistry $subscriptionRegistry
5761
) {
5862
$this->config = $config;
5963
$this->updateChecker = $updateChecker;
6064
$this->groupManager = $groupManager;
6165
$this->dateTimeFormatter = $dateTimeFormatter;
6266
$this->l10nFactory = $l10nFactory;
67+
$this->subscriptionRegistry = $subscriptionRegistry;
6368
}
6469

6570
/**
@@ -86,6 +91,12 @@ public function getForm(): TemplateResponse {
8691

8792
$defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/';
8893
$updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL);
94+
$defaultCustomerUpdateServerURLPrefix = 'https://updates.nextcloud.com/customers/';
95+
96+
$isDefaultUpdateServerURL = $updateServerURL === $defaultUpdateServerURL
97+
|| $updateServerURL === substr($updateServerURL, 0, strlen($defaultCustomerUpdateServerURLPrefix));
98+
99+
$hasValidSubscription = $this->subscriptionRegistry->delegateHasValidSubscription();
89100

90101
$params = [
91102
'isNewVersionAvailable' => !empty($updateState['updateAvailable']),
@@ -99,9 +110,10 @@ public function getForm(): TemplateResponse {
99110
'changes' => $this->filterChanges($updateState['changes'] ?? []),
100111
'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],
101112
'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'],
102-
'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL,
113+
'isDefaultUpdateServerURL' => $isDefaultUpdateServerURL,
103114
'updateServerURL' => $updateServerURL,
104115
'notifyGroups' => $this->getSelectedGroups($notifyGroups),
116+
'hasValidSubscription' => $hasValidSubscription,
105117
];
106118

107119
$params = [

apps/updatenotification/src/components/root.vue

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
versionIsEol: false,
116116
downloadLink: '',
117117
isNewVersionAvailable: false,
118+
hasValidSubscription: false,
118119
updateServerURL: '',
119120
changelogURL: '',
120121
whatsNewData: [],
@@ -224,7 +225,7 @@
224225
if(this.changelogURL) {
225226
whatsNew.push({
226227
href: this.changelogURL,
227-
text: t('updatenotificaiton', 'View changelog'),
228+
text: t('updatenotification', 'View changelog'),
228229
icon: 'icon-link',
229230
target: '_blank',
230231
action: ''
@@ -237,23 +238,24 @@
237238
let channelList = [];
238239
239240
channelList.push({
240-
text: t('updatenotificaiton', 'Stable'),
241+
text: t('updatenotification', 'Enterprise'),
242+
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.'),
243+
icon: 'icon-star',
244+
active: this.currentChannel === 'enterprise',
245+
disabled: !this.hasValidSubscription,
246+
action: this.changeReleaseChannelToEnterprise
247+
});
248+
249+
channelList.push({
250+
text: t('updatenotification', 'Stable'),
241251
longtext: t('updatenotification', 'The most recent stable version. It is suited for regular use and will always update to the latest major version.'),
242252
icon: 'icon-checkmark',
243253
active: this.currentChannel === 'stable',
244254
action: this.changeReleaseChannelToStable
245255
});
246256
247257
channelList.push({
248-
text: t('updatenotificaiton', 'Production'),
249-
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.'),
250-
icon: 'icon-star',
251-
active: this.currentChannel === 'production',
252-
action: this.changeReleaseChannelToProduction
253-
});
254-
255-
channelList.push({
256-
text: t('updatenotificaiton', 'Beta'),
258+
text: t('updatenotification', 'Beta'),
257259
longtext: t('updatenotification', 'A pre-release version only for testing new features, not for production environments.'),
258260
icon: 'icon-category-customization',
259261
active: this.currentChannel === 'beta',
@@ -272,19 +274,19 @@
272274
},
273275
274276
isNonDefaultChannel: function() {
275-
return this.currentChannel !== 'production' && this.currentChannel !== 'stable' && this.currentChannel !== 'beta';
277+
return this.currentChannel !== 'enterprise' && this.currentChannel !== 'stable' && this.currentChannel !== 'beta';
276278
},
277279
278280
localizedChannelName: function() {
279281
switch (this.currentChannel) {
280-
case 'production':
281-
return t('updatenotificaiton', 'Production');
282+
case 'enterprise':
283+
return t('updatenotification', 'Enterprise');
282284
break;
283285
case 'stable':
284-
return t('updatenotificaiton', 'Stable');
286+
return t('updatenotification', 'Stable');
285287
break;
286288
case 'beta':
287-
return t('updatenotificaiton', 'Beta');
289+
return t('updatenotification', 'Beta');
288290
break;
289291
default:
290292
return this.currentChannel;
@@ -317,12 +319,12 @@
317319
form.submit();
318320
}.bind(this));
319321
},
322+
changeReleaseChannelToEnterprise: function() {
323+
this.changeReleaseChannel('enterprise')
324+
},
320325
changeReleaseChannelToStable: function() {
321326
this.changeReleaseChannel('stable')
322327
},
323-
changeReleaseChannelToProduction: function() {
324-
this.changeReleaseChannel('production')
325-
},
326328
changeReleaseChannelToBeta: function() {
327329
this.changeReleaseChannel('beta')
328330
},
@@ -375,6 +377,7 @@
375377
this.notifyGroups = data.notifyGroups;
376378
this.isDefaultUpdateServerURL = data.isDefaultUpdateServerURL;
377379
this.versionIsEol = data.versionIsEol;
380+
this.hasValidSubscription = data.hasValidSubscription;
378381
if(data.changes && data.changes.changelogURL) {
379382
this.changelogURL = data.changes.changelogURL;
380383
}

apps/updatenotification/tests/Settings/AdminTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use OCP\IUserSession;
3636
use OCP\L10N\IFactory;
3737
use OCP\L10N\ILanguageIterator;
38+
use OCP\Support\Subscription\IRegistry;
3839
use OCP\Util;
3940
use Test\TestCase;
4041

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

5558
public function setUp() {
5659
parent::setUp();
@@ -60,9 +63,10 @@ public function setUp() {
6063
$this->groupManager = $this->createMock(IGroupManager::class);
6164
$this->dateTimeFormatter = $this->createMock(IDateTimeFormatter::class);
6265
$this->l10nFactory = $this->createMock(IFactory::class);
66+
$this->subscriptionRegistry = $this->createMock(IRegistry::class);
6367

6468
$this->admin = new Admin(
65-
$this->config, $this->updateChecker, $this->groupManager, $this->dateTimeFormatter, $this->l10nFactory
69+
$this->config, $this->updateChecker, $this->groupManager, $this->dateTimeFormatter, $this->l10nFactory, $this->subscriptionRegistry
6670
);
6771
}
6872

@@ -120,6 +124,11 @@ public function testGetFormWithUpdate() {
120124
->with('admin')
121125
->willReturn($group);
122126

127+
$this->subscriptionRegistry
128+
->expects($this->once())
129+
->method('delegateHasValidSubscription')
130+
->willReturn(true);
131+
123132
$params = [
124133
'json' => json_encode([
125134
'isNewVersionAvailable' => true,
@@ -138,6 +147,7 @@ public function testGetFormWithUpdate() {
138147
'notifyGroups' => [
139148
['value' => 'admin', 'label' => 'Administrators'],
140149
],
150+
'hasValidSubscription' => true,
141151
]),
142152
];
143153

config/config.sample.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,6 @@
653653
* - ``daily``
654654
* - ``beta``
655655
* - ``stable``
656-
* - ``production``
657656
*/
658657
'updater.release.channel' => 'stable',
659658

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@
10651065
'OC\\Repair\\NC16\\AddClenupLoginFlowV2BackgroundJob' => $baseDir . '/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php',
10661066
'OC\\Repair\\NC16\\CleanupCardDAVPhotoCache' => $baseDir . '/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php',
10671067
'OC\\Repair\\NC16\\RemoveCypressFiles' => $baseDir . '/lib/private/Repair/NC16/RemoveCypressFiles.php',
1068+
'OC\\Repair\\NC17\\SwitchUpdateChannel' => $baseDir . '/lib/private/Repair/NC17/SwitchUpdateChannel.php',
10681069
'OC\\Repair\\OldGroupMembershipShares' => $baseDir . '/lib/private/Repair/OldGroupMembershipShares.php',
10691070
'OC\\Repair\\Owncloud\\DropAccountTermsTable' => $baseDir . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php',
10701071
'OC\\Repair\\Owncloud\\SaveAccountsTableData' => $baseDir . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
10991099
'OC\\Repair\\NC16\\AddClenupLoginFlowV2BackgroundJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php',
11001100
'OC\\Repair\\NC16\\CleanupCardDAVPhotoCache' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php',
11011101
'OC\\Repair\\NC16\\RemoveCypressFiles' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/RemoveCypressFiles.php',
1102+
'OC\\Repair\\NC17\\SwitchUpdateChannel' => __DIR__ . '/../../..' . '/lib/private/Repair/NC17/SwitchUpdateChannel.php',
11021103
'OC\\Repair\\OldGroupMembershipShares' => __DIR__ . '/../../..' . '/lib/private/Repair/OldGroupMembershipShares.php',
11031104
'OC\\Repair\\Owncloud\\DropAccountTermsTable' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php',
11041105
'OC\\Repair\\Owncloud\\SaveAccountsTableData' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php',

lib/private/Repair.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use OC\Repair\NC16\AddClenupLoginFlowV2BackgroundJob;
4444
use OC\Repair\NC16\CleanupCardDAVPhotoCache;
4545
use OC\Repair\NC16\RemoveCypressFiles;
46+
use OC\Repair\NC17\SwitchUpdateChannel;
4647
use OC\Repair\OldGroupMembershipShares;
4748
use OC\Repair\Owncloud\DropAccountTermsTable;
4849
use OC\Repair\Owncloud\SaveAccountsTableData;
@@ -149,6 +150,7 @@ public static function getRepairSteps() {
149150
new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
150151
new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
151152
\OC::$server->query(RemoveCypressFiles::class),
153+
\OC::$server->query(SwitchUpdateChannel::class),
152154
];
153155
}
154156

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
declare(strict_types=1);
3+
/**
4+
* @copyright Copyright (c) 2019, Morris Jobke <hey@morrisjobke.de>
5+
*
6+
* @license GNU AGPL version 3 or any later version
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
namespace OC\Repair\NC17;
24+
25+
use OCP\IConfig;
26+
use OCP\Migration\IOutput;
27+
use OCP\Migration\IRepairStep;
28+
use OCP\Support\Subscription\IRegistry;
29+
/**
30+
* @deprecated - can be removed in 18
31+
*/
32+
class SwitchUpdateChannel implements IRepairStep {
33+
34+
/** @var IConfig */
35+
private $config;
36+
37+
/** @var IRegistry */
38+
private $subscriptionRegistry;
39+
40+
public function __construct(IConfig $config, IRegistry $subscriptionRegistry) {
41+
$this->config = $config;
42+
$this->subscriptionRegistry = $subscriptionRegistry;
43+
}
44+
45+
public function getName(): string {
46+
return 'Switches from deprecated "production" to "stable" update channel';
47+
}
48+
49+
public function run(IOutput $output): void {
50+
$currentChannel = $this->config->getSystemValue('updater.release.channel', 'stable');
51+
52+
if ($currentChannel === 'production') {
53+
if ($this->subscriptionRegistry->delegateHasValidSubscription()) {
54+
$this->config->setSystemValue('updater.release.channel', 'enterprise');
55+
} else {
56+
$this->config->setSystemValue('updater.release.channel', 'stable');
57+
}
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)