feat: add application versioning support to backend and UI
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m38s
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m38s
- Introduce APP_VERSION build argument and environment variable in Dockerfile. - Load AppVersion from environment variables in the configuration loader. - Pass the application version to the HTML renderer and expose it to templates via PageData. - Update tests to verify the version is correctly rendered in the footer.
This commit is contained in:
@@ -8,13 +8,15 @@ import (
|
||||
)
|
||||
|
||||
type Renderer struct {
|
||||
templates map[string]*template.Template
|
||||
appName string
|
||||
baseURL string
|
||||
templates map[string]*template.Template
|
||||
appName string
|
||||
appVersion string
|
||||
baseURL string
|
||||
}
|
||||
|
||||
type PageData struct {
|
||||
AppName string
|
||||
AppVersion string
|
||||
BaseURL string
|
||||
Title string
|
||||
Description string
|
||||
@@ -25,7 +27,7 @@ type PageData struct {
|
||||
Data any
|
||||
}
|
||||
|
||||
func NewRenderer(templateDir, appName, baseURL string) (*Renderer, error) {
|
||||
func NewRenderer(templateDir, appName, appVersion, baseURL string) (*Renderer, error) {
|
||||
layouts, err := filepath.Glob(filepath.Join(templateDir, "layouts", "*.html"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -56,14 +58,16 @@ func NewRenderer(templateDir, appName, baseURL string) (*Renderer, error) {
|
||||
}
|
||||
|
||||
return &Renderer{
|
||||
templates: templates,
|
||||
appName: appName,
|
||||
baseURL: baseURL,
|
||||
templates: templates,
|
||||
appName: appName,
|
||||
appVersion: appVersion,
|
||||
baseURL: baseURL,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *Renderer) Render(w http.ResponseWriter, status int, page string, data PageData) {
|
||||
data.AppName = r.appName
|
||||
data.AppVersion = r.appVersion
|
||||
data.BaseURL = r.baseURL
|
||||
data.CurrentYear = time.Now().Year()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user