Skip to content

Commit

Permalink
Add A Pre Deprovision Hook
Browse files Browse the repository at this point in the history
  • Loading branch information
spjmurray committed Dec 6, 2024
1 parent 8f5afa3 commit 1c82b01
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions charts/core/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: A Helm chart for deploying Unikorn Core

type: application

version: v0.1.86
appVersion: v0.1.86
version: v0.1.87
appVersion: v0.1.87

icon: https://assets.unikorn-cloud.org/images/logos/dark-on-light/icon.svg

Expand Down
7 changes: 7 additions & 0 deletions pkg/provisioners/application/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,10 @@ type Customizer interface {
type PostProvisionHook interface {
PostProvision(ctx context.Context) error
}

// PreDeprovisionHook is an interface that lets an application deprovisioner run
// a callback before deprovisioning an application e.g. to handle manual resource
// deletion.
type PreDeprovisionHook interface {
PreDeprovision(ctx context.Context) error
}
8 changes: 8 additions & 0 deletions pkg/provisioners/application/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,14 @@ func (p *Provisioner) Provision(ctx context.Context) error {
func (p *Provisioner) Deprovision(ctx context.Context) error {
log := log.FromContext(ctx)

if p.generator != nil {
if hook, ok := p.generator.(PreDeprovisionHook); ok {
if err := hook.PreDeprovision(ctx); err != nil {
return err
}
}
}

if err := p.initialize(ctx); err != nil {
return err
}
Expand Down

0 comments on commit 1c82b01

Please sign in to comment.