Skip to content

Commit

Permalink
fix missing scope error
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Labarussias <[email protected]>
  • Loading branch information
Issif authored and poiana committed Jan 22, 2025
1 parent 6ea2758 commit b4516db
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion actionners/kubernetes/sysdig/sysdig.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var (
type Parameters struct {
Image string `mapstructure:"image"`
Scope string `mapstructure:"scope" validate:"oneof=pod node"`
Duration int `mapstructure:"duration" validate:"gte=0,lte=30"`
Duration int `mapstructure:"duration" validate:"gt=0,lte=30"`
BufferSize int `mapstructure:"buffer_size" validate:"gte=128"`
}

Expand Down Expand Up @@ -157,6 +157,10 @@ func (a Actionner) Run(event *events.Event, action *rules.Action) (utils.LogLine
parameters.Scope = defaultScope
}

if parameters.BufferSize == 0 {
parameters.BufferSize = defaultBufferSize
}

client := k8s.GetClient()

pod, _ := client.GetPod(podName, namespace)
Expand Down Expand Up @@ -270,6 +274,18 @@ func (a Actionner) CheckParameters(action *rules.Action) error {
return err
}

if parameters.Scope == "" {
parameters.Scope = defaultScope
}

if parameters.BufferSize == 0 {
parameters.BufferSize = defaultBufferSize
}

if parameters.Duration == 0 {
parameters.Duration = defaultDuration
}

err = utils.ValidateStruct(parameters)
if err != nil {
return err
Expand Down

0 comments on commit b4516db

Please sign in to comment.