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
b5ca2381
Unverified
Commit
b5ca2381
authored
Jul 01, 2020
by
Dan Cech
Committed by
GitHub
Jul 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provide license token directly via plugin environment (#25987)
* provide license token directly via plugin environment
parent
bbdcd59c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
3 deletions
+19
-3
pkg/models/licensing.go
+2
-0
pkg/plugins/backendplugin/manager.go
+5
-1
pkg/plugins/backendplugin/manager_test.go
+8
-2
pkg/services/licensing/oss.go
+4
-0
No files found.
pkg/models/licensing.go
View file @
b5ca2381
...
@@ -16,4 +16,6 @@ type Licensing interface {
...
@@ -16,4 +16,6 @@ type Licensing interface {
LicenseURL
(
user
*
SignedInUser
)
string
LicenseURL
(
user
*
SignedInUser
)
string
StateInfo
()
string
StateInfo
()
string
TokenRaw
()
string
}
}
pkg/plugins/backendplugin/manager.go
View file @
b5ca2381
...
@@ -100,7 +100,11 @@ func (m *manager) Register(pluginID string, factory PluginFactoryFunc) error {
...
@@ -100,7 +100,11 @@ func (m *manager) Register(pluginID string, factory PluginFactoryFunc) error {
}
}
if
m
.
License
.
HasLicense
()
{
if
m
.
License
.
HasLicense
()
{
hostEnv
=
append
(
hostEnv
,
fmt
.
Sprintf
(
"GF_ENTERPRISE_LICENSE_PATH=%s"
,
m
.
Cfg
.
EnterpriseLicensePath
))
hostEnv
=
append
(
hostEnv
,
fmt
.
Sprintf
(
"GF_ENTERPRISE_LICENSE_PATH=%s"
,
m
.
Cfg
.
EnterpriseLicensePath
),
fmt
.
Sprintf
(
"GF_ENTERPRISE_LICENSE_TEXT=%s"
,
m
.
License
.
TokenRaw
()),
)
}
}
env
:=
pluginSettings
.
ToEnv
(
"GF_PLUGIN"
,
hostEnv
)
env
:=
pluginSettings
.
ToEnv
(
"GF_PLUGIN"
,
hostEnv
)
...
...
pkg/plugins/backendplugin/manager_test.go
View file @
b5ca2381
...
@@ -251,6 +251,7 @@ func TestManager(t *testing.T) {
...
@@ -251,6 +251,7 @@ func TestManager(t *testing.T) {
t
.
Run
(
"Plugin registration scenario when Grafana is licensed"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Plugin registration scenario when Grafana is licensed"
,
func
(
t
*
testing
.
T
)
{
ctx
.
license
.
edition
=
"Enterprise"
ctx
.
license
.
edition
=
"Enterprise"
ctx
.
license
.
hasLicense
=
true
ctx
.
license
.
hasLicense
=
true
ctx
.
license
.
tokenRaw
=
"testtoken"
ctx
.
cfg
.
BuildVersion
=
"7.0.0"
ctx
.
cfg
.
BuildVersion
=
"7.0.0"
ctx
.
cfg
.
EnterpriseLicensePath
=
"/license.txt"
ctx
.
cfg
.
EnterpriseLicensePath
=
"/license.txt"
...
@@ -258,8 +259,8 @@ func TestManager(t *testing.T) {
...
@@ -258,8 +259,8 @@ func TestManager(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
t
.
Run
(
"Should provide expected host environment variables"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Should provide expected host environment variables"
,
func
(
t
*
testing
.
T
)
{
require
.
Len
(
t
,
ctx
.
env
,
3
)
require
.
Len
(
t
,
ctx
.
env
,
4
)
require
.
EqualValues
(
t
,
[]
string
{
"GF_VERSION=7.0.0"
,
"GF_EDITION=Enterprise"
,
"GF_ENTERPRISE_LICENSE_PATH=/license.txt"
},
ctx
.
env
)
require
.
EqualValues
(
t
,
[]
string
{
"GF_VERSION=7.0.0"
,
"GF_EDITION=Enterprise"
,
"GF_ENTERPRISE_LICENSE_PATH=/license.txt"
,
"GF_ENTERPRISE_LICENSE_TEXT=testtoken"
},
ctx
.
env
)
})
})
})
})
})
})
...
@@ -383,6 +384,7 @@ func (tp *testPlugin) CallResource(ctx context.Context, req *backend.CallResourc
...
@@ -383,6 +384,7 @@ func (tp *testPlugin) CallResource(ctx context.Context, req *backend.CallResourc
type
testLicensingService
struct
{
type
testLicensingService
struct
{
edition
string
edition
string
hasLicense
bool
hasLicense
bool
tokenRaw
string
}
}
func
(
t
*
testLicensingService
)
HasLicense
()
bool
{
func
(
t
*
testLicensingService
)
HasLicense
()
bool
{
...
@@ -408,3 +410,7 @@ func (t *testLicensingService) LicenseURL(user *models.SignedInUser) string {
...
@@ -408,3 +410,7 @@ func (t *testLicensingService) LicenseURL(user *models.SignedInUser) string {
func
(
t
*
testLicensingService
)
HasValidLicense
()
bool
{
func
(
t
*
testLicensingService
)
HasValidLicense
()
bool
{
return
false
return
false
}
}
func
(
t
*
testLicensingService
)
TokenRaw
()
string
{
return
t
.
tokenRaw
}
pkg/services/licensing/oss.go
View file @
b5ca2381
...
@@ -56,3 +56,7 @@ func (l *OSSLicensingService) Init() error {
...
@@ -56,3 +56,7 @@ func (l *OSSLicensingService) Init() error {
func
(
*
OSSLicensingService
)
HasValidLicense
()
bool
{
func
(
*
OSSLicensingService
)
HasValidLicense
()
bool
{
return
false
return
false
}
}
func
(
*
OSSLicensingService
)
TokenRaw
()
string
{
return
""
}
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