Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KUBE-630: Add disable service account support #406

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion castai/resource_gke_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func resourceGKECluster() *schema.Resource {
CreateContext: resourceCastaiGKEClusterCreate,
ReadContext: resourceCastaiGKEClusterRead,
UpdateContext: resourceCastaiGKEClusterUpdate,
DeleteContext: resourceCastaiClusterDelete,
DeleteContext: resourceCastaiGKEClusterDelete,
CustomizeDiff: clusterTokenDiff,
Description: "GKE cluster resource allows connecting an existing GKE cluster to CAST AI.",

Expand Down Expand Up @@ -215,3 +215,14 @@ func updateGKEClusterSettings(ctx context.Context, data *schema.ResourceData, cl

return nil
}

func resourceCastaiGKEClusterDelete(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics {
// Disable service account used for impersonation.
client := meta.(*ProviderConfig).api
log.Printf("[INFO] Disabling service account.")
_, err := client.ExternalClusterAPIDisableGKESA(ctx, data.Id())
if err != nil {
log.Printf("[ERROR] Failed to disable service account: %v", err)
}
return resourceCastaiClusterDelete(ctx, data, meta)
}
117 changes: 79 additions & 38 deletions castai/sdk/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading