mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-18 21:27:51 +00:00
Update release.contract
type from string
to JsonType
This commit is contained in:
parent
19be0fec1a
commit
61af57acc9
@ -127,7 +127,7 @@ export const createRelease = async function (
|
||||
composition: Composition,
|
||||
draft: boolean,
|
||||
semver: string | undefined,
|
||||
contract: string | undefined,
|
||||
contract: import('@balena/compose/dist/release/models').ReleaseModel['contract'],
|
||||
): Promise<Release> {
|
||||
const _ = require('lodash') as typeof import('lodash');
|
||||
const crypto = require('crypto') as typeof import('crypto');
|
||||
|
@ -1404,7 +1404,7 @@ export async function deployProject(
|
||||
composition,
|
||||
isDraft,
|
||||
contract?.version,
|
||||
contract ? JSON.stringify(contract) : undefined,
|
||||
contract,
|
||||
),
|
||||
);
|
||||
const { client: pineClient, release, serviceImages } = $release;
|
||||
@ -1500,7 +1500,9 @@ export function createRunLoop(tick: (...args: any[]) => void) {
|
||||
|
||||
async function getContractContent(
|
||||
filePath: string,
|
||||
): Promise<Dictionary<any> | undefined> {
|
||||
): Promise<
|
||||
import('@balena/compose/dist/release/models').ReleaseModel['contract']
|
||||
> {
|
||||
let fileContentAsString;
|
||||
try {
|
||||
fileContentAsString = await fs.readFile(filePath, 'utf8');
|
||||
|
@ -208,9 +208,8 @@ export async function validateSecureBootOptionAndWarn(
|
||||
throw new ExpectedError(`Error: No ${version} release for ${slug}`);
|
||||
}
|
||||
|
||||
const contract = osRelease.contract ? JSON.parse(osRelease.contract) : null;
|
||||
if (
|
||||
contract?.provides.some((entry: Dictionary<string>) => {
|
||||
osRelease.contract?.provides.some((entry: Dictionary<string>) => {
|
||||
return entry.type === 'sw.feature' && entry.slug === 'secureboot';
|
||||
})
|
||||
) {
|
||||
|
@ -93,7 +93,7 @@ export class DeviceAPI {
|
||||
);
|
||||
}
|
||||
|
||||
public async getTargetState(): Promise<any> {
|
||||
public async getTargetState() {
|
||||
const url = this.getUrlForAction('getTargetState');
|
||||
|
||||
return DeviceAPI.promisifiedRequest(
|
||||
|
@ -636,6 +636,7 @@ export function generateTargetState(
|
||||
services[idx] = {
|
||||
...defaults,
|
||||
...opts,
|
||||
// TODO: is this affected by the `contract` typing change?
|
||||
...(contract != null ? { contract } : {}),
|
||||
...{
|
||||
imageId: idx,
|
||||
|
@ -183,9 +183,11 @@ describe('balena deploy', function () {
|
||||
api.expectPostRelease({
|
||||
inspectRequest: (_uri: string, requestBody: nock.Body) => {
|
||||
const body = requestBody.valueOf() as Partial<ReleaseRequest>;
|
||||
expect(body.contract).to.be.equal(
|
||||
'{"name":"testContract","type":"sw.application","version":"1.5.2"}',
|
||||
);
|
||||
expect(body.contract).to.deep.equal({
|
||||
name: 'testContract',
|
||||
type: 'sw.application',
|
||||
version: '1.5.2',
|
||||
});
|
||||
expect(body.is_final).to.be.true;
|
||||
},
|
||||
});
|
||||
@ -232,9 +234,11 @@ describe('balena deploy', function () {
|
||||
api.expectPostRelease({
|
||||
inspectRequest: (_uri: string, requestBody: nock.Body) => {
|
||||
const body = requestBody.valueOf() as Partial<ReleaseRequest>;
|
||||
expect(body.contract).to.be.equal(
|
||||
'{"name":"testContract","type":"sw.application","version":"1.5.2"}',
|
||||
);
|
||||
expect(body.contract).to.deep.equal({
|
||||
name: 'testContract',
|
||||
type: 'sw.application',
|
||||
version: '1.5.2',
|
||||
});
|
||||
expect(body.semver).to.be.equal('1.5.2');
|
||||
expect(body.is_final).to.be.false;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user