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
c7698a09
Commit
c7698a09
authored
Sep 15, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass context to image uploaders
parent
d0ab028c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
10 deletions
+13
-10
pkg/components/imguploader/gcsuploader.go
+5
-5
pkg/components/imguploader/imguploader.go
+3
-2
pkg/components/imguploader/s3uploader.go
+2
-1
pkg/components/imguploader/webdavuploader.go
+2
-1
pkg/services/alerting/notifier.go
+1
-1
No files found.
pkg/components/imguploader/gcsuploader.go
View file @
c7698a09
...
...
@@ -4,12 +4,13 @@ import (
"context"
"errors"
"fmt"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/util"
"golang.org/x/oauth2/google"
"io/ioutil"
"net/http"
"os"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/util"
"golang.org/x/oauth2/google"
)
type
GCSUploader
struct
{
...
...
@@ -26,12 +27,11 @@ func NewGCSUploader(keyFile, bucket string) *GCSUploader {
}
}
func
(
u
*
GCSUploader
)
Upload
(
imageDiskPath
string
)
(
string
,
error
)
{
func
(
u
*
GCSUploader
)
Upload
(
ctx
context
.
Context
,
imageDiskPath
string
)
(
string
,
error
)
{
key
:=
util
.
GetRandomString
(
20
)
+
".png"
log
.
Debug
(
"Opening key file "
,
u
.
keyFile
)
ctx
:=
context
.
Background
()
data
,
err
:=
ioutil
.
ReadFile
(
u
.
keyFile
)
if
err
!=
nil
{
return
""
,
err
...
...
pkg/components/imguploader/imguploader.go
View file @
c7698a09
package
imguploader
import
(
"context"
"fmt"
"regexp"
...
...
@@ -8,13 +9,13 @@ import (
)
type
ImageUploader
interface
{
Upload
(
path
string
)
(
string
,
error
)
Upload
(
ctx
context
.
Context
,
path
string
)
(
string
,
error
)
}
type
NopImageUploader
struct
{
}
func
(
NopImageUploader
)
Upload
(
path
string
)
(
string
,
error
)
{
func
(
NopImageUploader
)
Upload
(
ctx
context
.
Context
,
path
string
)
(
string
,
error
)
{
return
""
,
nil
}
...
...
pkg/components/imguploader/s3uploader.go
View file @
c7698a09
package
imguploader
import
(
"context"
"os"
"time"
...
...
@@ -34,7 +35,7 @@ func NewS3Uploader(region, bucket, acl, accessKey, secretKey string) *S3Uploader
}
}
func
(
u
*
S3Uploader
)
Upload
(
imageDiskPath
string
)
(
string
,
error
)
{
func
(
u
*
S3Uploader
)
Upload
(
ctx
context
.
Context
,
imageDiskPath
string
)
(
string
,
error
)
{
sess
,
err
:=
session
.
NewSession
()
if
err
!=
nil
{
return
""
,
err
...
...
pkg/components/imguploader/webdavuploader.go
View file @
c7698a09
...
...
@@ -2,6 +2,7 @@ package imguploader
import
(
"bytes"
"context"
"fmt"
"io/ioutil"
"net"
...
...
@@ -33,7 +34,7 @@ var netClient = &http.Client{
Transport
:
netTransport
,
}
func
(
u
*
WebdavUploader
)
Upload
(
pa
string
)
(
string
,
error
)
{
func
(
u
*
WebdavUploader
)
Upload
(
ctx
context
.
Context
,
pa
string
)
(
string
,
error
)
{
url
,
_
:=
url
.
Parse
(
u
.
url
)
filename
:=
util
.
GetRandomString
(
20
)
+
".png"
url
.
Path
=
path
.
Join
(
url
.
Path
,
filename
)
...
...
pkg/services/alerting/notifier.go
View file @
c7698a09
...
...
@@ -100,7 +100,7 @@ func (n *notificationService) uploadImage(context *EvalContext) (err error) {
context
.
ImageOnDiskPath
=
imagePath
}
context
.
ImagePublicUrl
,
err
=
uploader
.
Upload
(
context
.
ImageOnDiskPath
)
context
.
ImagePublicUrl
,
err
=
uploader
.
Upload
(
context
.
Ctx
,
context
.
ImageOnDiskPath
)
if
err
!=
nil
{
return
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