Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Add API to set update channel #119

Merged
merged 1 commit into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions logic/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,7 @@ export async function requestReboot(): Promise<systemStatus> {
throw new Error('Unable to request reboot');
}
}

export async function setUpdateChannel(channel: string): Promise<void> {
return runCommand(`set-update-channel ${channel}`);
}
8 changes: 7 additions & 1 deletion routes/v2/system.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Router from '@koa/router';
import {errorHandler} from '@runcitadel/utils';
import {errorHandler, typeHelper} from '@runcitadel/utils';

import * as systemLogic from '../../logic/system.js';
import * as diskLogic from '../../logic/disk.js';
Expand Down Expand Up @@ -143,6 +143,12 @@ router.get('/disk-type', async (ctx, next) => {
await next();
});

router.put('/update-channel', async (ctx, next) => {
typeHelper.isString(ctx.body.channel, ctx);
await systemLogic.setUpdateChannel(ctx.body.channel as string);
await next();
});

router.get('/', async (ctx, next) => {
ctx.body = {os: constants.IS_CITADEL_OS ? 'Citadel OS' : 'unknown'};
await next();
Expand Down