diff --git a/cmd/common.go b/cmd/common.go index e5665ac0..cc7d0f50 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -26,6 +26,7 @@ import ( "gopkg.in/yaml.v2" ) +// This function parses the yaml file given and returns the tests data int it func parseYamlFile(filepath string) (declarative.Tests, error) { data, err := os.ReadFile(filepath) if err != nil { diff --git a/cmd/declarative.go b/cmd/declarative.go index 18b49157..2d402978 100644 --- a/cmd/declarative.go +++ b/cmd/declarative.go @@ -15,18 +15,13 @@ limitations under the License. package cmd import ( - - // register event collections "fmt" - _ "github.com/falcosecurity/event-generator/events/k8saudit" - _ "github.com/falcosecurity/event-generator/events/syscall" "github.com/falcosecurity/event-generator/pkg/declarative" - "github.com/spf13/cobra" ) -// NewList instantiates the list subcommand. +// NewDeclarative instantiates the declarative subcommand for run command. func NewDeclarative() *cobra.Command { c := &cobra.Command{ Use: "declarative [yaml-file-path]", @@ -43,6 +38,8 @@ func NewDeclarative() *cobra.Command { if err != nil { return err } + + // Execute each test mentioned in yaml file for _, eachTest := range tests.Tests { err := runTestSteps(eachTest) if err != nil { @@ -59,6 +56,7 @@ func NewDeclarative() *cobra.Command { func runTestSteps(test declarative.Test) error { var runner declarative.Runner + // Assign a runner based on test.Runner value switch test.Runner { case "HostRunner": runner = &declarative.Hostrunner{}