Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add buildId to version after successful build #1029

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/api-server/lib/service/algorithms.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class AlgorithmStore {
* first, we create a new version, then if there are no versions,
* we update the current algorithm with the new build image.
*/
const { algorithm, algorithmName: name, algorithmImage } = build;
const { buildId, algorithm, algorithmName: name, algorithmImage } = build;
const versions = await stateManager.algorithms.versions.list({ name });
const newAlgorithm = merge({}, algorithm, { algorithmImage, options: { pending: false } });
const version = await versionsService.createVersion(newAlgorithm);
const version = await versionsService.createVersion(newAlgorithm, buildId);

if (versions.length === 0) {
await algorithmStore.storeAlgorithm({ ...newAlgorithm, version });
Expand Down
5 changes: 4 additions & 1 deletion core/api-server/lib/service/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class AlgorithmVersions {

/**
* This method creates new algorithm version.
* Version is created for any change in algorithm or after successful build.
* If the version created after build, a buildId will attached to version.
* The version has a two important properties that automatically generated.
* 1. version: <string> (10 length uid).
* 2. semver: <string> (major, minor, patch).
Expand All @@ -91,7 +93,7 @@ class AlgorithmVersions {
* 5) if lock was unsuccessful, try to increment the semver again.
* 6) create the version.
*/
async createVersion(algorithm) {
async createVersion(algorithm, buildId) {
const { name } = algorithm;
const version = uid({ length: SETTINGS.VERSION_LENGTH });
const latestSemver = await this._getLatestSemver({ name });
Expand All @@ -102,6 +104,7 @@ class AlgorithmVersions {
const newVersion = {
version,
semver,
buildId,
created: Date.now(),
name,
algorithm: { ...algorithm, version }
Expand Down