Skip to content

Commit

Permalink
package previous version status validation implementation (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexey Shtykov <[email protected]>
  • Loading branch information
ifdru74 and Alexey Shtykov authored Jan 30, 2025
1 parent 6156d33 commit bb7db7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion qubership-apihub-service/exception/ErrorCodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ const IncorrectFileNameMsg = "File name is incorrect: '$name'"
const FileByRefNotFound = "47"
const FileByRefNotFoundMsg = "File for path $fileId not found by reference $ref in project $projectGitId"

const PreviousPackageVersionNotRelease = "48"
const PreviousPackageVersionNotReleaseMsg = "Previous version $version for package $packageId is not in the 'release' status"

const PublishedPackageVersionNotFound = "49"
const PublishedPackageVersionNotFoundMsg = "Published version $version not found for package $packageId"

Expand Down Expand Up @@ -724,4 +727,4 @@ const InvalidPackageKind = "6802"
const InvalidPackageKindMsg = `Action is not allowed for package with kind="$kind", allowed kind - "$allowedKind"`

const HostNotAllowed = "6900"
const HostNotAllowedMsg = "Host not allowed: $host"
const HostNotAllowedMsg = "Host not allowed: $host"
10 changes: 9 additions & 1 deletion qubership-apihub-service/service/VersionService.go
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,14 @@ func (v versionServiceImpl) StartPublishFromCSV(ctx context.SecurityContext, req
Params: map[string]interface{}{"packageId": previousVersionPackageId, "version": req.PreviousVersion},
}
}
if prevVersion.Status != string(view.Release) {
return "", &exception.CustomError{
Status: http.StatusNotFound,
Code: exception.PreviousPackageVersionNotRelease,
Message: exception.PreviousPackageVersionNotReleaseMsg,
Params: map[string]interface{}{"packageId": previousVersionPackageId, "version": req.PreviousVersion},
}
}
}

publishEntity := &entity.CSVDashboardPublishEntity{
Expand Down Expand Up @@ -2427,4 +2435,4 @@ func getCSVSeparator(record string) *rune {
}
}
return nil
}
}

0 comments on commit bb7db7e

Please sign in to comment.