Skip to content

Commit

Permalink
refactor: use path to join strings, minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
MalinAhlberg committed Sep 10, 2024
1 parent 41bad3e commit 904ee5e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sda/cmd/s3inbox/healthchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"net/http"
"path"

"github.com/neicnordic/sensitive-data-archive/internal/broker"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -52,8 +53,7 @@ func (p *Proxy) CheckHealth(w http.ResponseWriter, _ *http.Request) {
}

// Check that s3 backend responds
s3URL := p.getS3ReadyPath()
err = p.httpsGetCheck(s3URL)
err = p.httpsGetCheck(p.getS3ReadyPath())
if err != nil {
log.Error(err)
w.WriteHeader(http.StatusServiceUnavailable)
Expand All @@ -65,7 +65,6 @@ func (p *Proxy) CheckHealth(w http.ResponseWriter, _ *http.Request) {

// httpsGetCheck sends a request to the S3 backend and makes sure it is healthy
func (p *Proxy) httpsGetCheck(url string) error {

resp, e := p.client.Get(url)
if e != nil {
return e
Expand All @@ -81,10 +80,10 @@ func (p *Proxy) httpsGetCheck(url string) error {
func (p *Proxy) getS3ReadyPath() string {
s3URL := p.s3.URL
if p.s3.Port != 0 {
s3URL = fmt.Sprintf("%s:%d", s3URL, p.s3.Port)
s3URL = path.Join(s3URL, string(p.s3.Port))

Check failure on line 83 in sda/cmd/s3inbox/healthchecks.go

View workflow job for this annotation

GitHub Actions / Lint sda code (1.22)

stringintconv: conversion from int to string yields a string of one rune, not a string of digits (govet)
}
if p.s3.Readypath != "" {
s3URL += p.s3.Readypath
s3URL += path.Join(s3URL, p.s3.Readypath)
}

return s3URL
Expand Down

0 comments on commit 904ee5e

Please sign in to comment.