Skip to content

Commit

Permalink
Merge pull request #1742 from yuvipanda/buildOnly
Browse files Browse the repository at this point in the history
Allow passing buildOnly param to the server from the js client
  • Loading branch information
consideRatio authored Oct 12, 2023
2 parents fe2bf1b + 7ba2c84 commit e67edb0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion js/packages/binderhub-client/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export class BinderRepository {
* @param {string} providerSpec Spec of the form <provider>/<repo>/<ref> to pass to the binderhub API.
* @param {URL} buildEndpointUrl API URL of the build endpoint to talk to
* @param {string} buildToken Optional JWT based build token if this binderhub installation requires using build tokens
* @param {boolean} buildOnly Opt out of launching built image by default by passing `build_only` param
*/
constructor(providerSpec, buildEndpointUrl, buildToken) {
constructor(providerSpec, buildEndpointUrl, buildToken, buildOnly) {
this.providerSpec = providerSpec;
// Make sure that buildEndpointUrl is a real URL - this ensures hostname is properly set
if (!(buildEndpointUrl instanceof URL)) {
Expand All @@ -36,6 +37,10 @@ export class BinderRepository {
this.buildUrl.searchParams.append("build_token", buildToken);
}

if (buildOnly) {
this.buildUrl.searchParams.append("build_only", "true");
}

this.eventIteratorQueue = null;
}

Expand Down
8 changes: 8 additions & 0 deletions js/packages/binderhub-client/tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ test("Invalid URL errors out", () => {
}).toThrow(TypeError);
});

test("Passing buildOnly flag works", () => {
const buildEndpointUrl = new URL("https://test-binder.org/build");
const br = new BinderRepository("gh/test/test", buildEndpointUrl, null, true);
expect(br.buildUrl.toString()).toEqual(
"https://test-binder.org/build/gh/test/test?build_only=true",
);
});

test("Trailing slash added if needed", () => {
const buildEndpointUrl = new URL("https://test-binder.org/build");
const br = new BinderRepository("gh/test/test", buildEndpointUrl);
Expand Down

0 comments on commit e67edb0

Please sign in to comment.