Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

feat: kubectl-hns describe to show AllowCascadingDeletion flag #355

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
5 changes: 4 additions & 1 deletion internal/kubectl/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"time"

"github.com/spf13/cobra"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/duration"
)
Expand Down Expand Up @@ -74,6 +74,9 @@ var describeCmd = &cobra.Command{
fmt.Printf(" No children\n")
}

// AllowCascadingDeletion
fmt.Printf(" Allows Cascading Deletion: %t\n", hier.Spec.AllowCascadingDeletion)

// Conditions
describeConditions(hier.Status.Conditions)

Expand Down
14 changes: 9 additions & 5 deletions test/e2e/quickstart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ spec:
CreateSubnamespace(nsTeamB, nsOrg)

expected := "" + // empty string make go fmt happy
nsOrg + "\n" +
nsOrg + "\n" +
"├── [s] " + nsTeamA + "\n" +
"└── [s] " + nsTeamB
// The subnamespaces takes a bit of time to show up
RunShouldContain(expected, propogationTimeout, "kubectl hns tree", nsOrg)

// create hrq in parent acme-org
hrq:=`# quickstart_test.go: hrq in acme-org
hrq := `# quickstart_test.go: hrq in acme-org
apiVersion: hnc.x-k8s.io/v1alpha2
kind: HierarchicalResourceQuota
metadata:
Expand All @@ -217,15 +217,15 @@ spec:
MustApplyYAML(hrq)

// create service in team-a
MustRun("kubectl create service clusterip", nsTeamA + "-svc", "--clusterip=None", "-n", nsTeamA)
MustRun("kubectl create service clusterip", nsTeamA+"-svc", "--clusterip=None", "-n", nsTeamA)

// show that you can't use resources more than the hrq
MustNotRun("kubectl create service clusterip", nsTeamB + "-svc", "--clusterip=None", "-n", nsTeamB)
MustNotRun("kubectl create service clusterip", nsTeamB+"-svc", "--clusterip=None", "-n", nsTeamB)

// show hrq usage
RunShouldContain("services: 1/1", defTimeout, "kubectl get hrq", "-n", nsOrg)

MustRun("kubectl delete hrq", nsOrg + "-hrq", "-n", nsOrg)
MustRun("kubectl delete hrq", nsOrg+"-hrq", "-n", nsOrg)
})

It("Should create and delete subnamespaces", func() {
Expand Down Expand Up @@ -269,6 +269,10 @@ spec:
"└── [s] " + nsService2
RunShouldContain(expected, defTimeout, "kubectl hns tree", nsTeamA)

// Describe should describe AllowCascadingDeletion flag value
MustRun("kubectl hns describe", nsOrg)
RunShouldContain("Allows Cascading Deletion: false", defTimeout, "kubectl hns describe", nsOrg)

// cascading deletion with the kubectl-hns plugin
CreateSubnamespace(nsService1, nsTeamA)
CreateSubnamespace(nsService4, nsService1)
Expand Down