MCPcopy
hub / github.com/caprover/caprover / setDeployedVersionAndImage

Method setDeployedVersionAndImage

src/datastore/AppsDataStore.ts:516–564  ·  view source on GitHub ↗
(
        appName: string,
        deployedVersion: number,
        builtImage: IBuiltImage
    )

Source from the content-addressed store, hash-verified

514 }
515
516 setDeployedVersionAndImage(
517 appName: string,
518 deployedVersion: number,
519 builtImage: IBuiltImage
520 ) {
521 if (!appName) {
522 throw ApiStatusCodes.createError(
523 ApiStatusCodes.STATUS_ERROR_GENERIC,
524 'App Name should not be empty'
525 )
526 }
527
528 if (!builtImage || !builtImage.imageName) {
529 throw ApiStatusCodes.createError(
530 ApiStatusCodes.STATUS_ERROR_GENERIC,
531 'ImageName Name should not be empty'
532 )
533 }
534
535 const self = this
536
537 return this.getAppDefinition(appName) //
538 .then(function (app) {
539 const versions = app.versions
540
541 let found = false
542
543 for (let i = 0; i < versions.length; i++) {
544 const element = versions[i]
545 if (element.version === deployedVersion) {
546 element.deployedImageName = builtImage.imageName
547 element.gitHash = builtImage.gitHash
548 found = true
549 break
550 }
551 }
552
553 if (!found) {
554 throw ApiStatusCodes.createError(
555 ApiStatusCodes.STATUS_ERROR_GENERIC,
556 `Version trying to deploy not found ${deployedVersion}`
557 )
558 }
559
560 app.deployedVersion = deployedVersion
561
562 return self.saveApp(appName, app)
563 })
564 }
565
566 createNewVersion(appName: string) {
567 if (!appName) {

Callers 1

Calls 3

getAppDefinitionMethod · 0.95
createErrorMethod · 0.80
saveAppMethod · 0.80

Tested by

no test coverage detected