diff --git a/server/memphis_handlers_integrations.go b/server/memphis_handlers_integrations.go index ca5f93bae..e8df7e137 100644 --- a/server/memphis_handlers_integrations.go +++ b/server/memphis_handlers_integrations.go @@ -738,18 +738,19 @@ func containsRepo(repos []interface{}, target interface{}) bool { for _, repo := range repos { var mapBranch, mapRepo, targetBranch, targetRepo string repoMap, okRepoMap := repo.(map[string]interface{}) - if okRepoMap { + target, okTarget := target.(map[string]interface{}) + if okRepoMap && okTarget { if branchVal, ok := repoMap["branch"].(string); ok { mapBranch = branchVal } if repoVal, ok := repoMap["repo_name"].(string); ok { mapRepo = repoVal } - if targetBranchVal, ok := repoMap["branch"].(string); ok { + if targetBranchVal, ok := target["branch"].(string); ok { targetBranch = targetBranchVal } - if targetRepoVal, ok := repoMap["repo_name"].(string); ok { + if targetRepoVal, ok := target["repo_name"].(string); ok { targetRepo = targetRepoVal } if mapBranch == "" && targetBranch == "" && mapRepo == "" && targetRepo == "" { diff --git a/server/memphis_handlers_user_mgmt.go b/server/memphis_handlers_user_mgmt.go index 1037a985c..83a5aa766 100644 --- a/server/memphis_handlers_user_mgmt.go +++ b/server/memphis_handlers_user_mgmt.go @@ -162,11 +162,6 @@ func removeTenantResources(tenantName string, user models.User) error { } // TODO: send response of DeleteAndGetAttachedFunctionsByStation to microservice to delete - err = db.RemoveStationsByTenant(tenantName) - if err != nil { - return err - } - err = sendDeleteAllFunctionsReqToMS(user, tenantName, "github", "", "", "aws_lambda", "", true) if err != nil { return err @@ -198,6 +193,11 @@ func removeTenantResources(tenantName string, user models.User) error { return err } + err = db.RemoveStationsByTenant(tenantName) + if err != nil { + return err + } + if tenantName != MEMPHIS_GLOBAL_ACCOUNT { err = db.RemoveTenant(tenantName) if err != nil {