Skip to content

Commit

Permalink
KUBE-630: Add disable service account support
Browse files Browse the repository at this point in the history
  • Loading branch information
gleb committed Oct 21, 2024
1 parent 0121ed0 commit a58ff27
Show file tree
Hide file tree
Showing 4 changed files with 848 additions and 55 deletions.
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

0 comments on commit a58ff27

Please sign in to comment.