diff --git a/plugin.go b/plugin.go index ea03335..69597d5 100644 --- a/plugin.go +++ b/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 { diff --git a/routes/routes.go b/routes/routes.go index 0ada8f1..45bf54e 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -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) }