wisski-cloud-distillery/internal/component/exporter/manifest.go
2022-11-16 13:07:13 +01:00

33 lines
649 B
Go

package exporter
import (
"path/filepath"
)
type WithManifest struct {
Manifest []string
}
func (wm *WithManifest) handleManifest(dest string) (chan<- string, func()) {
manifest := make(chan string)
done := make(chan struct{})
go func() {
defer close(done)
for file := range manifest {
// get the relative path to the root of the manifest.
// nothing *should* go wrong, but in case it does, use the original path.
path, err := filepath.Rel(dest, file)
if err != nil {
path = file
}
// add the manifest
wm.Manifest = append(wm.Manifest, path)
}
}()
return manifest, func() {
close(manifest)
<-done
}
}