feat: add build-time version injection via ldflags
- Remove hardcoded PluginVersion constant - Add Version variable settable via ldflags - Update routes.go to use Version for UI display - Version now injected by server build process
This commit is contained in:
16
plugin.go
16
plugin.go
@@ -17,16 +17,16 @@ import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
const (
|
||||
PluginName = "vault"
|
||||
PluginVersion = "1.0.0"
|
||||
)
|
||||
const PluginName = "vault"
|
||||
|
||||
// PluginVersion can be set at build time
|
||||
var Version = PluginVersion
|
||||
// Version can be set at build time via ldflags:
|
||||
// -ldflags "-X git.marketally.com/gitcaddy/gitcaddy-vault.Version=v1.0.30"
|
||||
var Version = "dev"
|
||||
|
||||
// init automatically registers the vault when this package is imported
|
||||
func init() {
|
||||
// Set version in routes package
|
||||
routes.Version = Version
|
||||
Register()
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func (p *VaultPlugin) Name() string {
|
||||
|
||||
// Version returns the plugin version
|
||||
func (p *VaultPlugin) Version() string {
|
||||
return PluginVersion
|
||||
return Version
|
||||
}
|
||||
|
||||
// Description returns the plugin description
|
||||
@@ -59,7 +59,7 @@ func (p *VaultPlugin) Description() string {
|
||||
|
||||
// Init initializes the plugin
|
||||
func (p *VaultPlugin) Init(ctx context.Context) error {
|
||||
log.Info("Initializing GitCaddy Vault plugin v%s", PluginVersion)
|
||||
log.Info("Initializing GitCaddy Vault plugin v%s", Version)
|
||||
|
||||
// Load and validate license
|
||||
if err := p.license.Load(); err != nil {
|
||||
|
||||
@@ -22,6 +22,9 @@ import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
// Version is set by the main vault package at init time
|
||||
var Version = "dev"
|
||||
|
||||
// Template names for vault pages
|
||||
const (
|
||||
tplVaultList templates.TplName = "repo/vault/list"
|
||||
@@ -933,7 +936,7 @@ func webListSecrets(lic *license.Manager) http.HandlerFunc {
|
||||
ctx.Data["LicenseTier"] = licInfo.Tier
|
||||
ctx.Data["LicenseValid"] = licInfo.Valid
|
||||
}
|
||||
ctx.Data["VaultVersion"] = "1.0.24"
|
||||
ctx.Data["VaultVersion"] = Version
|
||||
|
||||
ctx.HTML(http.StatusOK, tplVaultList)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user