Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
f2b7fbc3
Unverified
Commit
f2b7fbc3
authored
Dec 03, 2020
by
Arve Knudsen
Committed by
GitHub
Dec 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chore: Check errors from Close calls (#29562)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent
3c9310e9
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
109 additions
and
33 deletions
+109
-33
pkg/api/dashboard.go
+6
-3
pkg/cmd/grafana-server/main.go
+5
-1
pkg/components/imguploader/azureblobuploader.go
+5
-1
pkg/components/imguploader/gcs/gcsuploader.go
+5
-1
pkg/components/imguploader/s3uploader.go
+6
-1
pkg/infra/log/log.go
+4
-0
pkg/plugins/dashboards.go
+5
-2
pkg/plugins/manifest.go
+5
-1
pkg/plugins/plugins.go
+10
-2
pkg/services/alerting/notifiers/discord.go
+15
-4
pkg/services/alerting/notifiers/pushover.go
+5
-1
pkg/services/alerting/notifiers/slack.go
+24
-14
pkg/services/provisioning/dashboards/file_reader.go
+5
-1
pkg/services/rendering/http_mode.go
+9
-1
No files found.
pkg/api/dashboard.go
View file @
f2b7fbc3
...
@@ -15,7 +15,6 @@ import (
...
@@ -15,7 +15,6 @@ import (
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/components/dashdiffs"
"github.com/grafana/grafana/pkg/components/dashdiffs"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/infra/metrics"
"github.com/grafana/grafana/pkg/infra/metrics"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/services/guardian"
"github.com/grafana/grafana/pkg/services/guardian"
...
@@ -334,7 +333,7 @@ func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) Response {
...
@@ -334,7 +333,7 @@ func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) Response {
dashRedirect
:=
dtos
.
DashboardRedirect
{
RedirectUri
:
url
}
dashRedirect
:=
dtos
.
DashboardRedirect
{
RedirectUri
:
url
}
return
JSON
(
200
,
&
dashRedirect
)
return
JSON
(
200
,
&
dashRedirect
)
}
}
log
.
Warnf
(
"Failed to get slug from database, %s"
,
err
.
Error
()
)
hs
.
log
.
Warn
(
"Failed to get slug from database"
,
"err"
,
err
)
}
}
filePath
:=
hs
.
Cfg
.
DefaultHomeDashboardPath
filePath
:=
hs
.
Cfg
.
DefaultHomeDashboardPath
...
@@ -346,7 +345,11 @@ func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) Response {
...
@@ -346,7 +345,11 @@ func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) Response {
if
err
!=
nil
{
if
err
!=
nil
{
return
Error
(
500
,
"Failed to load home dashboard"
,
err
)
return
Error
(
500
,
"Failed to load home dashboard"
,
err
)
}
}
defer
file
.
Close
()
defer
func
()
{
if
err
:=
file
.
Close
();
err
!=
nil
{
hs
.
log
.
Warn
(
"Failed to close dashboard file"
,
"path"
,
filePath
,
"err"
,
err
)
}
}()
dash
:=
dtos
.
DashboardFullWithMeta
{}
dash
:=
dtos
.
DashboardFullWithMeta
{}
dash
.
Meta
.
IsHome
=
true
dash
.
Meta
.
IsHome
=
true
...
...
pkg/cmd/grafana-server/main.go
View file @
f2b7fbc3
...
@@ -116,7 +116,11 @@ func executeServer(configFile, homePath, pidFile, packaging string, traceDiagnos
...
@@ -116,7 +116,11 @@ func executeServer(configFile, homePath, pidFile, packaging string, traceDiagnos
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
defer
f
.
Close
()
defer
func
()
{
if
err
:=
f
.
Close
();
err
!=
nil
{
log
.
Error
(
"Failed to write trace diagnostics"
,
"path"
,
traceDiagnostics
.
file
,
"err"
,
err
)
}
}()
if
err
:=
trace
.
Start
(
f
);
err
!=
nil
{
if
err
:=
trace
.
Start
(
f
);
err
!=
nil
{
panic
(
err
)
panic
(
err
)
...
...
pkg/components/imguploader/azureblobuploader.go
View file @
f2b7fbc3
...
@@ -49,7 +49,11 @@ func (az *AzureBlobUploader) Upload(ctx context.Context, imageDiskPath string) (
...
@@ -49,7 +49,11 @@ func (az *AzureBlobUploader) Upload(ctx context.Context, imageDiskPath string) (
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
defer
file
.
Close
()
defer
func
()
{
if
err
:=
file
.
Close
();
err
!=
nil
{
az
.
log
.
Warn
(
"Failed to close file"
,
"path"
,
imageDiskPath
,
"err"
,
err
)
}
}()
randomFileName
,
err
:=
util
.
GetRandomString
(
30
)
randomFileName
,
err
:=
util
.
GetRandomString
(
30
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/components/imguploader/gcs/gcsuploader.go
View file @
f2b7fbc3
...
@@ -153,7 +153,11 @@ func (u *Uploader) uploadFile(
...
@@ -153,7 +153,11 @@ func (u *Uploader) uploadFile(
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
defer
fileReader
.
Close
()
defer
func
()
{
if
err
:=
fileReader
.
Close
();
err
!=
nil
{
u
.
log
.
Warn
(
"Failed to close file"
,
"err"
,
err
,
"path"
,
imageDiskPath
)
}
}()
// Set public access if not generating a signed URL
// Set public access if not generating a signed URL
pubAcc
:=
!
u
.
enableSignedURLs
pubAcc
:=
!
u
.
enableSignedURLs
...
...
pkg/components/imguploader/s3uploader.go
View file @
f2b7fbc3
...
@@ -80,12 +80,17 @@ func (u *S3Uploader) Upload(ctx context.Context, imageDiskPath string) (string,
...
@@ -80,12 +80,17 @@ func (u *S3Uploader) Upload(ctx context.Context, imageDiskPath string) (string,
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
defer
file
.
Close
()
defer
func
()
{
if
err
:=
file
.
Close
();
err
!=
nil
{
u
.
log
.
Warn
(
"Failed to close file"
,
"path"
,
imageDiskPath
,
"err"
,
err
)
}
}()
sess
,
err
=
session
.
NewSession
(
cfg
)
sess
,
err
=
session
.
NewSession
(
cfg
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
uploader
:=
s3manager
.
NewUploader
(
sess
)
uploader
:=
s3manager
.
NewUploader
(
sess
)
result
,
err
:=
uploader
.
UploadWithContext
(
ctx
,
&
s3manager
.
UploadInput
{
result
,
err
:=
uploader
.
UploadWithContext
(
ctx
,
&
s3manager
.
UploadInput
{
Bucket
:
aws
.
String
(
u
.
bucket
),
Bucket
:
aws
.
String
(
u
.
bucket
),
...
...
pkg/infra/log/log.go
View file @
f2b7fbc3
...
@@ -80,6 +80,10 @@ func Warnf(format string, v ...interface{}) {
...
@@ -80,6 +80,10 @@ func Warnf(format string, v ...interface{}) {
Root
.
Warn
(
message
)
Root
.
Warn
(
message
)
}
}
func
Error
(
msg
string
,
args
...
interface
{})
{
Root
.
Error
(
msg
,
args
...
)
}
func
Errorf
(
skip
int
,
format
string
,
v
...
interface
{})
{
func
Errorf
(
skip
int
,
format
string
,
v
...
interface
{})
{
Root
.
Error
(
fmt
.
Sprintf
(
format
,
v
...
))
Root
.
Error
(
fmt
.
Sprintf
(
format
,
v
...
))
}
}
...
...
pkg/plugins/dashboards.go
View file @
f2b7fbc3
...
@@ -91,7 +91,6 @@ func GetPluginDashboards(orgId int64, pluginId string) ([]*PluginDashboardInfoDT
...
@@ -91,7 +91,6 @@ func GetPluginDashboards(orgId int64, pluginId string) ([]*PluginDashboardInfoDT
func
loadPluginDashboard
(
pluginId
,
path
string
)
(
*
models
.
Dashboard
,
error
)
{
func
loadPluginDashboard
(
pluginId
,
path
string
)
(
*
models
.
Dashboard
,
error
)
{
plugin
,
exists
:=
Plugins
[
pluginId
]
plugin
,
exists
:=
Plugins
[
pluginId
]
if
!
exists
{
if
!
exists
{
return
nil
,
PluginNotFoundError
{
pluginId
}
return
nil
,
PluginNotFoundError
{
pluginId
}
}
}
...
@@ -102,7 +101,11 @@ func loadPluginDashboard(pluginId, path string) (*models.Dashboard, error) {
...
@@ -102,7 +101,11 @@ func loadPluginDashboard(pluginId, path string) (*models.Dashboard, error) {
return
nil
,
err
return
nil
,
err
}
}
defer
reader
.
Close
()
defer
func
()
{
if
err
:=
reader
.
Close
();
err
!=
nil
{
plog
.
Warn
(
"Failed to close file"
,
"path"
,
dashboardFilePath
,
"err"
,
err
)
}
}()
data
,
err
:=
simplejson
.
NewFromReader
(
reader
)
data
,
err
:=
simplejson
.
NewFromReader
(
reader
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/plugins/manifest.go
View file @
f2b7fbc3
...
@@ -113,7 +113,11 @@ func getPluginSignatureState(log log.Logger, plugin *PluginBase) PluginSignature
...
@@ -113,7 +113,11 @@ func getPluginSignatureState(log log.Logger, plugin *PluginBase) PluginSignature
if
err
!=
nil
{
if
err
!=
nil
{
return
PluginSignatureModified
return
PluginSignatureModified
}
}
defer
f
.
Close
()
defer
func
()
{
if
err
:=
f
.
Close
();
err
!=
nil
{
log
.
Warn
(
"Failed to close plugin file"
,
"path"
,
fp
,
"err"
,
err
)
}
}()
h
:=
sha256
.
New
()
h
:=
sha256
.
New
()
if
_
,
err
:=
io
.
Copy
(
h
,
f
);
err
!=
nil
{
if
_
,
err
:=
io
.
Copy
(
h
,
f
);
err
!=
nil
{
...
...
pkg/plugins/plugins.go
View file @
f2b7fbc3
...
@@ -273,7 +273,11 @@ func (pm *PluginManager) scan(pluginDir string, requireSigned bool) error {
...
@@ -273,7 +273,11 @@ func (pm *PluginManager) scan(pluginDir string, requireSigned bool) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
defer
reader
.
Close
()
defer
func
()
{
if
err
:=
reader
.
Close
();
err
!=
nil
{
scanner
.
log
.
Warn
(
"Failed to close JSON file"
,
"path"
,
jsonFPath
,
"err"
,
err
)
}
}()
jsonParser
:=
json
.
NewDecoder
(
reader
)
jsonParser
:=
json
.
NewDecoder
(
reader
)
...
@@ -343,7 +347,11 @@ func (s *PluginScanner) loadPlugin(pluginJSONFilePath string) error {
...
@@ -343,7 +347,11 @@ func (s *PluginScanner) loadPlugin(pluginJSONFilePath string) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
defer
reader
.
Close
()
defer
func
()
{
if
err
:=
reader
.
Close
();
err
!=
nil
{
s
.
log
.
Warn
(
"Failed to close JSON file"
,
"path"
,
pluginJSONFilePath
,
"err"
,
err
)
}
}()
jsonParser
:=
json
.
NewDecoder
(
reader
)
jsonParser
:=
json
.
NewDecoder
(
reader
)
pluginCommon
:=
PluginBase
{}
pluginCommon
:=
PluginBase
{}
...
...
pkg/services/alerting/notifiers/discord.go
View file @
f2b7fbc3
...
@@ -2,6 +2,7 @@ package notifiers
...
@@ -2,6 +2,7 @@ package notifiers
import
(
import
(
"bytes"
"bytes"
"fmt"
"io"
"io"
"mime/multipart"
"mime/multipart"
"os"
"os"
...
@@ -168,12 +169,20 @@ func (dn *DiscordNotifier) embedImage(cmd *models.SendWebhookSync, imagePath str
...
@@ -168,12 +169,20 @@ func (dn *DiscordNotifier) embedImage(cmd *models.SendWebhookSync, imagePath str
return
err
return
err
}
}
}
}
defer
func
()
{
defer
f
.
Close
()
if
err
:=
f
.
Close
();
err
!=
nil
{
dn
.
log
.
Warn
(
"Failed to close file"
,
"path"
,
imagePath
,
"err"
,
err
)
}
}()
var
b
bytes
.
Buffer
var
b
bytes
.
Buffer
w
:=
multipart
.
NewWriter
(
&
b
)
w
:=
multipart
.
NewWriter
(
&
b
)
defer
func
()
{
if
err
:=
w
.
Close
();
err
!=
nil
{
// Should be OK since we already close it on non-error path
dn
.
log
.
Warn
(
"Failed to close multipart writer"
,
"err"
,
err
)
}
}()
fw
,
err
:=
w
.
CreateFormField
(
"payload_json"
)
fw
,
err
:=
w
.
CreateFormField
(
"payload_json"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -192,7 +201,9 @@ func (dn *DiscordNotifier) embedImage(cmd *models.SendWebhookSync, imagePath str
...
@@ -192,7 +201,9 @@ func (dn *DiscordNotifier) embedImage(cmd *models.SendWebhookSync, imagePath str
return
err
return
err
}
}
w
.
Close
()
if
err
:=
w
.
Close
();
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to close multipart writer: %w"
,
err
)
}
cmd
.
Body
=
b
.
String
()
cmd
.
Body
=
b
.
String
()
cmd
.
ContentType
=
w
.
FormDataContentType
()
cmd
.
ContentType
=
w
.
FormDataContentType
()
...
...
pkg/services/alerting/notifiers/pushover.go
View file @
f2b7fbc3
...
@@ -292,7 +292,11 @@ func (pn *PushoverNotifier) genPushoverBody(evalContext *alerting.EvalContext, m
...
@@ -292,7 +292,11 @@ func (pn *PushoverNotifier) genPushoverBody(evalContext *alerting.EvalContext, m
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
b
,
err
return
nil
,
b
,
err
}
}
defer
f
.
Close
()
defer
func
()
{
if
err
:=
f
.
Close
();
err
!=
nil
{
pn
.
log
.
Warn
(
"Failed to close file"
,
"path"
,
evalContext
.
ImageOnDiskPath
,
"err"
,
err
)
}
}()
fw
,
err
:=
w
.
CreateFormFile
(
"attachment"
,
evalContext
.
ImageOnDiskPath
)
fw
,
err
:=
w
.
CreateFormFile
(
"attachment"
,
evalContext
.
ImageOnDiskPath
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/services/alerting/notifiers/slack.go
View file @
f2b7fbc3
...
@@ -321,7 +321,7 @@ func (sn *SlackNotifier) Notify(evalContext *alerting.EvalContext) error {
...
@@ -321,7 +321,7 @@ func (sn *SlackNotifier) Notify(evalContext *alerting.EvalContext) error {
return
err
return
err
}
}
if
sn
.
Token
!=
""
&&
sn
.
UploadImage
{
if
sn
.
Token
!=
""
&&
sn
.
UploadImage
{
err
=
slackFileUpload
(
evalContext
,
sn
.
log
,
"https://slack.com/api/files.upload"
,
sn
.
Recipient
,
sn
.
Token
)
err
=
s
n
.
s
lackFileUpload
(
evalContext
,
sn
.
log
,
"https://slack.com/api/files.upload"
,
sn
.
Recipient
,
sn
.
Token
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -329,12 +329,12 @@ func (sn *SlackNotifier) Notify(evalContext *alerting.EvalContext) error {
...
@@ -329,12 +329,12 @@ func (sn *SlackNotifier) Notify(evalContext *alerting.EvalContext) error {
return
nil
return
nil
}
}
func
slackFileUpload
(
evalContext
*
alerting
.
EvalContext
,
log
log
.
Logger
,
url
string
,
recipient
string
,
token
string
)
error
{
func
(
sn
*
SlackNotifier
)
slackFileUpload
(
evalContext
*
alerting
.
EvalContext
,
log
log
.
Logger
,
url
string
,
recipient
string
,
token
string
)
error
{
if
evalContext
.
ImageOnDiskPath
==
""
{
if
evalContext
.
ImageOnDiskPath
==
""
{
evalContext
.
ImageOnDiskPath
=
filepath
.
Join
(
setting
.
HomePath
,
"public/img/mixed_styles.png"
)
evalContext
.
ImageOnDiskPath
=
filepath
.
Join
(
setting
.
HomePath
,
"public/img/mixed_styles.png"
)
}
}
log
.
Info
(
"Uploading to slack via file.upload API"
)
log
.
Info
(
"Uploading to slack via file.upload API"
)
headers
,
uploadBody
,
err
:=
generateSlackBody
(
evalContext
.
ImageOnDiskPath
,
token
,
recipient
)
headers
,
uploadBody
,
err
:=
sn
.
generateSlackBody
(
evalContext
.
ImageOnDiskPath
,
token
,
recipient
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -346,37 +346,47 @@ func slackFileUpload(evalContext *alerting.EvalContext, log log.Logger, url stri
...
@@ -346,37 +346,47 @@ func slackFileUpload(evalContext *alerting.EvalContext, log log.Logger, url stri
return
nil
return
nil
}
}
func
generateSlackBody
(
file
string
,
token
string
,
recipient
string
)
(
map
[
string
]
string
,
bytes
.
Buffer
,
error
)
{
func
(
sn
*
SlackNotifier
)
generateSlackBody
(
path
string
,
token
string
,
recipient
string
)
(
map
[
string
]
string
,
bytes
.
Buffer
,
error
)
{
// Slack requires all POSTs to files.upload to present
// Slack requires all POSTs to files.upload to present
// an "application/x-www-form-urlencoded" encoded querystring
// an "application/x-www-form-urlencoded" encoded querystring
// See https://api.slack.com/methods/files.upload
// See https://api.slack.com/methods/files.upload
var
b
bytes
.
Buffer
var
b
bytes
.
Buffer
w
:=
multipart
.
NewWriter
(
&
b
)
w
:=
multipart
.
NewWriter
(
&
b
)
defer
func
()
{
if
err
:=
w
.
Close
();
err
!=
nil
{
// Shouldn't matter since we already close w explicitly on the non-error path
sn
.
log
.
Warn
(
"Failed to close multipart writer"
,
"err"
,
err
)
}
}()
// Add the generated image file
// Add the generated image file
f
,
err
:=
os
.
Open
(
file
)
f
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
b
,
err
return
nil
,
b
,
err
}
}
defer
f
.
Close
()
defer
func
()
{
fw
,
err
:=
w
.
CreateFormFile
(
"file"
,
file
)
if
err
:=
f
.
Close
();
err
!=
nil
{
sn
.
log
.
Warn
(
"Failed to close file"
,
"path"
,
path
,
"err"
,
err
)
}
}()
fw
,
err
:=
w
.
CreateFormFile
(
"file"
,
path
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
b
,
err
return
nil
,
b
,
err
}
}
_
,
err
=
io
.
Copy
(
fw
,
f
)
if
_
,
err
:=
io
.
Copy
(
fw
,
f
);
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
b
,
err
return
nil
,
b
,
err
}
}
// Add the authorization token
// Add the authorization token
err
=
w
.
WriteField
(
"token"
,
token
)
if
err
:=
w
.
WriteField
(
"token"
,
token
);
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
b
,
err
return
nil
,
b
,
err
}
}
// Add the channel(s) to POST to
// Add the channel(s) to POST to
err
=
w
.
WriteField
(
"channels"
,
recipient
)
if
err
:=
w
.
WriteField
(
"channels"
,
recipient
);
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
b
,
err
return
nil
,
b
,
err
}
}
w
.
Close
()
if
err
:=
w
.
Close
();
err
!=
nil
{
return
nil
,
b
,
fmt
.
Errorf
(
"failed to close multipart writer: %w"
,
err
)
}
headers
:=
map
[
string
]
string
{
headers
:=
map
[
string
]
string
{
"Content-Type"
:
w
.
FormDataContentType
(),
"Content-Type"
:
w
.
FormDataContentType
(),
"Authorization"
:
"auth_token=
\"
"
+
token
+
"
\"
"
,
"Authorization"
:
"auth_token=
\"
"
+
token
+
"
\"
"
,
...
...
pkg/services/provisioning/dashboards/file_reader.go
View file @
f2b7fbc3
...
@@ -347,7 +347,11 @@ func (fr *FileReader) readDashboardFromFile(path string, lastModified time.Time,
...
@@ -347,7 +347,11 @@ func (fr *FileReader) readDashboardFromFile(path string, lastModified time.Time,
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
defer
reader
.
Close
()
defer
func
()
{
if
err
:=
reader
.
Close
();
err
!=
nil
{
fr
.
log
.
Warn
(
"Failed to close file"
,
"path"
,
path
,
"err"
,
err
)
}
}()
all
,
err
:=
ioutil
.
ReadAll
(
reader
)
all
,
err
:=
ioutil
.
ReadAll
(
reader
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/services/rendering/http_mode.go
View file @
f2b7fbc3
...
@@ -96,7 +96,12 @@ func (rs *RenderingService) renderViaHttp(ctx context.Context, renderKey string,
...
@@ -96,7 +96,12 @@ func (rs *RenderingService) renderViaHttp(ctx context.Context, renderKey string,
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
defer
out
.
Close
()
defer
func
()
{
if
err
:=
out
.
Close
();
err
!=
nil
{
// We already close the file explicitly in the non-error path, so shouldn't be a problem
rs
.
log
.
Warn
(
"Failed to close file"
,
"path"
,
filePath
,
"err"
,
err
)
}
}()
_
,
err
=
io
.
Copy
(
out
,
resp
.
Body
)
_
,
err
=
io
.
Copy
(
out
,
resp
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
// check that we didn't timeout while receiving the response.
// check that we didn't timeout while receiving the response.
...
@@ -107,6 +112,9 @@ func (rs *RenderingService) renderViaHttp(ctx context.Context, renderKey string,
...
@@ -107,6 +112,9 @@ func (rs *RenderingService) renderViaHttp(ctx context.Context, renderKey string,
rs
.
log
.
Error
(
"Remote rendering request failed"
,
"error"
,
err
)
rs
.
log
.
Error
(
"Remote rendering request failed"
,
"error"
,
err
)
return
nil
,
fmt
.
Errorf
(
"remote rendering request failed: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"remote rendering request failed: %w"
,
err
)
}
}
if
err
:=
out
.
Close
();
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to write to %q: %w"
,
filePath
,
err
)
}
return
&
RenderResult
{
FilePath
:
filePath
},
err
return
&
RenderResult
{
FilePath
:
filePath
},
err
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment