Skip to content

Instantly share code, notes, and snippets.

@ialidzhikov
Created April 12, 2023 12:27
Show Gist options
  • Select an option

  • Save ialidzhikov/18de9d7b875cc8693bc57e412662a19d to your computer and use it in GitHub Desktop.

Select an option

Save ialidzhikov/18de9d7b875cc8693bc57e412662a19d to your computer and use it in GitHub Desktop.
ShootState `deletecollection`
package main
import (
"context"
"flag"
"fmt"
gardencoreversionedclientset "github.com/gardener/gardener/pkg/client/core/clientset/versioned"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/clientcmd"
)
var gardenKubeconfig = flag.String("garden-kubeconfig", "", "Garden cluster's kubeconfig path")
func main() {
flag.Parse()
if gardenKubeconfig == nil || len(*gardenKubeconfig) == 0 {
panic("--garden-kubeconfig is required")
}
ctx := context.Background()
config, err := clientcmd.BuildConfigFromFlags("", *gardenKubeconfig)
if err != nil {
panic(err)
}
versionedCoreClient, err := gardencoreversionedclientset.NewForConfig(config)
if err != nil {
panic(err)
}
if err := versionedCoreClient.CoreV1beta1().ShootStates("garden-baz").DeleteCollection(ctx, metav1.DeleteOptions{}, metav1.ListOptions{}); err != nil {
panic(err)
}
fmt.Println("Success")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment