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

Commit c3b5b24

Browse files
authored
Merge pull request #355 from manjinder-mckc/describe-allowcascadingdelete
feat: kubectl-hns describe to show AllowCascadingDeletion flag
2 parents b745a3b + 815bb27 commit c3b5b24

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

internal/kubectl/describe.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"time"
2626

2727
"github.com/spf13/cobra"
28-
"k8s.io/api/core/v1"
28+
v1 "k8s.io/api/core/v1"
2929
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
"k8s.io/apimachinery/pkg/util/duration"
3131
)
@@ -74,6 +74,9 @@ var describeCmd = &cobra.Command{
7474
fmt.Printf(" No children\n")
7575
}
7676

77+
// AllowCascadingDeletion
78+
fmt.Printf(" Allows Cascading Deletion: %t\n", hier.Spec.AllowCascadingDeletion)
79+
7780
// Conditions
7881
describeConditions(hier.Status.Conditions)
7982

test/e2e/quickstart_test.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,14 @@ spec:
198198
CreateSubnamespace(nsTeamB, nsOrg)
199199

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

207207
// create hrq in parent acme-org
208-
hrq:=`# quickstart_test.go: hrq in acme-org
208+
hrq := `# quickstart_test.go: hrq in acme-org
209209
apiVersion: hnc.x-k8s.io/v1alpha2
210210
kind: HierarchicalResourceQuota
211211
metadata:
@@ -217,15 +217,15 @@ spec:
217217
MustApplyYAML(hrq)
218218

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

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

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

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

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

272+
// Describe should describe AllowCascadingDeletion flag value
273+
MustRun("kubectl hns describe", nsOrg)
274+
RunShouldContain("Allows Cascading Deletion: false", defTimeout, "kubectl hns describe", nsOrg)
275+
272276
// cascading deletion with the kubectl-hns plugin
273277
CreateSubnamespace(nsService1, nsTeamA)
274278
CreateSubnamespace(nsService4, nsService1)

0 commit comments

Comments
 (0)