mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-21 22:47:48 +00:00
4676396b5f
Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
22 lines
500 B
TypeScript
22 lines
500 B
TypeScript
import { BalenaSDK } from 'balena-sdk';
|
|
import memoize = require('lodash/memoize');
|
|
|
|
export const serviceIdToName = memoize(
|
|
async (sdk: BalenaSDK, serviceId: number): Promise<string | undefined> => {
|
|
const serviceName = await sdk.pine.get({
|
|
resource: 'service',
|
|
id: serviceId,
|
|
options: {
|
|
$select: 'service_name',
|
|
},
|
|
});
|
|
|
|
if (serviceName != null) {
|
|
return serviceName.service_name;
|
|
}
|
|
return;
|
|
},
|
|
// Memoize the call based on service id
|
|
(_sdk, id) => id.toString(),
|
|
);
|