feat: allow `influx -import` to import from stdin (#25472)

Allow `influx -import` to import from stdin by specifying `-` as the path.
Example: `influx -import -path -`
gw_fix_load_log
Geoffrey Wossum 2024-10-17 14:33:56 -05:00 committed by GitHub
parent 3c87f524ed
commit 86e81167b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View File

@ -101,7 +101,7 @@ func main() {
-pps -pps
How many points per second the import will allow. By default it is zero and will not throttle importing. How many points per second the import will allow. By default it is zero and will not throttle importing.
-path -path
Path to file to import Path to file to import ('-' for stdin)
-compressed -compressed
Set to true if the import file is compressed Set to true if the import file is compressed

View File

@ -87,11 +87,16 @@ func (i *Importer) Import() error {
}() }()
// Open the file // Open the file
f, err := os.Open(i.config.Path) var f *os.File
if err != nil { if i.config.Path == "-" {
f = os.Stdin
} else {
var err error
if f, err = os.Open(i.config.Path); err != nil {
return err return err
} }
defer f.Close() defer f.Close()
}
var r io.Reader var r io.Reader