destroy project will destroy namespace

This commit is contained in:
Celina Lopez
2024-10-29 14:22:53 -07:00
parent 9925e80782
commit a4e07c2bd6
2 changed files with 13 additions and 1 deletions

View File

@@ -68,7 +68,7 @@ class ProjectsController < ApplicationController
# DELETE /projects/1 or /projects/1.json
def destroy
@project.destroy!
Projects::DestroyJob.perform_later(@project)
respond_to do |format|
format.html { redirect_to projects_url, status: :see_other, notice: "Project was successfully destroyed." }
format.json { head :no_content }

View File

@@ -0,0 +1,12 @@
class Projects::DestroyJob < ApplicationJob
def perform(project)
kubeconfig = project.cluster.kubeconfig
kubectl = K8::Kubectl.new(kubeconfig)
kubectl.call("delete namespace #{project.name}")
project.destroy!
end
end