Skip to content

Commit 5eb30e0

Browse files
authored
Remove printers from third_party and use cli-utils (#2627)
1 parent 67521d1 commit 5eb30e0

File tree

39 files changed

+113
-3057
lines changed

39 files changed

+113
-3057
lines changed

e2e/live/end-to-end-test.sh

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,10 @@ ${BIN_DIR}/kpt live apply e2e/live/testdata/rg-test-case-1a > $OUTPUT_DIR/status
437437
# The ResourceGroup inventory CRD is automatically installed on the initial apply.
438438
assertContains "installing inventory ResourceGroup CRD"
439439
assertContains "namespace/rg-test-namespace unchanged"
440-
assertContains "1 resource(s) applied. 0 created, 1 unchanged, 0 configured, 0 failed"
441440
assertContains "pod/pod-a created"
442441
assertContains "pod/pod-b created"
443442
assertContains "pod/pod-c created"
444-
assertContains "3 resource(s) applied. 3 created, 0 unchanged, 0 configured, 0 failed"
443+
assertContains "4 resource(s) applied. 3 created, 1 unchanged, 0 configured, 0 failed"
445444
wait 2
446445
# Validate resources in the cluster
447446
# ConfigMap inventory with four inventory items.
@@ -451,11 +450,10 @@ assertRGInventory "rg-test-namespace" "4"
451450
${BIN_DIR}/kpt live apply e2e/live/testdata/rg-test-case-1a > $OUTPUT_DIR/status 2>&1
452451
assertNotContains "installing inventory ResourceGroup CRD" # Not applied again
453452
assertContains "namespace/rg-test-namespace unchanged"
454-
assertContains "1 resource(s) applied. 0 created, 1 unchanged, 0 configured, 0 failed"
455453
assertContains "pod/pod-a unchanged"
456454
assertContains "pod/pod-b unchanged"
457455
assertContains "pod/pod-c unchanged"
458-
assertContains "3 resource(s) applied. 0 created, 3 unchanged, 0 configured, 0 failed"
456+
assertContains "4 resource(s) applied. 0 created, 4 unchanged, 0 configured, 0 failed"
459457
wait 2
460458

461459
printResult
@@ -529,12 +527,11 @@ printResult
529527
echo "[ResourceGroup] Testing initial apply dry-run"
530528
echo "kpt live apply --dry-run e2e/live/testdata/rg-test-case-1a"
531529
${BIN_DIR}/kpt live apply --dry-run e2e/live/testdata/rg-test-case-1a > $OUTPUT_DIR/status
532-
assertContains "namespace/rg-test-namespace created (dry-run)"
533-
assertContains "1 resource(s) applied. 1 created, 0 unchanged, 0 configured, 0 failed (dry-run)"
534-
assertContains "pod/pod-a created (dry-run)"
535-
assertContains "pod/pod-b created (dry-run)"
536-
assertContains "pod/pod-c created (dry-run)"
537-
assertContains "3 resource(s) applied. 3 created, 0 unchanged, 0 configured, 0 failed"
530+
assertContains "namespace/rg-test-namespace created"
531+
assertContains "pod/pod-a created"
532+
assertContains "pod/pod-b created"
533+
assertContains "pod/pod-c created"
534+
assertContains "4 resource(s) applied. 4 created, 0 unchanged, 0 configured, 0 failed"
538535
printResult
539536

540537
# Test: Basic kpt live apply
@@ -545,11 +542,10 @@ ${BIN_DIR}/kpt live apply e2e/live/testdata/rg-test-case-1a > $OUTPUT_DIR/status
545542
# The ResourceGroup CRD is already installed.
546543
assertNotContains "installing inventory ResourceGroup CRD"
547544
assertContains "namespace/rg-test-namespace unchanged"
548-
assertContains "1 resource(s) applied. 0 created, 1 unchanged, 0 configured, 0 failed"
549545
assertContains "pod/pod-a created"
550546
assertContains "pod/pod-b created"
551547
assertContains "pod/pod-c created"
552-
assertContains "3 resource(s) applied. 3 created, 0 unchanged, 0 configured, 0 failed"
548+
assertContains "4 resource(s) applied. 3 created, 1 unchanged, 0 configured, 0 failed"
553549
wait 2
554550
# Validate resources in the cluster
555551
# ConfigMap inventory with four inventory items.
@@ -565,11 +561,10 @@ ${BIN_DIR}/kpt live apply link-to-rg-test-case-1a > $OUTPUT_DIR/status
565561
# The ResourceGroup CRD is already installed.
566562
assertNotContains "installing inventory ResourceGroup CRD"
567563
assertContains "namespace/rg-test-namespace unchanged"
568-
assertContains "1 resource(s) applied. 0 created, 1 unchanged, 0 configured, 0 failed"
569564
assertContains "pod/pod-a unchanged"
570565
assertContains "pod/pod-b unchanged"
571566
assertContains "pod/pod-c unchanged"
572-
assertContains "3 resource(s) applied. 0 created, 3 unchanged, 0 configured, 0 failed"
567+
assertContains "4 resource(s) applied. 0 created, 4 unchanged, 0 configured, 0 failed"
573568
wait 2
574569
# Validate resources in the cluster
575570
# ConfigMap inventory with four inventory items.
@@ -602,14 +597,13 @@ echo "[ResourceGroup] Testing basic apply dry-run"
602597
echo "kpt live apply --dry-run e2e/live/testdata/rg-test-case-1b"
603598
cp -f e2e/live/testdata/rg-test-case-1a/Kptfile e2e/live/testdata/rg-test-case-1b
604599
${BIN_DIR}/kpt live apply --dry-run e2e/live/testdata/rg-test-case-1b > $OUTPUT_DIR/status
605-
assertContains "namespace/rg-test-namespace configured (dry-run)"
606-
assertContains "1 resource(s) applied. 0 created, 0 unchanged, 1 configured, 0 failed (dry-run)"
607-
assertContains "pod/pod-b configured (dry-run)"
608-
assertContains "pod/pod-c configured (dry-run)"
609-
assertContains "pod/pod-d created (dry-run)"
610-
assertContains "3 resource(s) applied. 1 created, 0 unchanged, 2 configured, 0 failed (dry-run)"
611-
assertContains "pod/pod-a pruned (dry-run)"
612-
assertContains "1 resource(s) pruned, 0 skipped, 0 failed (dry-run)"
600+
assertContains "namespace/rg-test-namespace configured"
601+
assertContains "pod/pod-b configured"
602+
assertContains "pod/pod-c configured"
603+
assertContains "pod/pod-d created"
604+
assertContains "4 resource(s) applied. 1 created, 0 unchanged, 3 configured, 0 failed"
605+
assertContains "pod/pod-a pruned"
606+
assertContains "1 resource(s) pruned, 0 skipped, 0 failed"
613607
wait 2
614608
# Validate resources in the cluster
615609
# ConfigMap inventory with four inventory items.
@@ -626,11 +620,10 @@ echo "kpt live apply e2e/live/testdata/rg-test-case-1b"
626620
${BIN_DIR}/kpt live apply e2e/live/testdata/rg-test-case-1b > $OUTPUT_DIR/status
627621
assertNotContains "installing inventory ResourceGroup CRD" # CRD already installed
628622
assertContains "namespace/rg-test-namespace unchanged"
629-
assertContains "1 resource(s) applied. 0 created, 1 unchanged, 0 configured, 0 failed"
630623
assertContains "pod/pod-b unchanged"
631624
assertContains "pod/pod-c unchanged"
632625
assertContains "pod/pod-d created"
633-
assertContains "3 resource(s) applied. 1 created, 2 unchanged, 0 configured, 0 failed"
626+
assertContains "4 resource(s) applied. 1 created, 3 unchanged, 0 configured, 0 failed"
634627
assertContains "pod/pod-a pruned"
635628
assertContains "1 resource(s) pruned, 0 skipped, 0 failed"
636629
wait 2
@@ -647,12 +640,11 @@ printResult
647640
echo "[ResourceGroup] Testing basic destroy dry-run"
648641
echo "kpt live destroy --dry-run e2e/live/testdata/rg-test-case-1b"
649642
${BIN_DIR}/kpt live destroy --dry-run e2e/live/testdata/rg-test-case-1b > $OUTPUT_DIR/status
650-
assertContains "pod/pod-d deleted (dry-run)"
651-
assertContains "pod/pod-c deleted (dry-run)"
652-
assertContains "pod/pod-b deleted (dry-run)"
653-
assertContains "3 resource(s) deleted, 0 skipped (dry-run)"
654-
assertContains "namespace/rg-test-namespace deleted (dry-run)"
655-
assertContains "1 resource(s) deleted, 0 skipped (dry-run)"
643+
assertContains "pod/pod-d deleted"
644+
assertContains "pod/pod-c deleted"
645+
assertContains "pod/pod-b deleted"
646+
assertContains "namespace/rg-test-namespace deleted"
647+
assertContains "4 resource(s) deleted, 0 skipped"
656648
# Validate resources NOT DESTROYED in the cluster
657649
assertPodExists "pod-b" "rg-test-namespace"
658650
assertPodExists "pod-c" "rg-test-namespace"
@@ -667,9 +659,8 @@ ${BIN_DIR}/kpt live destroy e2e/live/testdata/rg-test-case-1b > $OUTPUT_DIR/stat
667659
assertContains "pod/pod-d deleted"
668660
assertContains "pod/pod-c deleted"
669661
assertContains "pod/pod-b deleted"
670-
assertContains "3 resource(s) deleted, 0 skipped"
671662
assertContains "namespace/rg-test-namespace deleted"
672-
assertContains "1 resource(s) deleted, 0 skipped"
663+
assertContains "4 resource(s) deleted, 0 skipped"
673664
# Validate resources NOT in the cluster
674665
assertPodNotExists "pod-b" "rg-test-namespace"
675666
assertPodNotExists "pod-c" "rg-test-namespace"
@@ -684,7 +675,7 @@ cat e2e/live/testdata/stdin-test/pods.yaml | ${BIN_DIR}/kpt live apply - > $OUTP
684675
assertContains "pod/pod-a created"
685676
assertContains "pod/pod-b created"
686677
assertContains "pod/pod-c created"
687-
assertContains "3 resource(s) applied. 3 created, 0 unchanged, 0 configured, 0 failed"
678+
assertContains "4 resource(s) applied. 3 created, 1 unchanged, 0 configured, 0 failed"
688679
printResult
689680
echo "cat e2e/live/testdata/stdin-test/pods.yaml | kpt live status -"
690681
cat e2e/live/testdata/stdin-test/pods.yaml | ${BIN_DIR}/kpt live status - > $OUTPUT_DIR/status 2>&1
@@ -698,7 +689,7 @@ cat e2e/live/testdata/stdin-test/pods.yaml | ${BIN_DIR}/kpt live destroy - > $OU
698689
assertContains "pod/pod-a deleted"
699690
assertContains "pod/pod-b deleted"
700691
assertContains "pod/pod-c deleted"
701-
assertContains "3 resource(s) deleted, 0 skipped"
692+
assertContains "4 resource(s) deleted, 0 skipped"
702693
printResult
703694

704695
# Test: kpt live apply continue-on-error
@@ -829,11 +820,10 @@ echo "kpt live apply e2e/live/testdata/migrate-case-1b"
829820
cp -f e2e/live/testdata/migrate-case-1a/Kptfile e2e/live/testdata/migrate-case-1b
830821
${BIN_DIR}/kpt live apply e2e/live/testdata/migrate-case-1b > $OUTPUT_DIR/status
831822
assertContains "namespace/test-rg-namespace unchanged"
832-
assertContains "1 resource(s) applied. 0 created, 1 unchanged, 0 configured, 0 failed"
833823
assertContains "pod/pod-b unchanged"
834824
assertContains "pod/pod-c unchanged"
835825
assertContains "pod/pod-d created"
836-
assertContains "3 resource(s) applied. 1 created, 2 unchanged, 0 configured, 0 failed"
826+
assertContains "4 resource(s) applied. 1 created, 3 unchanged, 0 configured, 0 failed"
837827
assertContains "pod/pod-a pruned"
838828
assertContains "1 resource(s) pruned, 0 skipped, 0 failed"
839829
wait 2

e2e/testdata/live-apply/apply-depends-on/config.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
parallel: true
1616

1717
kptArgs:
18-
- "--reconcile-timeout=1m"
18+
- "--reconcile-timeout=2m"
1919

2020
stdOut: |
2121
deployment.apps/first-nginx created
22-
1 resource(s) applied. 1 created, 0 unchanged, 0 configured, 0 failed
22+
deployment.apps/first-nginx reconcile pending
23+
deployment.apps/first-nginx reconciled
2324
deployment.apps/second-nginx created
24-
1 resource(s) applied. 1 created, 0 unchanged, 0 configured, 0 failed
25+
2 resource(s) applied. 2 created, 0 unchanged, 0 configured, 0 failed
26+
deployment.apps/second-nginx reconcile pending
27+
deployment.apps/second-nginx reconciled
28+
2 resource(s) reconciled, 0 skipped, 0 failed to reconcile, 0 timed out
2529
2630
inventory:
2731
- group: apps

e2e/testdata/live-apply/crd-and-cr/config.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ kptArgs:
1919

2020
stdOut: |
2121
customresourcedefinition.apiextensions.k8s.io/customs.kpt.dev created
22-
1 resource(s) applied. 1 created, 0 unchanged, 0 configured, 0 failed
22+
customresourcedefinition.apiextensions.k8s.io/customs.kpt.dev reconcile pending
23+
customresourcedefinition.apiextensions.k8s.io/customs.kpt.dev reconciled
2324
custom.kpt.dev/cr created
24-
1 resource(s) applied. 1 created, 0 unchanged, 0 configured, 0 failed
25+
2 resource(s) applied. 2 created, 0 unchanged, 0 configured, 0 failed
26+
custom.kpt.dev/cr reconcile pending
27+
custom.kpt.dev/cr reconciled
28+
2 resource(s) reconciled, 0 skipped, 0 failed to reconcile, 0 timed out
2529
inventory:
2630
- group: apiextensions.k8s.io
2731
kind: CustomResourceDefinition

e2e/testdata/live-apply/dry-run-with-install-rg/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ kptArgs:
1818
- "--dry-run"
1919
- "--install-resource-group"
2020
stdOut: |
21-
deployment.apps/nginx-deployment created (dry-run)
22-
1 resource(s) applied. 1 created, 0 unchanged, 0 configured, 0 failed (dry-run)
21+
deployment.apps/nginx-deployment created
22+
1 resource(s) applied. 1 created, 0 unchanged, 0 configured, 0 failed
2323
stdErr: |
2424
installing inventory ResourceGroup CRD.
2525
exitCode: 0

e2e/testdata/live-apply/json-output/config.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,24 @@
1515
parallel: true
1616
kptArgs:
1717
- "--output=json"
18-
- "--reconcile-timeout=1m"
18+
- "--reconcile-timeout=2m"
1919
stdOut: |
2020
{"eventType":"resourceApplied","group":"","kind":"ConfigMap","name":"cm","namespace":"json-output","operation":"Created","timestamp":"<TIMESTAMP>","type":"apply"}
21-
{"configuredCount":0,"count":1,"createdCount":1,"eventType":"completed","failedCount":0,"serverSideCount":0,"timestamp":"<TIMESTAMP>","type":"apply","unchangedCount":0}
21+
{"eventType":"resourceReconciled","group":"","kind":"ConfigMap","name":"cm","namespace":"json-output","operation":"Pending","timestamp":"<TIMESTAMP>","type":"wait"}
22+
{"eventType":"resourceReconciled","group":"","kind":"ConfigMap","name":"cm","namespace":"json-output","operation":"Reconciled","timestamp":"<TIMESTAMP>","type":"wait"}
2223
{"eventType":"resourceApplied","group":"apps","kind":"Deployment","name":"nginx","namespace":"json-output","operation":"Created","timestamp":"<TIMESTAMP>","type":"apply"}
23-
{"configuredCount":0,"count":1,"createdCount":1,"eventType":"completed","failedCount":0,"serverSideCount":0,"timestamp":"<TIMESTAMP>","type":"apply","unchangedCount":0}
24+
{"configuredCount":0,"count":2,"createdCount":2,"eventType":"completed","failedCount":0,"serverSideCount":0,"timestamp":"<TIMESTAMP>","type":"apply","unchangedCount":0}
25+
{"eventType":"resourceReconciled","group":"apps","kind":"Deployment","name":"nginx","namespace":"json-output","operation":"Pending","timestamp":"<TIMESTAMP>","type":"wait"}
26+
{"eventType":"resourceReconciled","group":"apps","kind":"Deployment","name":"nginx","namespace":"json-output","operation":"Reconciled","timestamp":"<TIMESTAMP>","type":"wait"}
2427
{"eventType":"resourcePruned","group":"apps","kind":"Deployment","name":"second-nginx","namespace":"json-output","operation":"Pruned","timestamp":"<TIMESTAMP>","type":"prune"}
25-
{"eventType":"completed","pruned":1,"skipped":0,"timestamp":"<TIMESTAMP>","type":"prune"}
28+
{"eventType":"resourceReconciled","group":"apps","kind":"Deployment","name":"second-nginx","namespace":"json-output","operation":"Pending","timestamp":"<TIMESTAMP>","type":"wait"}
29+
{"eventType":"resourceReconciled","group":"apps","kind":"Deployment","name":"second-nginx","namespace":"json-output","operation":"Reconciled","timestamp":"<TIMESTAMP>","type":"wait"}
2630
{"eventType":"resourcePruned","group":"apps","kind":"Deployment","name":"first-nginx","namespace":"json-output","operation":"Pruned","timestamp":"<TIMESTAMP>","type":"prune"}
27-
{"eventType":"completed","pruned":1,"skipped":0,"timestamp":"<TIMESTAMP>","type":"prune"}
31+
{"eventType":"completed","failed":0,"pruned":2,"skipped":0,"timestamp":"<TIMESTAMP>","type":"prune"}
32+
{"eventType":"resourceReconciled","group":"apps","kind":"Deployment","name":"first-nginx","namespace":"json-output","operation":"Pending","timestamp":"<TIMESTAMP>","type":"wait"}
33+
{"eventType":"resourceReconciled","group":"apps","kind":"Deployment","name":"first-nginx","namespace":"json-output","operation":"Reconciled","timestamp":"<TIMESTAMP>","type":"wait"}
34+
{"eventType":"completed","failed":0,"reconciled":4,"skipped":0,"timeout":0,"timestamp":"<TIMESTAMP>","type":"wait"}
35+
2836
inventory:
2937
- kind: ConfigMap
3038
name: cm

e2e/testdata/live-apply/prune-depends-on/config.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,17 @@ kptArgs:
2020
stdOut: |
2121
configmap/cm created
2222
1 resource(s) applied. 1 created, 0 unchanged, 0 configured, 0 failed
23+
configmap/cm reconcile pending
24+
configmap/cm reconciled
2325
deployment.apps/second-nginx pruned
24-
1 resource(s) pruned, 0 skipped, 0 failed
26+
deployment.apps/second-nginx reconcile pending
27+
deployment.apps/second-nginx reconciled
2528
deployment.apps/first-nginx pruned
26-
1 resource(s) pruned, 0 skipped, 0 failed
29+
2 resource(s) pruned, 0 skipped, 0 failed to prune
30+
deployment.apps/first-nginx reconcile pending
31+
deployment.apps/first-nginx reconciled
32+
3 resource(s) reconciled, 0 skipped, 0 failed to reconcile, 0 timed out
33+
2734
inventory:
2835
- kind: ConfigMap
2936
name: cm

go.mod

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@ require (
1414
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca
1515
golang.org/x/mod v0.5.1
1616
gotest.tools v2.2.0+incompatible
17-
k8s.io/api v0.22.3
17+
k8s.io/api v0.22.3 // indirect
1818
k8s.io/apiextensions-apiserver v0.22.2
1919
k8s.io/apimachinery v0.22.3
2020
k8s.io/cli-runtime v0.22.2
2121
k8s.io/client-go v0.22.2
2222
k8s.io/klog/v2 v2.10.0
2323
k8s.io/kube-openapi v0.0.0-20211109043139-026bd182f079 // indirect
2424
k8s.io/kubectl v0.22.2
25-
k8s.io/utils v0.0.0-20210820185131-d34e5cb4466e
26-
sigs.k8s.io/cli-utils v0.26.1-0.20220108032703-d7d63f4b6289
25+
sigs.k8s.io/cli-utils v0.26.1-0.20220111001916-0c9b214db384
2726
sigs.k8s.io/kustomize/api v0.8.11
2827
sigs.k8s.io/kustomize/kyaml v0.13.1-0.20211203194734-cd2c6a1ad117
2928
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,8 +1022,8 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
10221022
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
10231023
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
10241024
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.22/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
1025-
sigs.k8s.io/cli-utils v0.26.1-0.20220108032703-d7d63f4b6289 h1:4kv1Ge3sdzNPT96uRa5zU+vNczErzkoQYanbQmRgn60=
1026-
sigs.k8s.io/cli-utils v0.26.1-0.20220108032703-d7d63f4b6289/go.mod h1:8ll2fyx+bzjbwmwUnKBQU+2LDbMDsxy44DiDZ+drALg=
1025+
sigs.k8s.io/cli-utils v0.26.1-0.20220111001916-0c9b214db384 h1:wElBbmlm1HWOxmnn1YWf0hR6BLrFFkszKCBfOWDDYv0=
1026+
sigs.k8s.io/cli-utils v0.26.1-0.20220111001916-0c9b214db384/go.mod h1:8ll2fyx+bzjbwmwUnKBQU+2LDbMDsxy44DiDZ+drALg=
10271027
sigs.k8s.io/controller-runtime v0.10.1 h1:+eLHgY/VrJWnfg6iXUqhCUqNXgPH1NZeP9drNAAgWlg=
10281028
sigs.k8s.io/controller-runtime v0.10.1/go.mod h1:CQp8eyUQZ/Q7PJvnIrB6/hgfTC1kBkGylwsLgOQi1WY=
10291029
sigs.k8s.io/kustomize/api v0.8.11 h1:LzQzlq6Z023b+mBtc6v72N2mSHYmN8x7ssgbf/hv0H8=

internal/cmdapply/cmdapply.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ import (
2525
"github.com/GoogleContainerTools/kpt/internal/util/argutil"
2626
"github.com/GoogleContainerTools/kpt/internal/util/strings"
2727
"github.com/GoogleContainerTools/kpt/pkg/live"
28-
"github.com/GoogleContainerTools/kpt/thirdparty/cli-utils/flagutils"
29-
"github.com/GoogleContainerTools/kpt/thirdparty/cli-utils/printers"
3028
"github.com/spf13/cobra"
3129
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3230
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3331
"k8s.io/cli-runtime/pkg/genericclioptions"
3432
"k8s.io/kubectl/pkg/cmd/util"
33+
"sigs.k8s.io/cli-utils/cmd/flagutils"
3534
"sigs.k8s.io/cli-utils/pkg/apply"
3635
"sigs.k8s.io/cli-utils/pkg/common"
3736
"sigs.k8s.io/cli-utils/pkg/inventory"
37+
"sigs.k8s.io/cli-utils/pkg/printers"
3838
)
3939

4040
// NewRunner returns a command runner
@@ -80,6 +80,8 @@ func NewRunner(ctx context.Context, factory util.Factory,
8080
"If true, install the inventory ResourceGroup CRD before applying.")
8181
c.Flags().BoolVar(&r.dryRun, "dry-run", false,
8282
"dry-run apply for the resources in the package.")
83+
c.Flags().BoolVar(&r.printStatusEvents, "status-events", false,
84+
"Print status events (always enabled for table output)")
8385
return r
8486
}
8587

@@ -105,6 +107,7 @@ type Runner struct {
105107
pruneTimeout time.Duration
106108
inventoryPolicyString string
107109
dryRun bool
110+
printStatusEvents bool
108111

109112
inventoryPolicy inventory.InventoryPolicy
110113
prunePropPolicy v1.DeletionPropagation
@@ -226,8 +229,17 @@ func runApply(r *Runner, invInfo inventory.InventoryInfo, objs []*unstructured.U
226229
InventoryPolicy: r.inventoryPolicy,
227230
})
228231

232+
// Print the preview strategy unless the output format is json.
233+
if dryRunStrategy.ClientOrServerDryRun() && r.output != printers.JSONPrinter {
234+
if dryRunStrategy.ServerDryRun() {
235+
fmt.Println("Dry-run strategy: server")
236+
} else {
237+
fmt.Println("Dry-run strategy: client")
238+
}
239+
}
240+
229241
// The printer will print updates from the channel. It will block
230242
// until the channel is closed.
231243
printer := printers.GetPrinter(r.output, r.ioStreams)
232-
return printer.Print(ch, dryRunStrategy)
244+
return printer.Print(ch, dryRunStrategy, r.printStatusEvents)
233245
}

0 commit comments

Comments
 (0)