mirror of
https://github.com/turbot/steampipe.git
synced 2026-03-01 17:01:00 -05:00
* Add test for #4717: Target.Export() should handle nil exporter gracefully * Fix #4717: Add nil check to Target.Export()
27 lines
490 B
Go
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
|
|
}
|
|
}
|