gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taldir] branch master updated: add version to footer and build


From: gnunet
Subject: [taler-taldir] branch master updated: add version to footer and build
Date: Fri, 10 Jan 2025 17:12:19 +0100

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository taldir.

The following commit(s) were added to refs/heads/master by this push:
     new fde47a1  add version to footer and build
fde47a1 is described below

commit fde47a1e7390aab82088658d86747e3c8ad7a741
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Fri Jan 10 17:12:13 2025 +0100

    add version to footer and build
---
 Makefile                   | 6 ++++--
 cmd/taldir-server/main.go  | 8 ++++++--
 pkg/rest/taldir.go         | 7 ++++++-
 web/templates/landing.html | 1 +
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 98d08a7..d2ed8a0 100644
--- a/Makefile
+++ b/Makefile
@@ -9,11 +9,13 @@ gana:
        cd third_party/gana/gnu-taler-error-codes && make taler_error_codes.go
        cp third_party/gana/gnu-taler-error-codes/taler_error_codes.go 
internal/gana/
 
+VERSION=`git describe --tags`
+
 server:
-       go build ./cmd/taldir-server
+       go build -ldflags "-X main.version=${VERSION}"  ./cmd/taldir-server
 
 cli:
-       go build ./cmd/taldir-cli
+       go build -ldflags "-X main.version=${VERSION}" ./cmd/taldir-cli
 
 install: server cli
        go install ./cmd/taldir-server && go install ./cmd/taldir-cli
diff --git a/cmd/taldir-server/main.go b/cmd/taldir-server/main.go
index fa1ce08..e8f3759 100644
--- a/cmd/taldir-server/main.go
+++ b/cmd/taldir-server/main.go
@@ -35,7 +35,10 @@ import (
        taldir "taler.net/taldir/pkg/rest"
 )
 
-var t taldir.Taldir
+var (
+       t taldir.Taldir
+       version string
+)
 
 func handleRequests(t *taldir.Taldir) {
        
log.Fatal(http.ListenAndServe(t.Cfg.Section("taldir").Key("bind_to").MustString("localhost:11000"),
 t.Router))
@@ -45,12 +48,13 @@ func main() {
        var cfgFlag = flag.String("c", "", "Configuration file to use")
 
        flag.Parse()
+       log.Println(version)
        cfgfile := "taldir.conf"
        if len(*cfgFlag) != 0 {
                cfgfile = *cfgFlag
        }
        t := taldir.Taldir{}
-       t.Initialize(cfgfile)
+       t.Initialize(cfgfile, version)
        t.Cfg.WriteTo(os.Stdout)
        handleRequests(&t)
 }
diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go
index 206e266..3a8a4f3 100644
--- a/pkg/rest/taldir.go
+++ b/pkg/rest/taldir.go
@@ -63,6 +63,9 @@ type Taldir struct {
        // Our configuration from the config.json
        Cfg *ini.File
 
+       // TalDir version
+       Version string
+
        // Map of supported validators as defined in the configuration
        Validators map[string]Validator
 
@@ -647,6 +650,7 @@ func (t *Taldir) landingPage(w http.ResponseWriter, r 
*http.Request) {
 
        fullData := map[string]interface{}{
                "validators": t.Validators,
+               "version": t.Version,
                "error": r.URL.Query().Get("error"),
        }
        err := t.LandingPageTpl.Execute(w, fullData)
@@ -737,7 +741,7 @@ func (t *Taldir) setupHandlers() {
 }
 
 // Initialize the Taldir instance with cfgfile
-func (t *Taldir) Initialize(cfgfile string) {
+func (t *Taldir) Initialize(cfgfile string, version string) {
        _cfg, err := ini.LooseLoad(cfgfile)
        if err != nil {
                log.Fatalf("Failed to read config: %v", err)
@@ -748,6 +752,7 @@ func (t *Taldir) Initialize(cfgfile string) {
                fmt.Println("Production mode enabled")
        }
 
+       t.Version = version
        t.BaseUrl = 
t.Cfg.Section("taldir").Key("base_url").MustString("http://localhost:11000";)
        t.Validators = make(map[string]Validator)
        for _, sec := range t.Cfg.Sections() {
diff --git a/web/templates/landing.html b/web/templates/landing.html
index 3bd905e..dc20351 100644
--- a/web/templates/landing.html
+++ b/web/templates/landing.html
@@ -35,6 +35,7 @@
       </div>
     </body>
     <footer class="fs-6 text-sm-end mt-4 me-2">
+      <span>Version: {{.version}}</span><br/>
       <span>Source: <a href="https://git.taler.net/taldir.git";>Browse Git 
Repository</a></span>
     </footer>
 </html>

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]