Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Set dev session region if not set
Browse files Browse the repository at this point in the history
When starting a dev session on a new app without setting a region on the
app, an error might crop up complaining about regions. This does not
happen if a region is explicitly set on the app.

Therefore, since users don't explicitly create dev session objects,
setting the region for them when the dev session region is unset is
reasonable.

Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Oct 25, 2023
1 parent 21ff0c8 commit 53296b8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/server/registry/apigroups/acorn/devsessions/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ func (v *Validator) Validate(ctx context.Context, obj runtime.Object) (result fi
}

if devSession.Spec.Region != app.GetRegion() {
result = append(result, field.Invalid(field.NewPath("spec", "region"), devSession.Spec.Region,
fmt.Sprintf("Region on devSession [%s] and app [%s] must match", devSession.Spec.Region, app.GetRegion())))
return
if devSession.Spec.Region != "" {
result = append(result, field.Invalid(field.NewPath("spec", "region"), devSession.Spec.Region,
fmt.Sprintf("Region on devSession [%s] and app [%s] must match", devSession.Spec.Region, app.GetRegion())))
return
}

// If the dev session's region is blank, then set it to the app's region.
devSession.Spec.Region = app.GetRegion()
}

if devSession.Spec.SpecOverride == nil {
Expand Down

0 comments on commit 53296b8

Please sign in to comment.