Browse Source

Add commit hash to index metadata

feature/add-commit-hash-to-index-metadata
Fabian Vowie 3 years ago
parent
commit
b2a1e5a547
No known key found for this signature in database GPG Key ID: C27317C33B27C410
  1. 3
      build.sh
  2. 5
      main.go

3
build.sh

@ -0,0 +1,3 @@
#!/bin/bash
GIT_COMMIT=$(git rev-parse --short HEAD); go build -ldflags "-X main.GitCommit=$GIT_COMMIT"

5
main.go

@ -15,9 +15,12 @@ import (
const Name string = "Lithium" const Name string = "Lithium"
const Version string = "0.1.0" const Version string = "0.1.0"
var GitCommit string
type Metadata struct { type Metadata struct {
Name string `json:"name"` Name string `json:"name"`
Version string `json:"version"` Version string `json:"version"`
CommitHash string `json:"commit_hash"`
} }
func PipelineHandler(pipeline pipelines.IPipeline, storageProvider storage.IStorageProvider, w http.ResponseWriter, r *http.Request) { func PipelineHandler(pipeline pipelines.IPipeline, storageProvider storage.IStorageProvider, w http.ResponseWriter, r *http.Request) {
@ -30,7 +33,7 @@ func PipelineHandler(pipeline pipelines.IPipeline, storageProvider storage.IStor
func IndexHandler(w http.ResponseWriter, r *http.Request) { func IndexHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(Metadata{Name, Version})
err := json.NewEncoder(w).Encode(Metadata{Name, Version, GitCommit})
if err != nil { if err != nil {
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
} }

Loading…
Cancel
Save