From 5eb80790d37170897a1a78f9f8e176ff2a6fd01c Mon Sep 17 00:00:00 2001 From: sunguroku Date: Mon, 20 May 2024 17:57:16 -0400 Subject: [PATCH 1/8] delete porter cloud project --- api/server/handlers/project/delete.go | 18 ++++++++++++++++++ go.mod | 2 ++ go.sum | 2 -- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/api/server/handlers/project/delete.go b/api/server/handlers/project/delete.go index 7903024238..4e0385d1b7 100644 --- a/api/server/handlers/project/delete.go +++ b/api/server/handlers/project/delete.go @@ -51,6 +51,24 @@ func (p *ProjectDeleteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) continue } + if cluster.CloudProvider == "Hosted" { + req := connect.NewRequest(&porterv1.DeletePorterCloudClusterRequest{ + ClusterId: int64(cluster.ID), + ProjectId: int64(cluster.ProjectID), + }) + + _, err = p.Config().ClusterControlPlaneClient.DeletePorterCloudCluster(ctx, req) + if err != nil { + e := "error deleting cluster" + err = telemetry.Error(ctx, span, err, e) + p.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError)) + return + } + + // technically multiple clusters shouldn't exist in a porter cloud project. + continue + } + contractRevision, err := p.Config().Repo.APIContractRevisioner().List(ctx, proj.ID, repository.WithClusterID(cluster.ID)) if err != nil { e := "error finding contract revisions for cluster" diff --git a/go.mod b/go.mod index 96b70c1f75..793e2602d0 100644 --- a/go.mod +++ b/go.mod @@ -390,3 +390,5 @@ require ( sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect ) + +replace github.com/porter-dev/api-contracts => ../api-contracts diff --git a/go.sum b/go.sum index 8557a216ca..a56b097d49 100644 --- a/go.sum +++ b/go.sum @@ -1570,8 +1570,6 @@ github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polyfloyd/go-errorlint v0.0.0-20210722154253-910bb7978349/go.mod h1:wi9BfjxjF/bwiZ701TzmfKu6UKC357IOAtNr0Td0Lvw= -github.com/porter-dev/api-contracts v0.2.164 h1:99Y96YH9CfAl/aPjnqXbsiEgMHUFxDM9wC5G5sQnmyQ= -github.com/porter-dev/api-contracts v0.2.164/go.mod h1:VV5BzXd02ZdbWIPLVP+PX3GKawJSGQnxorVT2sUZALU= github.com/porter-dev/switchboard v0.0.3 h1:dBuYkiVLa5Ce7059d6qTe9a1C2XEORFEanhbtV92R+M= github.com/porter-dev/switchboard v0.0.3/go.mod h1:xSPzqSFMQ6OSbp42fhCi4AbGbQbsm6nRvOkrblFeXU4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= From 2512fc201432b9a9163cc5d7fde5d21cd87e9af0 Mon Sep 17 00:00:00 2001 From: sunguroku Date: Wed, 22 May 2024 12:33:11 -0400 Subject: [PATCH 2/8] delete associated ns --- api/server/handlers/project/delete.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/server/handlers/project/delete.go b/api/server/handlers/project/delete.go index 4e0385d1b7..ba5d19788a 100644 --- a/api/server/handlers/project/delete.go +++ b/api/server/handlers/project/delete.go @@ -1,6 +1,7 @@ package project import ( + "fmt" "net/http" "connectrpc.com/connect" @@ -36,6 +37,7 @@ func (p *ProjectDeleteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) user, _ := ctx.Value(types.UserScope).(*models.User) proj, _ := ctx.Value(types.ProjectScope).(*models.Project) + fmt.Println("DLAKJLASJFLKJLAJS") if proj.GetFeatureFlag(models.CapiProvisionerEnabled, p.Config().LaunchDarklyClient) { clusters, err := p.Config().Repo.Cluster().ListClustersByProjectID(proj.ID) if err != nil { From e43a6aa49c75a223840b9289b3caa5f69f5f9dee Mon Sep 17 00:00:00 2001 From: sunguroku Date: Wed, 22 May 2024 12:35:06 -0400 Subject: [PATCH 3/8] remove go.mod --- api/server/handlers/project/delete.go | 2 -- go.mod | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/api/server/handlers/project/delete.go b/api/server/handlers/project/delete.go index ba5d19788a..4e0385d1b7 100644 --- a/api/server/handlers/project/delete.go +++ b/api/server/handlers/project/delete.go @@ -1,7 +1,6 @@ package project import ( - "fmt" "net/http" "connectrpc.com/connect" @@ -37,7 +36,6 @@ func (p *ProjectDeleteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) user, _ := ctx.Value(types.UserScope).(*models.User) proj, _ := ctx.Value(types.ProjectScope).(*models.Project) - fmt.Println("DLAKJLASJFLKJLAJS") if proj.GetFeatureFlag(models.CapiProvisionerEnabled, p.Config().LaunchDarklyClient) { clusters, err := p.Config().Repo.Cluster().ListClustersByProjectID(proj.ID) if err != nil { diff --git a/go.mod b/go.mod index 793e2602d0..5a69da0613 100644 --- a/go.mod +++ b/go.mod @@ -389,6 +389,4 @@ require ( sigs.k8s.io/kustomize/api v0.12.1 // indirect sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect -) - -replace github.com/porter-dev/api-contracts => ../api-contracts +) \ No newline at end of file From 731e11f0219c29b0d198f6ee7fa5a2a332db63e9 Mon Sep 17 00:00:00 2001 From: sunguroku Date: Wed, 22 May 2024 12:37:38 -0400 Subject: [PATCH 4/8] go mod --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 5a69da0613..96b70c1f75 100644 --- a/go.mod +++ b/go.mod @@ -389,4 +389,4 @@ require ( sigs.k8s.io/kustomize/api v0.12.1 // indirect sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect -) \ No newline at end of file +) diff --git a/go.sum b/go.sum index a56b097d49..8557a216ca 100644 --- a/go.sum +++ b/go.sum @@ -1570,6 +1570,8 @@ github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polyfloyd/go-errorlint v0.0.0-20210722154253-910bb7978349/go.mod h1:wi9BfjxjF/bwiZ701TzmfKu6UKC357IOAtNr0Td0Lvw= +github.com/porter-dev/api-contracts v0.2.164 h1:99Y96YH9CfAl/aPjnqXbsiEgMHUFxDM9wC5G5sQnmyQ= +github.com/porter-dev/api-contracts v0.2.164/go.mod h1:VV5BzXd02ZdbWIPLVP+PX3GKawJSGQnxorVT2sUZALU= github.com/porter-dev/switchboard v0.0.3 h1:dBuYkiVLa5Ce7059d6qTe9a1C2XEORFEanhbtV92R+M= github.com/porter-dev/switchboard v0.0.3/go.mod h1:xSPzqSFMQ6OSbp42fhCi4AbGbQbsm6nRvOkrblFeXU4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= From c6ecb61a9616a455764a9878799308f0df0d9478 Mon Sep 17 00:00:00 2001 From: sunguroku Date: Wed, 22 May 2024 14:02:05 -0400 Subject: [PATCH 5/8] docs link fix --- .../validate-apply/services-settings/tabs/Advanced.tsx | 2 +- .../validate-apply/services-settings/tabs/Advanced.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dashboard/src/legacy/main/home/app-dashboard/validate-apply/services-settings/tabs/Advanced.tsx b/dashboard/src/legacy/main/home/app-dashboard/validate-apply/services-settings/tabs/Advanced.tsx index f0e5f42107..e32fc489c7 100644 --- a/dashboard/src/legacy/main/home/app-dashboard/validate-apply/services-settings/tabs/Advanced.tsx +++ b/dashboard/src/legacy/main/home/app-dashboard/validate-apply/services-settings/tabs/Advanced.tsx @@ -22,7 +22,7 @@ const Advanced: React.FC = ({ index }) => { Specify how much time service processes are given to gracefully shut down when they receive SIGTERM diff --git a/dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Advanced.tsx b/dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Advanced.tsx index f215b969cf..4bfbbc4f5e 100644 --- a/dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Advanced.tsx +++ b/dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Advanced.tsx @@ -23,7 +23,7 @@ const Advanced: React.FC = ({ index }) => { Specify how much time service processes are given to gracefully shut down when they receive SIGTERM From 7296d25a1a5cef59d26ff3bfc0de57a114001558 Mon Sep 17 00:00:00 2001 From: sunguroku Date: Wed, 22 May 2024 14:13:51 -0400 Subject: [PATCH 6/8] nit --- api/server/handlers/project/delete.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/server/handlers/project/delete.go b/api/server/handlers/project/delete.go index 4e0385d1b7..96e47876eb 100644 --- a/api/server/handlers/project/delete.go +++ b/api/server/handlers/project/delete.go @@ -59,8 +59,7 @@ func (p *ProjectDeleteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) _, err = p.Config().ClusterControlPlaneClient.DeletePorterCloudCluster(ctx, req) if err != nil { - e := "error deleting cluster" - err = telemetry.Error(ctx, span, err, e) + err = telemetry.Error(ctx, span, err, "error deleting cluster") p.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError)) return } From 871eff437fa7a5c10a3442f9d11a68c3588517b7 Mon Sep 17 00:00:00 2001 From: sunguroku Date: Wed, 22 May 2024 14:46:04 -0400 Subject: [PATCH 7/8] go mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 96b70c1f75..30a2c0a8a0 100644 --- a/go.mod +++ b/go.mod @@ -89,7 +89,7 @@ require ( github.com/nats-io/nats.go v1.24.0 github.com/open-policy-agent/opa v0.44.0 github.com/ory/client-go v1.9.0 - github.com/porter-dev/api-contracts v0.2.164 + github.com/porter-dev/api-contracts v0.2.169 github.com/riandyrn/otelchi v0.5.1 github.com/santhosh-tekuri/jsonschema/v5 v5.0.1 github.com/stefanmcshane/helm v0.0.0-20221213002717-88a4a2c6e77d From 253552998ec4509925967156b25966292170e1eb Mon Sep 17 00:00:00 2001 From: sunguroku Date: Wed, 22 May 2024 14:46:51 -0400 Subject: [PATCH 8/8] update api contract version --- go.sum | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.sum b/go.sum index 8557a216ca..61a7eac12f 100644 --- a/go.sum +++ b/go.sum @@ -1570,8 +1570,8 @@ github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polyfloyd/go-errorlint v0.0.0-20210722154253-910bb7978349/go.mod h1:wi9BfjxjF/bwiZ701TzmfKu6UKC357IOAtNr0Td0Lvw= -github.com/porter-dev/api-contracts v0.2.164 h1:99Y96YH9CfAl/aPjnqXbsiEgMHUFxDM9wC5G5sQnmyQ= -github.com/porter-dev/api-contracts v0.2.164/go.mod h1:VV5BzXd02ZdbWIPLVP+PX3GKawJSGQnxorVT2sUZALU= +github.com/porter-dev/api-contracts v0.2.169 h1:bZtfkBkkNRyZtez4zfRxjwTEcIMtwegN9fteGDAw4Q0= +github.com/porter-dev/api-contracts v0.2.169/go.mod h1:VV5BzXd02ZdbWIPLVP+PX3GKawJSGQnxorVT2sUZALU= github.com/porter-dev/switchboard v0.0.3 h1:dBuYkiVLa5Ce7059d6qTe9a1C2XEORFEanhbtV92R+M= github.com/porter-dev/switchboard v0.0.3/go.mod h1:xSPzqSFMQ6OSbp42fhCi4AbGbQbsm6nRvOkrblFeXU4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=