Skip to content

Commit

Permalink
Merge 1dae3ca into backport/cleanup_remove_finalizers/blatantly-set-b…
Browse files Browse the repository at this point in the history
…asilisk
  • Loading branch information
hc-github-team-consul-core authored Mar 14, 2024
2 parents a3ee3bc + 1dae3ca commit 3cceb96
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion acceptance/framework/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ func RunCommand(t testutil.TestingTB, command Command) (string, error) {
return string(cmd), err
}

// getCRDRemoveFinalizers gets CRDs with finalizers and removes them.
func getCRDRemoveFinalizers(t testutil.TestingTB) error {
t.Helper()
// Get CRD names with finalizers
Expand All @@ -233,7 +234,7 @@ func getCRDRemoveFinalizers(t testutil.TestingTB) error {
return nil
}

// CRD struct to parse CRD JSON output
// CRD struct to parse CRD JSON output.
type CRD struct {
Items []struct {
Metadata struct {
Expand All @@ -243,6 +244,7 @@ type CRD struct {
} `json:"items"`
}

// getCRDsWithFinalizers gets CRDs with finalizers.
func getCRDsWithFinalizers() ([]string, error) {
cmd := exec.Command("kubectl", "get", "crd", "-o=json")

Expand All @@ -266,6 +268,7 @@ func getCRDsWithFinalizers() ([]string, error) {
return crdNames, nil
}

// removeFinalizers removes finalizers from CRDs.
func removeFinalizers(crdNames []string) error {
for _, crd := range crdNames {
cmd := exec.Command("kubectl", "patch", "crd", crd, "--type=json", "-p=[{\"op\": \"remove\", \"path\": \"/metadata/finalizers\"}]")
Expand Down

0 comments on commit 3cceb96

Please sign in to comment.