-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consumer API: Endpoint for reading the current major version of the B…
…ackbone (#704) * feat: add version endpoint * fix: return the actual majorVersion of the backbone * refactoring * refactor: rename * fix: implement another approach for getting the major version of the backbone * fix: version * Revert "fix: version" This reverts commit 14cd86e. * feat: add exception when version is null or empty * fix: remove hardcoded version & add version to other dockerfiles * Revert "fix: remove hardcoded version & add version to other dockerfiles" This reverts commit 29a32ac. * fix: remove hardcoded version * Revert "fix: remove hardcoded version" This reverts commit 8cb1402. * fix: remove hardcoded version number * fix: build arg version * fix: add run echo command to version * fix: remove echo * fix: use publish * fix: add version to property group * Revert "fix: add version to property group" This reverts commit 6a270ca. * chore: simplify docker file * chore: add version to dockerfiles * chore: add version tag to build container image * refactor: add VersionResponse * fix: formatting * chore: change service to singleton * chore: remove nullable operator --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
dace53d
commit cd92fba
Showing
22 changed files
with
90 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Backbone.ConsumerApi.Controllers; | ||
|
||
[Route("api/v1/[controller]")] | ||
public class VersionController : ControllerBase | ||
{ | ||
private readonly VersionService _versionService; | ||
|
||
public VersionController(VersionService versionService) | ||
{ | ||
_versionService = versionService; | ||
} | ||
|
||
[HttpGet] | ||
[AllowAnonymous] | ||
[ProducesResponseType(typeof(VersionResponse), StatusCodes.Status200OK)] | ||
public async Task<IActionResult> GetBackboneMajorVersion(CancellationToken cancellationToken) | ||
{ | ||
var majorVersion = await _versionService.GetBackboneMajorVersion(); | ||
return Ok(new VersionResponse { MajorVersion = majorVersion }); | ||
} | ||
} | ||
|
||
public class VersionResponse | ||
{ | ||
public required string MajorVersion { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Backbone.ConsumerApi; | ||
|
||
public class VersionService | ||
{ | ||
public async Task<string> GetBackboneMajorVersion() | ||
{ | ||
var assembly = System.Reflection.Assembly.GetExecutingAssembly(); | ||
var version = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion; | ||
|
||
if (string.IsNullOrEmpty(version)) | ||
throw new InvalidOperationException("The file version information could not be retrieved."); | ||
|
||
var majorVersion = version.Split('.', 2)[0]; | ||
|
||
return await Task.FromResult(majorVersion); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters