mirror of
https://github.com/turbot/steampipe.git
synced 2025-12-19 18:12:43 -05:00
42 lines
896 B
Go
42 lines
896 B
Go
package export
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/turbot/pipe-fittings/v2/steampipeconfig"
|
|
"github.com/turbot/steampipe/v2/pkg/constants"
|
|
)
|
|
|
|
type SnapshotExporter struct {
|
|
ExporterBase
|
|
}
|
|
|
|
func (e *SnapshotExporter) Export(_ context.Context, input ExportSourceData, filePath string) error {
|
|
snapshot, ok := input.(*steampipeconfig.SteampipeSnapshot)
|
|
if !ok {
|
|
return fmt.Errorf("SnapshotExporter input must be *dashboardtypes.SteampipeSnapshot")
|
|
}
|
|
snapshotBytes, err := snapshot.AsStrippedJson(false)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
res := strings.NewReader(fmt.Sprintf("%s\n", string(snapshotBytes)))
|
|
|
|
return Write(filePath, res)
|
|
}
|
|
|
|
func (e *SnapshotExporter) FileExtension() string {
|
|
return constants.SnapshotExtension
|
|
}
|
|
|
|
func (e *SnapshotExporter) Name() string {
|
|
return constants.OutputFormatSnapshot
|
|
}
|
|
|
|
func (*SnapshotExporter) Alias() string {
|
|
return "sps"
|
|
}
|