Skip to content

Commit

Permalink
Add RD_FORCE_UPDATES_ENABLED env var
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Pickering <[email protected]>
  • Loading branch information
adamkpickering committed May 23, 2023
1 parent 2fef035 commit bffa8c4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions dev-app-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
owner: rancher-sandbox
repo: rancher-desktop
updaterCacheDirName: rancher-desktop
provider: custom
upgradeServer: https://desktop.version.rancher.io/v1/checkupgrade
vPrefixedTagName: true
7 changes: 6 additions & 1 deletion pkg/rancher-desktop/config/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,12 @@ export function load(deploymentProfiles: DeploymentProfileType): Settings {
settings.virtualMachine.memoryInGB = Math.min(6, Math.round(totalMemoryInGB / 4.0));
}
}
if (os.platform() === 'linux' && !process.env['APPIMAGE']) {

// determine whether updates should be enabled
if (process.env.RD_FORCE_UPDATES_ENABLED) {
console.debug('updates enabled via RD_FORCE_UPDATES_ENABLED');
settings.application.updater.enabled = true;
} else if (os.platform() === 'linux' && !process.env.APPIMAGE) {
settings.application.updater.enabled = false;
} else {
const appVersion = getProductionVersion();
Expand Down
8 changes: 6 additions & 2 deletions pkg/rancher-desktop/main/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Electron.ipcMain.on('update-state', () => {
});

Electron.ipcMain.on('update-apply', () => {
if (!autoUpdater) {
if (!autoUpdater || process.env.RD_FORCE_UPDATES_ENABLED) {
return;
}
autoUpdater.quitAndInstall();
Expand Down Expand Up @@ -125,6 +125,10 @@ async function getUpdater(): Promise<AppUpdater | undefined> {
throw e;
}

if (process.env.RD_FORCE_UPDATES_ENABLED) {
updater.forceDevUpdateConfig = true;
}

updater.logger = console;
updater.autoDownload = true;
updater.autoInstallOnAppQuit = false;
Expand Down Expand Up @@ -246,7 +250,7 @@ export default async function setupUpdate(enabled: boolean, doInstall = false):
* @returns Whether the update is being installed.
*/
async function doInitialUpdateCheck(doInstall = false): Promise<boolean> {
if (doInstall && await hasQueuedUpdate()) {
if (doInstall && await hasQueuedUpdate() && !process.env.RD_FORCE_UPDATES_ENABLED) {
console.log('Update is cached; forcing re-check to install.');

return await new Promise((resolve) => {
Expand Down

0 comments on commit bffa8c4

Please sign in to comment.