Skip to content

Commit 17602e8

Browse files
committed
Add release notes to promoteRelease
1 parent d92f049 commit 17602e8

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

pacts/npm_consumer-vp_service.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@
113113
"description": "a request for promoting a release",
114114
"providerState": "release promoted",
115115
"request": {
116+
"body": {
117+
"channelIds": [
118+
"channelid"
119+
],
120+
"releaseNotesGzip": "H4sIAAAAAAAAA1MqSs1JTSxOVcjLL0ktVgIAxFWEEQ8AAAA=",
121+
"versionLabel": "v1.0.0"
122+
},
123+
"headers": {
124+
"Content-Type": "application/json"
125+
},
116126
"method": "POST",
117127
"path": "/app/1234abcd/release/1/promote"
118128
},

src/releases.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ReleaseChart, exportedForTesting, KotsSingleSpec, createReleaseFromChar
33
import * as mockttp from "mockttp";
44
import * as fs from "fs-extra";
55
import * as path from "path";
6-
import { sl } from "date-fns/locale";
6+
import { gzip } from "pako";
77

88
const areReleaseChartsPushed = exportedForTesting.areReleaseChartsPushed;
99
const getReleaseByAppId = exportedForTesting.getReleaseByAppId;
@@ -23,7 +23,12 @@ describe("Promote Release", () => {
2323
uponReceiving: "a request for promoting a release",
2424
withRequest: {
2525
method: "POST",
26-
path: "/app/1234abcd/release/1/promote"
26+
path: "/app/1234abcd/release/1/promote",
27+
body: {
28+
versionLabel: "v1.0.0",
29+
channelIds: ["channelid"],
30+
releaseNotesGzip: Buffer.from(gzip(JSON.stringify("release notes"))).toString("base64")
31+
}
2732
},
2833
willRespondWith: {
2934
status: 200,
@@ -35,7 +40,7 @@ describe("Promote Release", () => {
3540
apiClient.apiToken = "abcd1234";
3641
apiClient.endpoint = globalThis.provider.mockService.baseUrl;
3742

38-
return promoteReleaseByAppId(apiClient, "1234abcd", "channelid", 1, "v1.0.0")
43+
return promoteReleaseByAppId(apiClient, "1234abcd", "channelid", 1, "v1.0.0", "release notes")
3944
.then(() => {
4045
expect(true).toEqual(true);
4146
})

src/releases.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,20 +213,23 @@ function isSupportedExt(ext: string): boolean {
213213
return supportedExts.includes(ext);
214214
}
215215

216-
export async function promoteRelease(vendorPortalApi: VendorPortalApi, appSlug: string, channelId: string, releaseSequence: number, version: string) {
216+
export async function promoteRelease(vendorPortalApi: VendorPortalApi, appSlug: string, channelId: string, releaseSequence: number, version: string, releaseNotes?: string) {
217217
// 1. get the app id from the app slug
218218
const app = await getApplicationDetails(vendorPortalApi, appSlug);
219219

220220
// 2. promote the release
221-
await promoteReleaseByAppId(vendorPortalApi, app.id, channelId, releaseSequence, version);
221+
await promoteReleaseByAppId(vendorPortalApi, app.id, channelId, releaseSequence, version, releaseNotes);
222222
}
223223

224-
async function promoteReleaseByAppId(vendorPortalApi: VendorPortalApi, appId: string, channelId: string, releaseSequence: number, version: string) {
224+
async function promoteReleaseByAppId(vendorPortalApi: VendorPortalApi, appId: string, channelId: string, releaseSequence: number, version: string, releaseNotes?: string) {
225225
const http = await vendorPortalApi.client();
226226
const reqBody = {
227227
versionLabel: version,
228228
channelIds: [channelId]
229229
};
230+
if (releaseNotes) {
231+
reqBody["releaseNotesGzip"] = gzipData(releaseNotes);
232+
}
230233
const uri = `${vendorPortalApi.endpoint}/app/${appId}/release/${releaseSequence}/promote`;
231234
const res = await http.post(uri, JSON.stringify(reqBody));
232235
if (res.message.statusCode != 200) {

0 commit comments

Comments
 (0)