Skip to content

Commit

Permalink
Added comments to explain the code
Browse files Browse the repository at this point in the history
Signed-off-by: GLVS Kiriti <[email protected]>
  • Loading branch information
GLVSKiriti committed Jun 17, 2024
1 parent fe51d56 commit 74a2a78
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 4 additions & 6 deletions cmd/declarative.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand All @@ -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 {
Expand All @@ -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{}
Expand Down

0 comments on commit 74a2a78

Please sign in to comment.