Created
April 12, 2023 12:27
-
-
Save ialidzhikov/18de9d7b875cc8693bc57e412662a19d to your computer and use it in GitHub Desktop.
ShootState `deletecollection`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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