From 34233a3819a117fd090fbb2fd8472af2eee80b22 Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Tue, 29 Oct 2024 17:11:09 -0600 Subject: [PATCH] Update to use the new Version stuff --- .gitignore | 5 ----- cmd/boot-script-service/main.go | 3 +-- cmd/boot-script-service/serviceAPI.go | 15 ++++----------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 63b7463..a93bf7e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,11 +2,6 @@ kubernetes/.packaged/ .idea/ *.swp - -# Binaries -boot-script-service -bss-init - # Prevent certificates from getting checked in *.ca *.cer diff --git a/cmd/boot-script-service/main.go b/cmd/boot-script-service/main.go index e6c00e8..7b73766 100644 --- a/cmd/boot-script-service/main.go +++ b/cmd/boot-script-service/main.go @@ -48,7 +48,6 @@ import ( "strings" "time" - base "github.com/Cray-HPE/hms-base" hmetcd "github.com/Cray-HPE/hms-hmetcd" "github.com/OpenCHAMI/bss/internal/postgres" ) @@ -449,7 +448,7 @@ func main() { } parseCmdLine() - sn, snerr := base.GetServiceInstanceName() + sn, snerr := os.Hostname() if snerr == nil { serviceName = sn } diff --git a/cmd/boot-script-service/serviceAPI.go b/cmd/boot-script-service/serviceAPI.go index 3c6508c..21be332 100644 --- a/cmd/boot-script-service/serviceAPI.go +++ b/cmd/boot-script-service/serviceAPI.go @@ -25,6 +25,7 @@ package main import ( "encoding/json" "fmt" + "io" "io/ioutil" "log" "math/rand" @@ -53,16 +54,8 @@ func serviceStatusAPI(w http.ResponseWriter, req *http.Request) { } if strings.Contains(strings.ToUpper(req.URL.Path), "VERSION") || strings.Contains(strings.ToUpper(req.URL.Path), "ALL") { - dat, err := ioutil.ReadFile(".version") - if err != nil { - dat, err = ioutil.ReadFile("../../.version") - if err != nil { - httpStatus = http.StatusInternalServerError - dat = []byte("error") - log.Printf("Cannot read version file: %s", err) - } - } - bssStatus.Version = strings.TrimSpace(string(dat)) + + bssStatus.Version = strings.TrimSpace(Version) } if strings.Contains(strings.ToUpper(req.URL.Path), "HSM") || strings.Contains(strings.ToUpper(req.URL.Path), "ALL") { @@ -74,7 +67,7 @@ func serviceStatusAPI(w http.ResponseWriter, req *http.Request) { bssStatus.HSMStatus = "error" log.Printf("Cannot connect to HSM: %s", err) } else { - _, err = ioutil.ReadAll(rsp.Body) + _, err = io.ReadAll(rsp.Body) if err != nil { httpStatus = http.StatusInternalServerError bssStatus.HSMStatus = "error"