mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-12-04 15:21:05 +01:00
fix(be): remove integrations when template removed
This commit is contained in:
parent
8e2f450981
commit
8123bdad21
@ -6,6 +6,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/semaphoreui/semaphore/db"
|
"github.com/semaphoreui/semaphore/db"
|
||||||
|
"go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -145,10 +146,19 @@ func (d *BoltDb) UpdateIntegrationMatcher(projectID int, integrationMatcher db.I
|
|||||||
return d.updateObject(projectID, db.IntegrationMatcherProps, integrationMatcher)
|
return d.updateObject(projectID, db.IntegrationMatcherProps, integrationMatcher)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BoltDb) DeleteIntegrationMatcher(projectID int, matcherID int, integrationID int) error {
|
func (d *BoltDb) deleteIntegrationMatcher(projectID int, matcherID int, integrationID int, tx *bbolt.Tx) error {
|
||||||
return d.deleteObject(projectID, db.IntegrationMatcherProps, intObjectID(matcherID), nil)
|
return d.deleteObject(projectID, db.IntegrationMatcherProps, intObjectID(matcherID), tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *BoltDb) DeleteIntegrationMatcher(projectID int, matcherID int, integrationID int) error {
|
||||||
|
return d.deleteIntegrationMatcher(projectID, matcherID, integrationID, nil)
|
||||||
|
}
|
||||||
|
|
||||||
func (d *BoltDb) DeleteIntegration(projectID int, integrationID int) error {
|
func (d *BoltDb) DeleteIntegration(projectID int, integrationID int) error {
|
||||||
|
return d.deleteIntegration(projectID, integrationID, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *BoltDb) deleteIntegration(projectID int, integrationID int, tx *bbolt.Tx) error {
|
||||||
matchers, err := d.GetIntegrationMatchers(projectID, db.RetrieveQueryParams{}, integrationID)
|
matchers, err := d.GetIntegrationMatchers(projectID, db.RetrieveQueryParams{}, integrationID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -156,10 +166,10 @@ func (d *BoltDb) DeleteIntegration(projectID int, integrationID int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for m := range matchers {
|
for m := range matchers {
|
||||||
d.DeleteIntegrationMatcher(projectID, matchers[m].ID, integrationID)
|
d.deleteIntegrationMatcher(projectID, matchers[m].ID, integrationID, tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
return d.deleteObject(projectID, db.IntegrationProps, intObjectID(integrationID), nil)
|
return d.deleteObject(projectID, db.IntegrationProps, intObjectID(integrationID), tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BoltDb) GetIntegrationMatcherRefs(projectID int, matcherID int, integrationID int) (db.IntegrationExtractorChildReferrers, error) {
|
func (d *BoltDb) GetIntegrationMatcherRefs(projectID int, matcherID int, integrationID int) (db.IntegrationExtractorChildReferrers, error) {
|
||||||
|
@ -172,6 +172,30 @@ func (d *BoltDb) deleteTemplate(projectID int, templateID int, tx *bbolt.Tx) (er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete template vaults
|
||||||
|
vaults, err := d.GetTemplateVaults(projectID, templateID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, sch := range vaults {
|
||||||
|
err = d.deleteTemplateVault(projectID, sch.ID, tx)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
integrations, err := d.GetIntegrations(projectID, db.RetrieveQueryParams{})
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, integration := range integrations {
|
||||||
|
if integration.TemplateID != templateID {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
d.deleteIntegration(projectID, integration.ID, tx)
|
||||||
|
}
|
||||||
|
|
||||||
return d.deleteObject(projectID, db.TemplateProps, intObjectID(templateID), tx)
|
return d.deleteObject(projectID, db.TemplateProps, intObjectID(templateID), tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,3 +69,7 @@ func (d *BoltDb) UpdateTemplateVaults(projectID int, templateID int, vaults []db
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *BoltDb) deleteTemplateVault(projectID int, vaultID int, tx *bbolt.Tx) error {
|
||||||
|
return d.deleteObject(projectID, db.TemplateVaultProps, intObjectID(vaultID), tx)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user