Allow getting the target state when not in local mode

Change-type: patch
Closes: #1176
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2020-01-29 15:30:17 +00:00
parent 6bb7a5fd57
commit 3ff3bce605
2 changed files with 3 additions and 9 deletions

View File

@ -922,7 +922,9 @@ Response:
These endpoints are mainly for use by the CLI, for working with a local mode device.
As such they are not recommended for general use.
The device must be in local mode before these endpoints are called.
The device must be in local mode before these endpoints are
called, with the exception of `GET /v2/local/target-state`,
which can be called when the device is not in local mode.
#### Get current target state (GET /v2/local/target-state)

View File

@ -234,14 +234,6 @@ export function createV2Api(router: Router, applications: ApplicationManager) {
);
router.get('/v2/local/target-state', async (_req, res) => {
const localMode = await deviceState.config.get('localMode');
if (!localMode) {
return res.status(400).json({
status: 'failed',
message: 'Target state can only be retrieved when in local mode',
});
}
const targetState = await deviceState.getTarget();
// We avoid using cloneDeep here, as the class