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

Commit

Permalink
Make devsession region specific for cleanup to work properly
Browse files Browse the repository at this point in the history
Signed-off-by: Darren Shepherd <darren@acorn.io>
  • Loading branch information
ibuildthecloud committed Aug 5, 2023
1 parent 7f7fd41 commit 96d1c00
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/apis/internal.acorn.io/v1/devsession.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ type DevSessionInstance struct {
Status DevSessionInstanceStatus `json:"status,omitempty"`
}

func (in *DevSessionInstance) HasRegion(region string) bool {
return in.Spec.Region == region
}

type DevSessionInstanceSpec struct {
Region string `json:"region,omitempty"`
Client DevSessionInstanceClient `json:"client,omitempty"`
SessionTimeoutSeconds int32 `json:"sessionTimeoutSeconds,omitempty"`
SessionStartTime metav1.Time `json:"sessionStartTime,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions pkg/client/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ func (c *DefaultClient) appUpdate(ctx context.Context, name string, opts *AppUpd
SessionStartTime: metav1.Now(),
SessionRenewTime: metav1.Now(),
SpecOverride: &app.Spec,
Region: app.GetRegion(),
},
}))
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/openapi/generated/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/server/registry/apigroups/acorn/devsessions/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ func (v *Validator) Validate(ctx context.Context, obj runtime.Object) (result fi
return
}

if devSession.Spec.Region != app.GetRegion() {
result = append(result, field.Invalid(field.NewPath("spec", "region"), devSession.Name,
"Region on devSession and app must match"))
return
}

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

0 comments on commit 96d1c00

Please sign in to comment.