-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
498 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package dataflow | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/bearer/bearer/pkg/commands/process/settings" | ||
"github.com/bearer/bearer/pkg/flag" | ||
outputtypes "github.com/bearer/bearer/pkg/report/output/types" | ||
outputhandler "github.com/bearer/bearer/pkg/util/output" | ||
) | ||
|
||
type Formatter struct { | ||
ReportData *outputtypes.ReportData | ||
Config settings.Config | ||
} | ||
|
||
func NewFormatter(reportData *outputtypes.ReportData, config settings.Config) *Formatter { | ||
return &Formatter{ | ||
ReportData: reportData, | ||
Config: config, | ||
} | ||
} | ||
|
||
func (f Formatter) Format(format string) (output *string, err error) { | ||
switch format { | ||
case flag.FormatEmpty: | ||
output, err = outputhandler.ReportJSON(f.ReportData.Dataflow) | ||
case flag.FormatJSON: | ||
output, err = outputhandler.ReportJSON(f.ReportData.Dataflow) | ||
case flag.FormatYAML: | ||
output, err = outputhandler.ReportYAML(f.ReportData.Dataflow) | ||
default: | ||
err = fmt.Errorf(`--report flag "%s" is not supported`, f.Config.Report.Report) | ||
} | ||
|
||
return output, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package detectors | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/bearer/bearer/pkg/commands/process/settings" | ||
"github.com/bearer/bearer/pkg/flag" | ||
outputtypes "github.com/bearer/bearer/pkg/report/output/types" | ||
outputhandler "github.com/bearer/bearer/pkg/util/output" | ||
) | ||
|
||
type Formatter struct { | ||
ReportData *outputtypes.ReportData | ||
Config settings.Config | ||
} | ||
|
||
func NewFormatter(reportData *outputtypes.ReportData, config settings.Config) *Formatter { | ||
return &Formatter{ | ||
ReportData: reportData, | ||
Config: config, | ||
} | ||
} | ||
|
||
func (f Formatter) Format(format string) (output *string, err error) { | ||
switch format { | ||
case flag.FormatEmpty: | ||
output, err = outputhandler.ReportJSON(f.ReportData.Detectors) | ||
case flag.FormatJSON: | ||
output, err = outputhandler.ReportJSON(f.ReportData.Detectors) | ||
case flag.FormatYAML: | ||
output, err = outputhandler.ReportYAML(f.ReportData.Detectors) | ||
default: | ||
err = fmt.Errorf(`--report flag "%s" is not supported`, f.Config.Report.Report) | ||
} | ||
|
||
return output, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.