Skip to content

Commit

Permalink
some renaming.
Browse files Browse the repository at this point in the history
  • Loading branch information
preslavgerchev authored and chris-rock committed Dec 20, 2023
1 parent b9baa79 commit d44af69
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions apps/cnspec/cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ var scanCmdRun = func(cmd *cobra.Command, runtime *providers.Runtime, cliRes *pl

logger.DebugDumpJSON("report", report)

cliConf := reporter.ReportConfig{
handlerConf := reporter.HandlerConfig{
Format: conf.OutputFormat,
OutputTarget: conf.OutputTarget,
Incognito: conf.IsIncognito,
}
outputHandler, err := reporter.NewOutputHandler(cliConf)
outputHandler, err := reporter.NewOutputHandler(handlerConf)
if err != nil {
log.Fatal().Err(err).Msg("failed to create an output handler")
}
Expand Down
2 changes: 1 addition & 1 deletion cli/reporter/file_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestFileHandler(t *testing.T) {

now := time.Now().Format(time.RFC3339)
fileName := fmt.Sprintf("/tmp/%s-testfilehandler.json", now)
config := ReportConfig{Format: "compact", OutputTarget: fileName}
config := HandlerConfig{Format: "compact", OutputTarget: fileName}
handler, err := NewOutputHandler(config)
require.NoError(t, err)
err = handler.WriteReport(context.Background(), yr)
Expand Down
4 changes: 2 additions & 2 deletions cli/reporter/output_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"sigs.k8s.io/yaml"
)

type ReportConfig struct {
type HandlerConfig struct {
Format string
OutputTarget string
Incognito bool
Expand All @@ -33,7 +33,7 @@ type OutputHandler interface {
WriteReport(ctx context.Context, report *policy.ReportCollection) error
}

func NewOutputHandler(config ReportConfig) (OutputHandler, error) {
func NewOutputHandler(config HandlerConfig) (OutputHandler, error) {
format, ok := Formats[strings.ToLower(config.Format)]
if !ok {
return nil, errors.New("unknown output format '" + config.Format + "'. Available: " + AllFormats())
Expand Down
6 changes: 3 additions & 3 deletions cli/reporter/output_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestOutputHandlerAwsSqs(t *testing.T) {
}

for i, sqsUrl := range sqsUrls {
rep, err := NewOutputHandler(ReportConfig{Format: "JSON", OutputTarget: sqsUrl})
rep, err := NewOutputHandler(HandlerConfig{Format: "JSON", OutputTarget: sqsUrl})
require.NoError(t, err, i)
require.IsType(t, &awsSqsHandler{}, rep, i)
}
Expand All @@ -36,14 +36,14 @@ func TestOutputHandlerFileLocal(t *testing.T) {
}

for i, f := range fileTargets {
rep, err := NewOutputHandler(ReportConfig{Format: "JSON", OutputTarget: f})
rep, err := NewOutputHandler(HandlerConfig{Format: "JSON", OutputTarget: f})
require.NoError(t, err, i)
require.IsType(t, &localFileHandler{}, rep, i)
}
}

func TestCliReporter(t *testing.T) {
rep, err := NewOutputHandler(ReportConfig{})
rep, err := NewOutputHandler(HandlerConfig{})
require.NoError(t, err)
require.IsType(t, &Reporter{}, rep)
}
6 changes: 4 additions & 2 deletions test/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import (
"go.mondoo.com/cnspec/v9/apps/cnspec/cmd"
)

var once sync.Once
var cnspecCmd *cobra.Command
var (
once sync.Once
cnspecCmd *cobra.Command
)

func setup() {
var err error
Expand Down

0 comments on commit d44af69

Please sign in to comment.