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
68332c59
Commit
68332c59
authored
Oct 02, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: fix broken substring. also adds tests
parent
2e665fba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
pkg/tsdb/stackdriver/stackdriver.go
+5
-2
pkg/tsdb/stackdriver/stackdriver_test.go
+13
-0
No files found.
pkg/tsdb/stackdriver/stackdriver.go
View file @
68332c59
...
...
@@ -170,8 +170,11 @@ func reverse(s string) string {
}
func
interpolateFilterWildcards
(
value
string
)
string
{
if
strings
.
HasSuffix
(
value
,
"*"
)
&&
strings
.
HasPrefix
(
value
,
"*"
)
{
value
=
strings
.
Replace
(
value
,
"*"
,
""
,
1
)
re
:=
regexp
.
MustCompile
(
"[*]"
)
matches
:=
re
.
FindAllStringIndex
(
value
,
-
1
)
logger
.
Info
(
"len"
,
"len"
,
len
(
matches
))
if
len
(
matches
)
==
2
&&
strings
.
HasSuffix
(
value
,
"*"
)
&&
strings
.
HasPrefix
(
value
,
"*"
)
{
value
=
strings
.
Replace
(
value
,
"*"
,
""
,
-
1
)
value
=
fmt
.
Sprintf
(
`has_substring("%s")`
,
value
)
}
else
if
strings
.
HasPrefix
(
value
,
"*"
)
{
value
=
strings
.
Replace
(
value
,
"*"
,
""
,
1
)
...
...
pkg/tsdb/stackdriver/stackdriver_test.go
View file @
68332c59
...
...
@@ -342,6 +342,19 @@ func TestStackdriver(t *testing.T) {
})
})
})
Convey
(
"when interpolating filter wildcards"
,
func
()
{
Convey
(
"and wildcard is used in the beginning and the end of the word"
,
func
()
{
Convey
(
"and theres no wildcard in the middle of the word"
,
func
()
{
value
:=
interpolateFilterWildcards
(
"*-central1*"
)
So
(
value
,
ShouldEqual
,
`has_substring("-central1")`
)
})
Convey
(
"and there is a wildcard in the middle of the word"
,
func
()
{
value
:=
interpolateFilterWildcards
(
"*-cent*ral1*"
)
So
(
value
,
ShouldNotStartWith
,
`has_substring`
)
})
})
})
})
}
...
...
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