Files
steampipe/pkg/export/target.go
Nathan Wallace 0b0b330a27 Fix #4717: Add nil check to Target.Export() (#4881)
* Add test for #4717: Target.Export() should handle nil exporter gracefully

* Fix #4717: Add nil check to Target.Export()
2025-11-15 11:16:16 -05:00

27 lines
490 B
Go

package export
import (
"context"
"fmt"
"os"
)
type Target struct {
exporter Exporter
filePath string
isNamedTarget bool
}
func (t *Target) Export(ctx context.Context, input ExportSourceData) (string, error) {
if t.exporter == nil {
return "", fmt.Errorf("exporter is nil")
}
err := t.exporter.Export(ctx, input, t.filePath)
if err != nil {
return "", err
} else {
pwd, _ := os.Getwd()
return fmt.Sprintf("File exported to %s/%s", pwd, t.filePath), nil
}
}