Skip to content

Commit

Permalink
Fix app.Plan.Override as nil
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Jun 13, 2024
1 parent 29e47c0 commit c61daeb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1130,14 +1130,19 @@ func (app *App) validate() error {

func (app *App) validatePlan() error {
cpuBurst := app.Plan.CPUBurst
planOverride := app.Plan.Override

if cpuBurst == nil {
cpuBurst = &appTypes.CPUBurst{}
}

if planOverride == nil {
planOverride = &appTypes.PlanOverride{}
}

if (cpuBurst.MaxAllowed != 0) &&
(app.Plan.Override.CPUBurst != nil) &&
(*app.Plan.Override.CPUBurst > app.Plan.CPUBurst.MaxAllowed) {
(planOverride.CPUBurst != nil) &&
(*planOverride.CPUBurst > cpuBurst.MaxAllowed) {

msg := fmt.Sprintf("CPU burst exceeds the maximum allowed by plan %q", app.Plan.Name)
return &tsuruErrors.ValidationError{Message: msg}
Expand Down

0 comments on commit c61daeb

Please sign in to comment.