Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: adds comment to deployment and build APPSITE-1549
  • Loading branch information
simon-scherzinger committed Jan 9, 2020
1 parent 8c859c4 commit df07ebe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
21 changes: 12 additions & 9 deletions src/resources/apps/PlatformResource.ts
Expand Up @@ -134,11 +134,12 @@ class PlatformResource extends Resource {
/**
* Start a new build for this platform.
*
* @property {String} comment Comment to add to this Build.
* @returns {Promise<BuildResource>} The created build, probably in running state.
*/
createBuild(): Promise<BuildResource> {
return post(this[environmentSymbol], this.newRequest().follow('ec:app/builds')).then(
([res, traversal]) => new BuildResource(res, this[environmentSymbol], traversal),
createBuild(comment?: string): Promise<BuildResource> {
return post(this[environmentSymbol], this.newRequest().follow('ec:app/builds'), { comment }).then(
([res, traversal]) => new BuildResource(res, this[environmentSymbol], traversal)
);
}

Expand All @@ -149,11 +150,13 @@ class PlatformResource extends Resource {
* to which the build should be deployed.
* @param {string|BuildResource|BuildList|Array<string|BuildResource>} buildID build which
* should be deployed.
* @param {string} comment Comment to add to new Deployment.
* @returns {Promise<DeploymentResource>} The created deployment, probably in running state.
*/
createDeployment(
targetIDs: string | TargetResource | TargetList | Array<string | TargetResource>,
buildID: string | BuildResource | BuildList | Array<string | BuildResource>,
comment?: string
): Promise<DeploymentResource> {
return Promise.resolve()
.then(() => {
Expand All @@ -173,7 +176,7 @@ class PlatformResource extends Resource {
}

targetIDs = (<Array<string | TargetResource>>targetIDs).map((target) =>
target instanceof TargetResource ? target.targetID : target,
target instanceof TargetResource ? target.targetID : target
);

const request = this.newRequest()
Expand All @@ -184,7 +187,7 @@ class PlatformResource extends Resource {
targetID: (<Array<string>>targetIDs).join(','),
});

return post(this[environmentSymbol], request);
return post(this[environmentSymbol], request, { comment });
})
.then(([res, traversal]) => new DeploymentResource(res, this[environmentSymbol], traversal));
}
Expand All @@ -197,7 +200,7 @@ class PlatformResource extends Resource {
* @returns {Promise<DeploymentResource>} The created deployment, probably in running state.
*/
deployLatestBuild(
targetIDs: string | TargetResource | TargetList | Array<string | TargetResource>,
targetIDs: string | TargetResource | TargetList | Array<string | TargetResource>
): Promise<DeploymentResource> {
return Promise.resolve().then(() => {
const link = this.getLink('ec:app/build/latest');
Expand Down Expand Up @@ -309,7 +312,7 @@ class PlatformResource extends Resource {
*/
loadCodeSource(): Promise<CodeSourceResource> {
return get(this[environmentSymbol], this.newRequest().follow('ec:app/codesource')).then(
([res, traversal]) => new CodeSourceResource(res, this[environmentSymbol], traversal),
([res, traversal]) => new CodeSourceResource(res, this[environmentSymbol], traversal)
);
}

Expand All @@ -320,7 +323,7 @@ class PlatformResource extends Resource {
*/
loadDataSource(): Promise<DataSourceResource> {
return get(this[environmentSymbol], this.newRequest().follow('ec:app/datasource')).then(
([res, traversal]) => new DataSourceResource(res, this[environmentSymbol], traversal),
([res, traversal]) => new DataSourceResource(res, this[environmentSymbol], traversal)
);
}

Expand All @@ -334,7 +337,7 @@ class PlatformResource extends Resource {
.then(() => {
const qs: any = {};
const targetIDs = this.getLinks('ec:app/target').map(
(l: any) => querystring.parse(l.href.split('?')[1]).targetID,
(l: any) => querystring.parse(l.href.split('?')[1]).targetID
);
if (targetIDs.length === 1) {
targetIDs.push(targetIDs[0]);
Expand Down
4 changes: 2 additions & 2 deletions test/apps/PlatformResource.test.js
Expand Up @@ -179,7 +179,7 @@ describe('Platform Resource', () => {
stub.returns(resolver('build-single.json'));

return resource
.createBuild()
.createBuild('This is a comment')
.then(() => {
stub.should.be.calledOnce;
stub.restore();
Expand Down Expand Up @@ -249,7 +249,7 @@ describe('Platform Resource', () => {
stub.returns(resolver('deployment-single.json'));

return resource
.createDeployment('id', 'id')
.createDeployment('id', 'id', 'This is a comment')
.then(() => {
stub.should.be.calledOnce;
stub.restore();
Expand Down

0 comments on commit df07ebe

Please sign in to comment.