Skip to content

Commit

Permalink
Merge pull request #6686 from dokku/k3s-autoscaling-validation
Browse files Browse the repository at this point in the history
Validate input for the autoscaling-auth:set command
  • Loading branch information
josegonzalez committed Mar 8, 2024
2 parents 4d18c8d + 8f5a834 commit bfe552e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions plugins/scheduler-k3s/subcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ func CommandAutoscalingAuthSet(appName string, trigger string, metadata map[stri
appName = "--global"
}

if appName != "--global" {
if err := common.VerifyAppName(appName); err != nil {
return err
}
}

if len(trigger) == 0 {
return fmt.Errorf("Missing trigger type argument")
}

if len(metadata) == 0 {
properties, err := common.PropertyGetAllByPrefix("scheduler-k3s", appName, fmt.Sprintf("%s%s.", TriggerAuthPropertyPrefix, trigger))
if err != nil {
Expand Down Expand Up @@ -95,6 +105,9 @@ func CommandAutoscalingAuthSet(appName string, trigger string, metadata map[stri
if err := common.PropertyWrite("scheduler-k3s", appName, fmt.Sprintf("%s%s.%s", TriggerAuthPropertyPrefix, trigger, key), value); err != nil {
return fmt.Errorf("Unable to set property: %w", err)
}

common.LogInfo1("Trigger authentication settings saved")
common.LogVerbose("Resources will be created or updated on next deploy")
}

if appName == "--global" {
Expand Down

0 comments on commit bfe552e

Please sign in to comment.