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
79e788e4
Unverified
Commit
79e788e4
authored
Nov 21, 2017
by
Carl Bergquist
Committed by
GitHub
Nov 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9937 from saady/gcs-path
[GCS] Support for gcs path
parents
3a772c7f
767b460f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
3 deletions
+15
-3
conf/defaults.ini
+2
-0
conf/sample.ini
+2
-0
docs/sources/installation/configuration.md
+3
-0
pkg/components/imguploader/gcsuploader.go
+6
-2
pkg/components/imguploader/imguploader.go
+2
-1
No files found.
conf/defaults.ini
View file @
79e788e4
...
...
@@ -495,3 +495,4 @@ public_url =
[external_image_storage.gcs]
key_file
=
bucket
=
path
=
\ No newline at end of file
conf/sample.ini
View file @
79e788e4
...
...
@@ -438,3 +438,4 @@ log_queries =
[external_image_storage.gcs]
;key_file =
;bucket =
;
path
=
\ No newline at end of file
docs/sources/installation/configuration.md
View file @
79e788e4
...
...
@@ -778,6 +778,9 @@ Service Account should have "Storage Object Writer" role.
### bucket name
Bucket Name on Google Cloud Storage.
### path
Optional extra path inside bucket
## [alerting]
### enabled
...
...
pkg/components/imguploader/gcsuploader.go
View file @
79e788e4
...
...
@@ -6,6 +6,7 @@ import (
"io/ioutil"
"net/http"
"os"
"path"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/util"
...
...
@@ -20,19 +21,22 @@ const (
type
GCSUploader
struct
{
keyFile
string
bucket
string
path
string
log
log
.
Logger
}
func
NewGCSUploader
(
keyFile
,
bucket
string
)
*
GCSUploader
{
func
NewGCSUploader
(
keyFile
,
bucket
,
path
string
)
*
GCSUploader
{
return
&
GCSUploader
{
keyFile
:
keyFile
,
bucket
:
bucket
,
path
:
path
,
log
:
log
.
New
(
"gcsuploader"
),
}
}
func
(
u
*
GCSUploader
)
Upload
(
ctx
context
.
Context
,
imageDiskPath
string
)
(
string
,
error
)
{
key
:=
util
.
GetRandomString
(
20
)
+
".png"
fileName
:=
util
.
GetRandomString
(
20
)
+
".png"
key
:=
path
.
Join
(
u
.
path
,
fileName
)
u
.
log
.
Debug
(
"Opening key file "
,
u
.
keyFile
)
data
,
err
:=
ioutil
.
ReadFile
(
u
.
keyFile
)
...
...
pkg/components/imguploader/imguploader.go
View file @
79e788e4
...
...
@@ -73,8 +73,9 @@ func NewImageUploader() (ImageUploader, error) {
keyFile
:=
gcssec
.
Key
(
"key_file"
)
.
MustString
(
""
)
bucketName
:=
gcssec
.
Key
(
"bucket"
)
.
MustString
(
""
)
path
:=
gcssec
.
Key
(
"path"
)
.
MustString
(
""
)
return
NewGCSUploader
(
keyFile
,
bucketName
),
nil
return
NewGCSUploader
(
keyFile
,
bucketName
,
path
),
nil
}
return
NopImageUploader
{},
nil
...
...
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