Skip to content

Commit

Permalink
change git to info
Browse files Browse the repository at this point in the history
  • Loading branch information
theruziev committed Mar 2, 2024
1 parent 02f87af commit b24c05d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .theruziev/taskfile/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ vars:
GIT_BRANCH:
sh: git branch --show-current
LD_FLAGS: >-
-X '{{.PACKAGE_PREFIX}}/internal/pkg/git.Version={{.GIT_TAG}}'
-X '{{.PACKAGE_PREFIX}}/internal/pkg/git.Commit={{.GIT_COMMIT}}'
-X '{{.PACKAGE_PREFIX}}/internal/pkg/info.Version={{.GIT_TAG}}'
-X '{{.PACKAGE_PREFIX}}/internal/pkg/info.Commit={{.GIT_COMMIT}}'
4 changes: 2 additions & 2 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"encoding/json"
"fmt"

"github.com/theruziev/starter/internal/pkg/git"
"github.com/theruziev/starter/internal/pkg/info"
)

type versionCli struct{}

func (v *versionCli) Run(_ *contextCli) error {
resultJSON, err := json.Marshal(git.Information())
resultJSON, err := json.Marshal(info.Information())
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/app/server/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/go-chi/chi/v5"
"github.com/theruziev/starter/internal/pkg/closer"
"github.com/theruziev/starter/internal/pkg/git"
"github.com/theruziev/starter/internal/pkg/healthcheck"
"github.com/theruziev/starter/internal/pkg/info"
"github.com/theruziev/starter/internal/pkg/logx"
"google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"
Expand Down Expand Up @@ -53,7 +53,7 @@ func (s *Server) initRouter(_ context.Context) {
})
r.Get("/live", healthcheck.NewLivenessHandler())
r.Get("/ready", healthcheck.NewReadinessHandler(s.healthcheck))
r.Get("/version", git.Handler())
r.Get("/version", info.Handler())
s.r = r
}

Expand Down
9 changes: 5 additions & 4 deletions internal/pkg/git/git.go → internal/pkg/info/info.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package git
package info

import (
"encoding/json"
Expand All @@ -20,8 +20,9 @@ func Handler() http.HandlerFunc {
info := Information()
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
jsonBytes, _ := json.Marshal(info)
_, _ = w.Write(jsonBytes)

if err := json.NewEncoder(w).Encode(info); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
}

0 comments on commit b24c05d

Please sign in to comment.