mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-21 21:30:48 +02:00
fix: testing for flag files on windows (#1249)
* fix: testing for flag files on windows * fix build script on windows/msys
This commit is contained in:
parent
2f4d58776d
commit
56368a7207
3 changed files with 22 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
package flags
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
@ -468,9 +469,13 @@ func getSecretFromFile(flags *pflag.FlagSet, secret string) {
|
|||
}
|
||||
|
||||
func isFile(s string) bool {
|
||||
_, err := os.Stat(s)
|
||||
if os.IsNotExist(err) {
|
||||
firstColon := strings.IndexRune(s, ':')
|
||||
if firstColon != 1 && firstColon != -1 {
|
||||
// If the string contains a ':', but it's not the second character, it's probably not a file
|
||||
// and will cause a fatal error on windows if stat'ed
|
||||
// This still allows for paths that start with 'c:\' etc.
|
||||
return false
|
||||
}
|
||||
return true
|
||||
_, err := os.Stat(s)
|
||||
return !errors.Is(err, os.ErrNotExist)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue