Skip to content

Commit

Permalink
update remotefile plugin for new version
Browse files Browse the repository at this point in the history
  • Loading branch information
DStrand1 committed Nov 12, 2024
1 parent a0d0516 commit e9148ce
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plugins/outputs/remotefile/remotefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ func (f *File) Init() error {
}

// Prepare VFS options
f.vfsopts = vfscommon.DefaultOpt
f.vfsopts = vfscommon.Opt
f.vfsopts.CacheMode = vfscommon.CacheModeWrites // required for appends
if f.WriteBackInterval > 0 {
f.vfsopts.WriteBack = time.Duration(f.WriteBackInterval)
f.vfsopts.WriteBack = fs.Duration(f.WriteBackInterval)
}
if f.MaxCacheSize > 0 {
f.vfsopts.CacheMaxSize = fs.SizeSuffix(f.MaxCacheSize)
}

// Redirect logging
fs.LogPrint = func(level fs.LogLevel, text string) {
fs.LogOutput = func(level fs.LogLevel, text string) {
if f.Trace {
f.Log.Debugf("[%s] %s", level.String(), text)
} else {
Expand Down Expand Up @@ -129,7 +129,7 @@ func (f *File) Connect() error {

// Setup the remote virtual filesystem
ctx, cancel := context.WithCancel(context.Background())
rootfs, err := info.NewFs(ctx, parsed.Name, parsed.Path, fs.ConfigMap(info, parsed.Name, parsed.Config))
rootfs, err := info.NewFs(ctx, parsed.Name, parsed.Path, fs.ConfigMap(info.Prefix, info.Options, parsed.Name, parsed.Config))
if err != nil {
cancel()
return fmt.Errorf("creating remote failed: %w", err)
Expand Down Expand Up @@ -229,13 +229,13 @@ func (f *File) Write(metrics []telegraf.Metric) error {
if filepath.ToSlash(fn) != fn {
dir = filepath.FromSlash(dir)
}
if err := f.root.MkdirAll(dir, f.root.Opt.DirPerms); err != nil {
if err := f.root.MkdirAll(dir, os.FileMode(f.root.Opt.DirPerms)); err != nil {
return fmt.Errorf("creating dir %q failed: %w", dir, err)
}
}

// Open the file for appending or create a new one
file, err := f.root.OpenFile(fn, os.O_APPEND|os.O_RDWR|os.O_CREATE, f.root.Opt.FilePerms)
file, err := f.root.OpenFile(fn, os.O_APPEND|os.O_RDWR|os.O_CREATE, os.FileMode(f.root.Opt.FilePerms))
if err != nil {
return fmt.Errorf("opening file %q: %w", fn, err)
}
Expand Down

0 comments on commit e9148ce

Please sign in to comment.