jobsite: go-staticcheck appeasement

Log and errors should not end with punctuation.
This commit is contained in:
Simon de Vlieger 2024-02-12 10:22:48 +01:00 committed by Sanne Raymaekers
parent 7b7de50e23
commit 3cf2531ae2
2 changed files with 46 additions and 46 deletions

View file

@ -123,7 +123,7 @@ func (builder *Builder) GetState() State {
func (builder *Builder) GuardState(stateWanted State) {
if stateCurrent := builder.GetState(); stateWanted != stateCurrent {
logrus.Fatalf("Builder.GuardState: Requested guard for %d but we're in %d. Exit.", stateWanted, stateCurrent)
logrus.Fatalf("Builder.GuardState: Requested guard for %d but we're in %d. Exit", stateWanted, stateCurrent)
}
}
@ -146,7 +146,7 @@ func (builder *Builder) HandleClaim(w http.ResponseWriter, r *http.Request) erro
fmt.Fprintf(w, "%s", "done")
logrus.Info("Builder.HandleClaim: Done.")
logrus.Info("Builder.HandleClaim: Done")
builder.SetState(StateProvision)
@ -157,10 +157,10 @@ func (builder *Builder) HandleProvision(w http.ResponseWriter, r *http.Request)
builder.GuardState(StateProvision)
if r.Method != "PUT" {
return fmt.Errorf("Builder.HandleProvision: Unexpected request method.")
return fmt.Errorf("Builder.HandleProvision: Unexpected request method")
}
logrus.WithFields(logrus.Fields{"argBuildPath": argBuildPath}).Debug("Builder.HandleProvision: Opening manifest.json.")
logrus.WithFields(logrus.Fields{"argBuildPath": argBuildPath}).Debug("Builder.HandleProvision: Opening manifest.json")
dst, err := os.OpenFile(
path.Join(argBuildPath, "manifest.json"),
@ -175,24 +175,24 @@ func (builder *Builder) HandleProvision(w http.ResponseWriter, r *http.Request)
}()
if err != nil {
return fmt.Errorf("Builder.HandleProvision: Failed to open manifest.json.")
return fmt.Errorf("Builder.HandleProvision: Failed to open manifest.json")
}
logrus.Debug("Builder.HandleProvision: Writing manifest.json.")
logrus.Debug("Builder.HandleProvision: Writing manifest.json")
_, err = io.Copy(dst, r.Body)
if err != nil {
return fmt.Errorf("Builder.HandleProvision: Failed to write manifest.json.")
return fmt.Errorf("Builder.HandleProvision: Failed to write manifest.json")
}
w.WriteHeader(http.StatusCreated)
if _, err := w.Write([]byte(`done`)); err != nil {
return fmt.Errorf("Builder.HandleProvision: Failed to write response.")
return fmt.Errorf("Builder.HandleProvision: Failed to write response")
}
logrus.Info("Builder.HandleProvision: Done.")
logrus.Info("Builder.HandleProvision: Done")
builder.SetState(StatePopulate)
@ -209,10 +209,10 @@ func (builder *Builder) HandlePopulate(w http.ResponseWriter, r *http.Request) e
w.WriteHeader(http.StatusOK)
if _, err := w.Write([]byte(`done`)); err != nil {
return fmt.Errorf("Builder.HandlePopulate: Failed to write response.")
return fmt.Errorf("Builder.HandlePopulate: Failed to write response")
}
logrus.Info("Builder.HandlePopulate: Done.")
logrus.Info("Builder.HandlePopulate: Done")
builder.SetState(StateBuild)
@ -223,7 +223,7 @@ func (builder *Builder) HandleBuild(w http.ResponseWriter, r *http.Request) erro
builder.GuardState(StateBuild)
if r.Method != "POST" {
return fmt.Errorf("Builder.HandleBuild: Unexpected request method.")
return fmt.Errorf("Builder.HandleBuild: Unexpected request method")
}
var buildRequest BuildRequest
@ -231,11 +231,11 @@ func (builder *Builder) HandleBuild(w http.ResponseWriter, r *http.Request) erro
var err error
if err = json.NewDecoder(r.Body).Decode(&buildRequest); err != nil {
return fmt.Errorf("HandleBuild: Failed to decode body.")
return fmt.Errorf("HandleBuild: Failed to decode body")
}
if Build != nil {
logrus.Fatal("HandleBuild: Build started but Build was non-nil.")
logrus.Fatal("HandleBuild: Build started but Build was non-nil")
}
args := []string{
@ -277,14 +277,14 @@ func (builder *Builder) HandleBuild(w http.ResponseWriter, r *http.Request) erro
}
if err := Build.Process.Start(); err != nil {
return fmt.Errorf("BackgroundProcess: Failed to start process.")
return fmt.Errorf("BackgroundProcess: Failed to start process")
}
go func() {
Build.Error = Build.Process.Wait()
Build.Done = true
logrus.Info("BackgroundProcess: Exited.")
logrus.Info("BackgroundProcess: Exited")
}()
go func() {
@ -314,11 +314,11 @@ func (builder *Builder) HandleProgress(w http.ResponseWriter, r *http.Request) e
builder.GuardState(StateProgress)
if r.Method != "GET" {
return fmt.Errorf("Builder.HandleProgress: Unexpected request method.")
return fmt.Errorf("Builder.HandleProgress: Unexpected request method")
}
if Build == nil {
return fmt.Errorf("HandleProgress: Progress requested but Build was nil.")
return fmt.Errorf("HandleProgress: Progress requested but Build was nil")
}
if Build.Done {
@ -334,10 +334,10 @@ func (builder *Builder) HandleProgress(w http.ResponseWriter, r *http.Request) e
}
if _, err := w.Write([]byte(`done`)); err != nil {
return fmt.Errorf("Builder.HandleBuild: Failed to write response.")
return fmt.Errorf("Builder.HandleBuild: Failed to write response")
}
logrus.Info("Builder.HandleBuild: Done.")
logrus.Info("Builder.HandleBuild: Done")
return nil
}
@ -352,7 +352,7 @@ func (builder *Builder) HandleExport(w http.ResponseWriter, r *http.Request) err
exportPath := r.URL.Query().Get("path")
if exportPath == "" {
return fmt.Errorf("Builder.HandleExport: Missing export.")
return fmt.Errorf("Builder.HandleExport: Missing export")
}
// XXX check subdir
@ -363,16 +363,16 @@ func (builder *Builder) HandleExport(w http.ResponseWriter, r *http.Request) err
)
if err != nil {
return fmt.Errorf("Builder.HandleExport: Failed to open source: %s.", err)
return fmt.Errorf("Builder.HandleExport: Failed to open source: %s", err)
}
_, err = io.Copy(w, src)
if err != nil {
return fmt.Errorf("Builder.HandleExport: Failed to write response: %s.", err)
return fmt.Errorf("Builder.HandleExport: Failed to write response: %s", err)
}
logrus.Info("Builder.HandleExport: Done.")
logrus.Info("Builder.HandleExport: Done")
builder.SetState(StateDone)
@ -413,7 +413,7 @@ func main() {
"argTimeoutProvision": argTimeoutProvision,
"argTimeoutBuild": argTimeoutBuild,
"argTimeoutExport": argTimeoutExport,
}).Info("main: Starting up.")
}).Info("main: Starting up")
builder := Builder{
State: StateClaim,
@ -434,7 +434,7 @@ func main() {
select {
case state := <-builder.StateChannel:
if state == StateDone {
logrus.Info("main: Shutting down successfully.")
logrus.Info("main: Shutting down successfully")
os.Exit(ExitOk)
}
case err := <-errs:

View file

@ -97,7 +97,7 @@ func init() {
}
func main() {
logrus.Info("main: Starting up.")
logrus.Info("main: Starting up")
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
@ -113,16 +113,16 @@ func main() {
logrus.WithFields(
logrus.Fields{
"signal": sig,
}).Info("main: Exiting on signal.")
}).Info("main: Exiting on signal")
os.Exit(ExitSignal)
case err := <-errs:
logrus.WithFields(
logrus.Fields{
"error": err,
}).Info("main: Exiting on error.")
}).Info("main: Exiting on error")
os.Exit(ExitError)
case <-done:
logrus.Info("main: Shutting down succesfully.")
logrus.Info("main: Shutting down succesfully")
os.Exit(ExitOk)
}
}
@ -179,7 +179,7 @@ func Request(method string, path string, body []byte) (*http.Response, error) {
return nil, err
}
logrus.Debugf("Request: Making a %s request to %s.", method, url)
logrus.Debugf("Request: Making a %s request to %s", method, url)
for {
res, err := cli.Do(req)
@ -225,11 +225,11 @@ func StepClaim() error {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
errs <- fmt.Errorf("StepClaim: Got an unexpected response %d while expecting %d. Exiting.", res.StatusCode, http.StatusOK)
errs <- fmt.Errorf("StepClaim: Got an unexpected response %d while expecting %d. Exiting", res.StatusCode, http.StatusOK)
return
}
logrus.Info("StepClaim: Done.")
logrus.Info("StepClaim: Done")
close(done)
})
@ -247,11 +247,11 @@ func StepProvision(manifest []byte) error {
defer res.Body.Close()
if res.StatusCode != http.StatusCreated {
errs <- fmt.Errorf("StepProvision: Got an unexpected response %d while expecting %d. Exiting.", res.StatusCode, http.StatusCreated)
errs <- fmt.Errorf("StepProvision: Got an unexpected response %d while expecting %d. Exiting", res.StatusCode, http.StatusCreated)
return
}
logrus.Info("StepProvision: Done.")
logrus.Info("StepProvision: Done")
close(done)
})
@ -269,11 +269,11 @@ func StepPopulate() error {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
errs <- fmt.Errorf("StepPopulate: Got an unexpected response %d while expecting %d. Exiting.", res.StatusCode, http.StatusOK)
errs <- fmt.Errorf("StepPopulate: Got an unexpected response %d while expecting %d. Exiting", res.StatusCode, http.StatusOK)
return
}
logrus.Info("StepPopulate: Done.")
logrus.Info("StepPopulate: Done")
close(done)
})
@ -302,11 +302,11 @@ func StepBuild() error {
defer res.Body.Close()
if res.StatusCode != http.StatusCreated {
errs <- fmt.Errorf("StepBuild: Got an unexpected response %d while expecting %d. Exiting.", res.StatusCode, http.StatusOK)
errs <- fmt.Errorf("StepBuild: Got an unexpected response %d while expecting %d. Exiting", res.StatusCode, http.StatusOK)
return
}
logrus.Info("StepBuild: Done.")
logrus.Info("StepBuild: Done")
close(done)
})
@ -325,20 +325,20 @@ func StepProgress() error {
defer res.Body.Close()
if res.StatusCode == http.StatusAccepted {
logrus.Info("StepProgress: Build is pending. Retry.")
logrus.Info("StepProgress: Build is pending. Retry")
time.Sleep(5 * time.Second)
continue
}
if res.StatusCode != http.StatusOK {
errs <- fmt.Errorf("StepProgress: Got an unexpected response %d while expecting %d. Exiting.", res.StatusCode, http.StatusOK)
errs <- fmt.Errorf("StepProgress: Got an unexpected response %d while expecting %d. Exiting", res.StatusCode, http.StatusOK)
return
}
break
}
logrus.Info("StepProgress: Done.")
logrus.Info("StepProgress: Done")
close(done)
})
@ -357,7 +357,7 @@ func StepExport() error {
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
errs <- fmt.Errorf("StepExport: Got an unexpected response %d while expecting %d. Exiting.", res.StatusCode, http.StatusOK)
errs <- fmt.Errorf("StepExport: Got an unexpected response %d while expecting %d. Exiting", res.StatusCode, http.StatusOK)
return
}
@ -368,19 +368,19 @@ func StepExport() error {
)
if err != nil {
errs <- fmt.Errorf("StepExport: Failed to open destination response: %s.", err)
errs <- fmt.Errorf("StepExport: Failed to open destination response: %s", err)
return
}
_, err = io.Copy(dst, res.Body)
if err != nil {
errs <- fmt.Errorf("StepExport: Failed to copy response: %s.", err)
errs <- fmt.Errorf("StepExport: Failed to copy response: %s", err)
return
}
}
logrus.Info("StepExport: Done.")
logrus.Info("StepExport: Done")
close(done)
})