Skip to content

Commit

Permalink
inputs.x509_cert: Try to use globpath only on all file://, / sources
Browse files Browse the repository at this point in the history
(not on sources starting with <driveletter>:\)
See: influxdata#9289 for more information.
  • Loading branch information
jjh74 committed Jun 21, 2021
1 parent 7998ef8 commit 11f41ba
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugins/inputs/x509_cert/x509_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,21 @@ func (c *X509Cert) SampleConfig() string {
func (c *X509Cert) sourcesToURLs() error {
for _, source := range c.Sources {
if strings.HasPrefix(source, "file://") ||
strings.HasPrefix(source, "/") ||
strings.Index(source, ":\\") == 1 {
strings.HasPrefix(source, "/") {
source = filepath.ToSlash(strings.TrimPrefix(source, "file://"))
g, err := globpath.Compile(source)
if err != nil {
return fmt.Errorf("could not compile glob %v: %v", source, err)
}
c.globpaths = append(c.globpaths, g)
} else {
if strings.Index(source, ":\\") == 1 {
source = "file://" + filepath.ToSlash(source)
}
u, err := url.Parse(source)
if err != nil {
return fmt.Errorf("failed to parse cert location - %s", err.Error())
}

c.locations = append(c.locations, u)
}
}
Expand Down

0 comments on commit 11f41ba

Please sign in to comment.