Skip to content

Commit e6200b9

Browse files
Bump golangci/golangci-lint-action from 6.5.2 to 7.0.0 (#220)
* Bump golangci/golangci-lint-action from 6.5.2 to 7.0.0 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6.5.2 to 7.0.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](golangci/golangci-lint-action@v6.5.2...v7.0.0) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Address new linter issues --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Stefan Agner <stefan@agner.ch>
1 parent 64ed4e2 commit e6200b9

3 files changed

Lines changed: 37 additions & 10 deletions

File tree

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v4.2.2
1313
- name: golangci-lint
14-
uses: golangci/golangci-lint-action@v6.5.2
14+
uses: golangci/golangci-lint-action@v7.0.0
1515
with:
1616
version: latest
1717
args: -D errcheck

http.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func statusIndex(w http.ResponseWriter, r *http.Request) {
8989
// Set logs
9090
if data.SupervisorState != "" || !data.SupervisorConnected {
9191
var buf bytes.Buffer
92-
var re = regexp.MustCompile(`\[\d+m`)
92+
var re = regexp.MustCompile(`\x1b\[\d+m`)
9393
logWriter := bufio.NewWriter(&buf)
9494

9595
err := supervisorLogs(logWriter)
@@ -101,5 +101,10 @@ func statusIndex(w http.ResponseWriter, r *http.Request) {
101101
}
102102

103103
// Render Website
104-
indexTemplate.Execute(w, data)
104+
err := indexTemplate.Execute(w, data)
105+
if err != nil {
106+
log.Printf("failed to render template: %v", err)
107+
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
108+
return
109+
}
105110
}

supervisor.go

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,27 @@ func supervisorApiProxy(path string) (SupervisorResponse, error) {
5151

5252
if response.StatusCode >= 300 && response.StatusCode != 400 {
5353
log.Printf("Supervisor API call failed with status code %v", response.StatusCode)
54-
return jsonResponse, fmt.Errorf("Supervisor API call failed with status code %v", response.StatusCode)
54+
return jsonResponse, fmt.Errorf("call to Supervisor API failed with status code %v", response.StatusCode)
5555
}
5656

5757
bodyBytes, err := io.ReadAll(response.Body)
5858
if err != nil {
5959
return jsonResponse, err
6060
}
61+
defer func() {
62+
if err := response.Body.Close(); err != nil {
63+
log.Printf("error closing response body: %v", err)
64+
}
65+
}()
6166

62-
defer response.Body.Close()
63-
json.Unmarshal([]byte(bodyBytes), &jsonResponse)
67+
err = json.Unmarshal([]byte(bodyBytes), &jsonResponse)
68+
if err != nil {
69+
log.Printf("json unmarshalling failed with error %s", err)
70+
return jsonResponse, err
71+
}
6472

6573
if response.StatusCode == 400 {
66-
return jsonResponse, errors.New("Supervisor API call failed with status code 400")
74+
return jsonResponse, errors.New("call to Supervisor API failed with status code 400")
6775
}
6876

6977
return jsonResponse, err
@@ -95,7 +103,11 @@ func getSupervisorInfo() (SupervisorInfo, error) {
95103
}
96104

97105
jsonData, _ := json.Marshal(response.Data)
98-
json.Unmarshal(jsonData, &supervisorInfo)
106+
err = json.Unmarshal(jsonData, &supervisorInfo)
107+
if err != nil {
108+
log.Printf("json unmarshalling failed with error %s", err)
109+
return supervisorInfo, err
110+
}
99111

100112
return supervisorInfo, nil
101113
}
@@ -109,7 +121,11 @@ func getResolutionInfo() (ResolutionInfo, error) {
109121
}
110122

111123
jsonData, _ := json.Marshal(response.Data)
112-
json.Unmarshal(jsonData, &resolutionInfo)
124+
err = json.Unmarshal(jsonData, &resolutionInfo)
125+
if err != nil {
126+
log.Printf("json unmarshalling failed with error %s", err)
127+
return resolutionInfo, err
128+
}
113129

114130
return resolutionInfo, nil
115131
}
@@ -128,7 +144,13 @@ func supervisorLogs(w io.Writer) error {
128144
log.Printf("Can't get supervisor logs %s", err)
129145
return err
130146
}
131-
defer reader.Close()
147+
defer func() {
148+
if err := reader.Close(); err != nil {
149+
log.Printf("error closing reader: %v", err)
150+
}
151+
}()
152+
153+
132154

133155
// Return the content
134156
_, err = stdcopy.StdCopy(w, w, reader)

0 commit comments

Comments
 (0)