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
parent
3c87f524ed
commit
86e81167b8
|
@ -101,7 +101,7 @@ func main() {
|
|||
-pps
|
||||
How many points per second the import will allow. By default it is zero and will not throttle importing.
|
||||
-path
|
||||
Path to file to import
|
||||
Path to file to import ('-' for stdin)
|
||||
-compressed
|
||||
Set to true if the import file is compressed
|
||||
|
||||
|
|
|
@ -87,11 +87,16 @@ func (i *Importer) Import() error {
|
|||
}()
|
||||
|
||||
// Open the file
|
||||
f, err := os.Open(i.config.Path)
|
||||
if err != nil {
|
||||
var f *os.File
|
||||
if i.config.Path == "-" {
|
||||
f = os.Stdin
|
||||
} else {
|
||||
var err error
|
||||
if f, err = os.Open(i.config.Path); err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
}
|
||||
|
||||
var r io.Reader
|
||||
|
||||
|
|
Loading…
Reference in New Issue