Skip to content

Commit

Permalink
convArtiToPromNumber use case (#150)
Browse files Browse the repository at this point in the history
The regular expression `pattNumber` did not recognise the word `1000GB`.
  • Loading branch information
KacperPerschke authored Nov 7, 2024
1 parent 56a1722 commit 673ba5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion collector/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func convArtiToPromBool(b bool) float64 {
}

const (
pattNumber = `^(?P<number>[[:digit:]]{1,3}(?:,[[:digit:]]{3})*(?:\.[[:digit:]]{1,2})?) ?(?P<multiplier>%|bytes|[KMGT]B)?$`
pattNumber = `^(?P<number>[[:digit:]]{1,4}(?:,[[:digit:]]{3})*(?:\.[[:digit:]]{1,2})?) ?(?P<multiplier>%|bytes|[KMGT]B)?$`
)

var (
Expand Down
5 changes: 5 additions & 0 deletions collector/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ func TestConvNum(t *testing.T) {
input: `100 %`,
want: 1.0,
},
{
// Detected during testing of https://github.com/peimanja/artifactory_exporter/pull/149
input: `1000GB`,
want: 1073741824000.0,
},
}
for _, tc := range tests {
got, err := fakeExporter.convArtiToPromNumber(tc.input)
Expand Down

0 comments on commit 673ba5a

Please sign in to comment.