Merge pull request #570 from karlkfi/karl-operations

feat: improve event status consistency
This commit is contained in:
Kubernetes Prow Robot 2022-04-14 09:28:47 -07:00 committed by GitHub
commit 5d06234969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
60 changed files with 1275 additions and 996 deletions

View File

@ -117,11 +117,10 @@ Destroy one service and make sure that only that service is destroyed and clean-
```
kapply destroy $BASE/wordpress | tee $OUTPUT/status;
expectedOutputLine "service/wordpress deleted"
expectedOutputLine "deployment.apps/wordpress deleted"
expectedOutputLine "2 resource(s) deleted, 0 skipped"
expectedOutputLine "service/wordpress delete successful"
expectedOutputLine "deployment.apps/wordpress delete successful"
expectedOutputLine "delete result: 2 attempted, 2 successful, 0 skipped, 0 failed"
expectedOutputLine "reconcile result: 2 attempted, 2 successful, 0 skipped, 0 failed, 0 timed out"
# Verify that we still have the mysql resources in the cluster.
kubectl get all --no-headers --selector=app=mysql | wc -l | xargs | tee $OUTPUT/status

View File

@ -174,11 +174,11 @@ Run preview to check which commands will be executed
```
kapply preview $BASE | tee $OUTPUT/status
expectedOutputLine "3 resource(s) applied. 3 created, 0 unchanged, 0 configured, 0 failed"
expectedOutputLine "apply result: 3 attempted, 3 successful, 0 skipped, 0 failed"
kapply preview $BASE --server-side | tee $OUTPUT/status
expectedOutputLine "3 resource(s) applied. 0 created, 0 unchanged, 0 configured, 0 failed, 3 serverside applied"
expectedOutputLine "apply result: 3 attempted, 3 successful, 0 skipped, 0 failed"
# Verify that preview didn't create any resources.
kubectl get all -n hellospace 2>&1 | tee $OUTPUT/status
@ -222,7 +222,7 @@ kapply apply $BASE --reconcile-timeout=120s --status-events | tee $OUTPUT/status
expectedOutputLine "configmap/the-map2 is Current: Resource is always ready"
expectedOutputLine "configmap/the-map1 pruned"
expectedOutputLine "configmap/the-map1 prune successful"
# Verify that the new configmap has been created and the old one pruned.
kubectl get cm -n hellospace --no-headers | awk '{print $1}' | tee $OUTPUT/status
@ -235,19 +235,17 @@ Clean-up the cluster
```
kapply preview $BASE --destroy | tee $OUTPUT/status
expectedOutputLine "deployment.apps/the-deployment deleted"
expectedOutputLine "configmap/the-map2 deleted"
expectedOutputLine "service/the-service deleted"
expectedOutputLine "deployment.apps/the-deployment delete successful"
expectedOutputLine "configmap/the-map2 delete successful"
expectedOutputLine "service/the-service delete successful"
expectedOutputLine "delete result: 3 attempted, 3 successful, 0 skipped, 0 failed"
kapply preview $BASE --destroy --server-side | tee $OUTPUT/status
expectedOutputLine "deployment.apps/the-deployment deleted"
expectedOutputLine "configmap/the-map2 deleted"
expectedOutputLine "service/the-service deleted"
expectedOutputLine "deployment.apps/the-deployment delete successful"
expectedOutputLine "configmap/the-map2 delete successful"
expectedOutputLine "service/the-service delete successful"
expectedOutputLine "delete result: 3 attempted, 3 successful, 0 skipped, 0 failed"
# Verify that preview all resources are still there after running preview.
kubectl get --no-headers all -n hellospace | wc -l | xargs | tee $OUTPUT/status
@ -255,14 +253,12 @@ expectedOutputLine "6"
kapply destroy $BASE | tee $OUTPUT/status;
expectedOutputLine "deployment.apps/the-deployment deleted"
expectedOutputLine "configmap/the-map2 deleted"
expectedOutputLine "service/the-service deleted"
expectedOutputLine "3 resource(s) deleted, 0 skipped"
expectedNotFound "resource(s) pruned"
expectedOutputLine "deployment.apps/the-deployment delete successful"
expectedOutputLine "configmap/the-map2 delete successful"
expectedOutputLine "service/the-service delete successful"
expectedOutputLine "delete result: 3 attempted, 3 successful, 0 skipped, 0 failed"
expectedOutputLine "reconcile result: 3 attempted, 3 successful, 0 skipped, 0 failed, 0 timed out"
expectedNotFound "prune result"
kind delete cluster;
```

View File

@ -93,9 +93,10 @@ test-namespace is created first, so the following resources within the namespace
<!-- @runApply @testE2EAgainstLatestRelease -->
```
kapply apply $BASE --reconcile-timeout=1m | tee $OUTPUT/status
expectedOutputLine "namespace/test-namespace unchanged"
expectedOutputLine "configmap/cm-a created"
expectedOutputLine "2 resource(s) applied. 1 created, 1 unchanged, 0 configured"
expectedOutputLine "namespace/test-namespace apply successful"
expectedOutputLine "configmap/cm-a apply successful"
expectedOutputLine "apply result: 2 attempted, 2 successful, 0 skipped, 0 failed"
expectedOutputLine "reconcile result: 2 attempted, 2 successful, 0 skipped, 0 failed, 0 timed out"
# There should be only one inventory object
kubectl get cm -n test-namespace --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers | wc -l | tee $OUTPUT/status
@ -119,7 +120,8 @@ that the subsequent apply does not prune this omitted namespace.
```
rm -f $BASE/test-namespace.yaml
kapply apply $BASE --reconcile-timeout=1m | tee $OUTPUT/status
expectedOutputLine "0 resource(s) pruned, 1 skipped"
expectedOutputLine "prune result: 1 attempted, 0 successful, 1 skipped, 0 failed"
expectedOutputLine "reconcile result: 1 attempted, 0 successful, 1 skipped, 0 failed, 0 timed out"
# Inventory namespace should still exist
kubectl get ns test-namespace --no-headers | wc -l | tee $OUTPUT/status

View File

@ -134,8 +134,8 @@ Apply the three resources to the cluster.
```
kapply apply $BASE --reconcile-timeout=1m | tee $OUTPUT/status
expectedOutputLine "3 resource(s) applied. 3 created, 0 unchanged, 0 configured, 0 failed"
expectedOutputLine "3 resource(s) reconciled, 0 skipped, 0 failed to reconcile, 0 timed out"
expectedOutputLine "apply result: 3 attempted, 3 successful, 0 skipped, 0 failed"
expectedOutputLine "reconcile result: 3 attempted, 3 successful, 0 skipped, 0 failed, 0 timed out"
```
Use the preview command to show what will happen if we run destroy. This should
@ -145,10 +145,10 @@ command.
```
kapply preview --destroy $BASE | tee $OUTPUT/status
expectedOutputLine "configmap/firstmap deleted"
expectedOutputLine "configmap/firstmap delete successful"
expectedOutputLine 'configmap/secondmap delete skipped: annotation prevents deletion ("cli-utils.sigs.k8s.io/on-remove": "keep")'
expectedOutputLine 'configmap/thirdmap delete skipped: annotation prevents deletion ("client.lifecycle.config.k8s.io/deletion": "detach")'
expectedOutputLine "1 resource(s) deleted, 2 skipped"
expectedOutputLine "delete result: 3 attempted, 1 successful, 2 skipped, 0 failed"
```
We run the destroy command and see that the resource without the annotations (firstmap)
@ -158,17 +158,15 @@ cluster.
```
kapply destroy $BASE | tee $OUTPUT/status
expectedOutputLine "configmap/firstmap deleted"
expectedOutputLine "configmap/firstmap delete successful"
expectedOutputLine 'configmap/secondmap delete skipped: annotation prevents deletion ("cli-utils.sigs.k8s.io/on-remove": "keep")'
expectedOutputLine 'configmap/thirdmap delete skipped: annotation prevents deletion ("client.lifecycle.config.k8s.io/deletion": "detach")'
expectedOutputLine "1 resource(s) deleted, 2 skipped"
expectedOutputLine "configmap/firstmap reconciled"
expectedOutputLine "configmap/firstmap reconcile successful"
expectedOutputLine "configmap/secondmap reconcile skipped"
expectedOutputLine "configmap/thirdmap reconcile skipped"
expectedOutputLine "1 resource(s) reconciled, 2 skipped, 0 failed to reconcile, 0 timed out"
expectedNotFound "resource(s) pruned"
expectedOutputLine "delete result: 3 attempted, 1 successful, 2 skipped, 0 failed"
expectedOutputLine "reconcile result: 3 attempted, 1 successful, 2 skipped, 0 failed, 0 timed out"
expectedNotFound "prune result"
kubectl get cm --no-headers | awk '{print $1}' | tee $OUTPUT/status
expectedOutputLine "secondmap"

View File

@ -102,9 +102,11 @@ no resources should be pruned.
<!-- @runApply @testE2EAgainstLatestRelease -->
```
kapply apply $BASE --reconcile-timeout=1m | tee $OUTPUT/status
expectedOutputLine "configmap/cm-a created"
expectedOutputLine "configmap/cm-b created"
expectedOutputLine "configmap/cm-c created"
expectedOutputLine "configmap/cm-a apply successful"
expectedOutputLine "configmap/cm-b apply successful"
expectedOutputLine "configmap/cm-c apply successful"
expectedOutputLine "apply result: 3 attempted, 3 successful, 0 skipped, 0 failed"
expectedOutputLine "reconcile result: 3 attempted, 3 successful, 0 skipped, 0 failed, 0 timed out"
# There should be only one inventory object
kubectl get cm --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers | wc -l | tee $OUTPUT/status
@ -154,11 +156,13 @@ cm-d should be created.
<!-- @applySecondTime @testE2EAgainstLatestRelease -->
```
kapply apply $BASE --reconcile-timeout=1m | tee $OUTPUT/status
expectedOutputLine "configmap/cm-a pruned"
expectedOutputLine "configmap/cm-b unchanged"
expectedOutputLine "configmap/cm-c unchanged"
expectedOutputLine "configmap/cm-d created"
expectedOutputLine "1 resource(s) pruned, 0 skipped"
expectedOutputLine "configmap/cm-a prune successful"
expectedOutputLine "configmap/cm-b apply successful"
expectedOutputLine "configmap/cm-c apply successful"
expectedOutputLine "configmap/cm-d apply successful"
expectedOutputLine "apply result: 3 attempted, 3 successful, 0 skipped, 0 failed"
expectedOutputLine "prune result: 1 attempted, 1 successful, 0 skipped, 0 failed"
expectedOutputLine "reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out"
# There should be only one inventory object
kubectl get cm --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers | wc -l | tee $OUTPUT/status

View File

@ -116,11 +116,12 @@ no resources should be pruned.
<!-- @runApply @testE2EAgainstLatestRelease -->
```
kapply apply $BASE --reconcile-timeout=1m | tee $OUTPUT/status
expectedOutputLine "namespace/test-namespace created"
expectedOutputLine "configmap/cm-a created"
expectedOutputLine "configmap/cm-b created"
expectedOutputLine "configmap/cm-c created"
expectedOutputLine "4 resource(s) applied. 4 created, 0 unchanged, 0 configured"
expectedOutputLine "namespace/test-namespace apply successful"
expectedOutputLine "configmap/cm-a apply successful"
expectedOutputLine "configmap/cm-b apply successful"
expectedOutputLine "configmap/cm-c apply successful"
expectedOutputLine "apply result: 4 attempted, 4 successful, 0 skipped, 0 failed"
expectedOutputLine "reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out"
# There should be only one inventory object
kubectl get cm --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers | wc -l | tee $OUTPUT/status
@ -172,19 +173,20 @@ test-namespace should **not** be pruned.
kapply apply $BASE --reconcile-timeout=1m | tee $OUTPUT/status
expectedOutputLine "configmap/cm-c apply skipped: dependency scheduled for delete: _test-namespace__Namespace"
expectedOutputLine "1 resource(s) applied. 0 created, 1 unchanged, 0 configured, 0 failed"
expectedOutputLine "configmap/cm-c reconcile skipped"
expectedOutputLine "configmap/cm-a pruned"
expectedOutputLine "configmap/cm-b pruned"
expectedOutputLine "configmap/cm-a prune successful"
expectedOutputLine "configmap/cm-b prune successful"
expectedOutputLine "namespace/test-namespace prune skipped: namespace still in use: test-namespace"
expectedOutputLine "2 resource(s) pruned, 1 skipped, 0 failed to prune"
expectedOutputLine "namespace/test-namespace reconcile skipped"
expectedOutputLine "configmap/cm-a reconciled"
expectedOutputLine "configmap/cm-b reconciled"
expectedOutputLine "configmap/cm-a reconcile successful"
expectedOutputLine "configmap/cm-b reconcile successful"
expectedOutputLine "configmap/cm-c reconcile skipped"
expectedOutputLine "2 resource(s) reconciled, 2 skipped, 0 failed to reconcile, 0 timed out"
expectedOutputLine "apply result: 1 attempted, 0 successful, 1 skipped, 0 failed"
expectedOutputLine "prune result: 3 attempted, 2 successful, 1 skipped, 0 failed"
expectedOutputLine "reconcile result: 4 attempted, 2 successful, 2 skipped, 0 failed, 0 timed out"
# The test-namespace should not be pruned.
kubectl get ns test-namespace --no-headers | wc -l | tee $OUTPUT/status

View File

@ -93,9 +93,10 @@ no resources should be pruned.
<!-- @runServerSideApply @testE2EAgainstLatestRelease -->
```
kapply apply $BASE --server-side --reconcile-timeout=1m | tee $OUTPUT/status
expectedOutputLine "configmap/cm-a serversideapplied"
expectedOutputLine "configmap/cm-b serversideapplied"
expectedOutputLine "2 serverside applied"
expectedOutputLine "configmap/cm-a apply successful"
expectedOutputLine "configmap/cm-b apply successful"
expectedOutputLine "apply result: 2 attempted, 2 successful, 0 skipped, 0 failed"
expectedOutputLine "reconcile result: 2 attempted, 2 successful, 0 skipped, 0 failed, 0 timed out"
# There should be only one inventory object
kubectl get cm --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers | wc -l | tee $OUTPUT/status
@ -129,7 +130,8 @@ data:
EOF
kapply apply $BASE --server-side --field-manager=sean --force-conflicts --reconcile-timeout=1m | tee $OUTPUT/status
expectedOutputLine "configmap/cm-a serversideapplied"
expectedOutputLine "configmap/cm-b serversideapplied"
expectedOutputLine "2 serverside applied"
expectedOutputLine "configmap/cm-a apply successful"
expectedOutputLine "configmap/cm-b apply successful"
expectedOutputLine "apply result: 2 attempted, 2 successful, 0 skipped, 0 failed"
expectedOutputLine "reconcile result: 2 attempted, 2 successful, 0 skipped, 0 failed, 0 timed out"
```

View File

@ -158,7 +158,7 @@ func TestApplier(t *testing.T) {
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created, // Create new
Status: event.ApplySuccessful, // Create new
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -182,7 +182,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -316,7 +316,7 @@ func TestApplier(t *testing.T) {
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created, // Create new
Status: event.ApplySuccessful, // Create new
Identifier: testutil.ToIdentifier(t, resources["secret"]),
},
},
@ -324,7 +324,7 @@ func TestApplier(t *testing.T) {
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created, // Create new
Status: event.ApplySuccessful, // Create new
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -349,7 +349,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: testutil.ToIdentifier(t, resources["secret"]),
},
},
@ -357,7 +357,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -366,7 +366,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -374,7 +374,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: testutil.ToIdentifier(t, resources["secret"]),
},
},
@ -497,7 +497,7 @@ func TestApplier(t *testing.T) {
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created, // Create new
Status: event.ApplySuccessful, // Create new
Identifier: testutil.ToIdentifier(t, resources["secret"]),
},
},
@ -505,7 +505,7 @@ func TestApplier(t *testing.T) {
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Configured, // Update existing
Status: event.ApplySuccessful, // Update existing
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -530,7 +530,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: testutil.ToIdentifier(t, resources["secret"]),
},
},
@ -538,7 +538,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -547,7 +547,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -555,7 +555,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: testutil.ToIdentifier(t, resources["secret"]),
},
},
@ -703,7 +703,7 @@ func TestApplier(t *testing.T) {
EventType: event.PruneType,
PruneEvent: &testutil.ExpPruneEvent{
GroupName: "prune-0",
Operation: event.Pruned,
Status: event.PruneSuccessful,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -711,7 +711,7 @@ func TestApplier(t *testing.T) {
EventType: event.PruneType,
PruneEvent: &testutil.ExpPruneEvent{
GroupName: "prune-0",
Operation: event.Pruned,
Status: event.PruneSuccessful,
Identifier: testutil.ToIdentifier(t, resources["secret"]),
},
},
@ -736,7 +736,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -744,7 +744,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: testutil.ToIdentifier(t, resources["secret"]),
},
},
@ -753,7 +753,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -761,7 +761,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: testutil.ToIdentifier(t, resources["secret"]),
},
},
@ -875,7 +875,7 @@ func TestApplier(t *testing.T) {
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
Operation: event.Unchanged,
Status: event.ApplySkipped,
Error: &inventory.PolicyPreventedActuationError{
Strategy: actuation.ActuationStrategyApply,
Policy: inventory.PolicyMustMatch,
@ -903,7 +903,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -986,7 +986,7 @@ func TestApplier(t *testing.T) {
EventType: event.PruneType,
PruneEvent: &testutil.ExpPruneEvent{
GroupName: "prune-0",
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
Error: &inventory.PolicyPreventedActuationError{
Strategy: actuation.ActuationStrategyDelete,
@ -1015,7 +1015,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -1130,7 +1130,7 @@ func TestApplier(t *testing.T) {
EventType: event.PruneType,
PruneEvent: &testutil.ExpPruneEvent{
GroupName: "prune-0",
Operation: event.Pruned,
Status: event.PruneSuccessful,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -1154,7 +1154,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -1162,7 +1162,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -1309,7 +1309,7 @@ func TestApplier(t *testing.T) {
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created, // Create new
Status: event.ApplySuccessful, // Create new
Identifier: testutil.ToIdentifier(t, resources["secret"]),
},
},
@ -1334,7 +1334,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: testutil.ToIdentifier(t, resources["secret"]),
},
},
@ -1343,7 +1343,7 @@ func TestApplier(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: testutil.ToIdentifier(t, resources["secret"]),
},
},
@ -1484,7 +1484,7 @@ func TestApplier(t *testing.T) {
break loop
}
if e.Type == event.ActionGroupType &&
e.ActionGroupEvent.Type == event.Finished {
e.ActionGroupEvent.Status == event.Finished {
// Send events after the first apply/prune task ends
if e.ActionGroupEvent.Action == event.ApplyAction ||
e.ActionGroupEvent.Action == event.PruneAction {
@ -1642,7 +1642,7 @@ func TestApplierCancel(t *testing.T) {
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -1670,7 +1670,7 @@ func TestApplierCancel(t *testing.T) {
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// Deployment never becomes Current.
@ -1807,7 +1807,7 @@ func TestApplierCancel(t *testing.T) {
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -1835,7 +1835,7 @@ func TestApplierCancel(t *testing.T) {
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
{
@ -1844,7 +1844,7 @@ func TestApplierCancel(t *testing.T) {
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
{
@ -1922,7 +1922,7 @@ func TestApplierCancel(t *testing.T) {
events = append(events, e)
if e.Type == event.ActionGroupType &&
e.ActionGroupEvent.Type == event.Finished {
e.ActionGroupEvent.Status == event.Finished {
// Send events after the first apply/prune task ends
if e.ActionGroupEvent.Action == event.ApplyAction ||
e.ActionGroupEvent.Action == event.PruneAction {

View File

@ -108,7 +108,7 @@ func TestDestroyerCancel(t *testing.T) {
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-0",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
Error: nil,
},
@ -136,7 +136,7 @@ func TestDestroyerCancel(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -236,7 +236,7 @@ func TestDestroyerCancel(t *testing.T) {
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-0",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
Error: nil,
},
@ -264,7 +264,7 @@ func TestDestroyerCancel(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},
@ -273,7 +273,7 @@ func TestDestroyerCancel(t *testing.T) {
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: testutil.ToIdentifier(t, resources["deployment"]),
},
},

View File

@ -0,0 +1,24 @@
// Code generated by "stringer -type=ActionGroupEventStatus"; DO NOT EDIT.
package event
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[Started-0]
_ = x[Finished-1]
}
const _ActionGroupEventStatus_name = "StartedFinished"
var _ActionGroupEventStatus_index = [...]uint8{0, 7, 15}
func (i ActionGroupEventStatus) String() string {
if i < 0 || i >= ActionGroupEventStatus(len(_ActionGroupEventStatus_index)-1) {
return "ActionGroupEventStatus(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _ActionGroupEventStatus_name[_ActionGroupEventStatus_index[i]:_ActionGroupEventStatus_index[i+1]]
}

View File

@ -1,24 +0,0 @@
// Code generated by "stringer -type=ActionGroupEventType"; DO NOT EDIT.
package event
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[Started-0]
_ = x[Finished-1]
}
const _ActionGroupEventType_name = "StartedFinished"
var _ActionGroupEventType_index = [...]uint8{0, 7, 15}
func (i ActionGroupEventType) String() string {
if i < 0 || i >= ActionGroupEventType(len(_ActionGroupEventType_index)-1) {
return "ActionGroupEventType(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _ActionGroupEventType_name[_ActionGroupEventType_index[i]:_ActionGroupEventType_index[i+1]]
}

View File

@ -1,27 +0,0 @@
// Code generated by "stringer -type=ApplyEventOperation"; DO NOT EDIT.
package event
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[ApplyUnspecified-0]
_ = x[ServersideApplied-1]
_ = x[Created-2]
_ = x[Unchanged-3]
_ = x[Configured-4]
}
const _ApplyEventOperation_name = "ApplyUnspecifiedServersideAppliedCreatedUnchangedConfigured"
var _ApplyEventOperation_index = [...]uint8{0, 16, 33, 40, 49, 59}
func (i ApplyEventOperation) String() string {
if i < 0 || i >= ApplyEventOperation(len(_ApplyEventOperation_index)-1) {
return "ApplyEventOperation(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _ApplyEventOperation_name[_ApplyEventOperation_index[i]:_ApplyEventOperation_index[i+1]]
}

View File

@ -0,0 +1,26 @@
// Code generated by "stringer -type=ApplyEventStatus -linecomment"; DO NOT EDIT.
package event
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[ApplyPending-0]
_ = x[ApplySuccessful-1]
_ = x[ApplySkipped-2]
_ = x[ApplyFailed-3]
}
const _ApplyEventStatus_name = "PendingSuccessfulSkippedFailed"
var _ApplyEventStatus_index = [...]uint8{0, 7, 17, 24, 30}
func (i ApplyEventStatus) String() string {
if i < 0 || i >= ApplyEventStatus(len(_ApplyEventStatus_index)-1) {
return "ApplyEventStatus(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _ApplyEventStatus_name[_ApplyEventStatus_index[i]:_ApplyEventStatus_index[i+1]]
}

View File

@ -1,25 +0,0 @@
// Code generated by "stringer -type=DeleteEventOperation"; DO NOT EDIT.
package event
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[DeleteUnspecified-0]
_ = x[Deleted-1]
_ = x[DeleteSkipped-2]
}
const _DeleteEventOperation_name = "DeleteUnspecifiedDeletedDeleteSkipped"
var _DeleteEventOperation_index = [...]uint8{0, 17, 24, 37}
func (i DeleteEventOperation) String() string {
if i < 0 || i >= DeleteEventOperation(len(_DeleteEventOperation_index)-1) {
return "DeleteEventOperation(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _DeleteEventOperation_name[_DeleteEventOperation_index[i]:_DeleteEventOperation_index[i+1]]
}

View File

@ -0,0 +1,26 @@
// Code generated by "stringer -type=DeleteEventStatus -linecomment"; DO NOT EDIT.
package event
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[DeletePending-0]
_ = x[DeleteSuccessful-1]
_ = x[DeleteSkipped-2]
_ = x[DeleteFailed-3]
}
const _DeleteEventStatus_name = "PendingSuccessfulSkippedFailed"
var _DeleteEventStatus_index = [...]uint8{0, 7, 17, 24, 30}
func (i DeleteEventStatus) String() string {
if i < 0 || i >= DeleteEventStatus(len(_DeleteEventStatus_index)-1) {
return "DeleteEventStatus(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _DeleteEventStatus_name[_DeleteEventStatus_index[i]:_DeleteEventStatus_index[i+1]]
}

View File

@ -158,72 +158,71 @@ func (ee ErrorEvent) String() string {
return fmt.Sprintf("ErrorEvent{ Err: %q }", ee.Err.Error())
}
//go:generate stringer -type=WaitEventOperation -linecomment
type WaitEventOperation int
//go:generate stringer -type=WaitEventStatus -linecomment
type WaitEventStatus int
const (
ReconcilePending WaitEventOperation = iota // Pending
Reconciled
ReconcileSkipped // Skipped
ReconcileTimeout // Timeout
ReconcileFailed // Failed
ReconcilePending WaitEventStatus = iota // Pending
ReconcileSuccessful // Successful
ReconcileSkipped // Skipped
ReconcileTimeout // Timeout
ReconcileFailed // Failed
)
type WaitEvent struct {
GroupName string
Identifier object.ObjMetadata
Operation WaitEventOperation
Status WaitEventStatus
}
// String returns a string suitable for logging
func (we WaitEvent) String() string {
return fmt.Sprintf("WaitEvent{ GroupName: %q, Operation: %q, Identifier: %q }",
we.GroupName, we.Operation, we.Identifier)
return fmt.Sprintf("WaitEvent{ GroupName: %q, Status: %q, Identifier: %q }",
we.GroupName, we.Status, we.Identifier)
}
//go:generate stringer -type=ActionGroupEventType
type ActionGroupEventType int
//go:generate stringer -type=ActionGroupEventStatus
type ActionGroupEventStatus int
const (
Started ActionGroupEventType = iota
Started ActionGroupEventStatus = iota
Finished
)
type ActionGroupEvent struct {
GroupName string
Action ResourceAction
Type ActionGroupEventType
Status ActionGroupEventStatus
}
// String returns a string suitable for logging
func (age ActionGroupEvent) String() string {
return fmt.Sprintf("ActionGroupEvent{ GroupName: %q, Action: %q, Type: %q }",
age.GroupName, age.Action, age.Type)
age.GroupName, age.Action, age.Status)
}
//go:generate stringer -type=ApplyEventOperation
type ApplyEventOperation int
//go:generate stringer -type=ApplyEventStatus -linecomment
type ApplyEventStatus int
const (
ApplyUnspecified ApplyEventOperation = iota
ServersideApplied
Created
Unchanged
Configured
ApplyPending ApplyEventStatus = iota // Pending
ApplySuccessful // Successful
ApplySkipped // Skipped
ApplyFailed // Failed
)
type ApplyEvent struct {
GroupName string
Identifier object.ObjMetadata
Operation ApplyEventOperation
Status ApplyEventStatus
Resource *unstructured.Unstructured
Error error
}
// String returns a string suitable for logging
func (ae ApplyEvent) String() string {
return fmt.Sprintf("ApplyEvent{ GroupName: %q, Operation: %q, Identifier: %q, Error: %q }",
ae.GroupName, ae.Operation, ae.Identifier, ae.Error)
return fmt.Sprintf("ApplyEvent{ GroupName: %q, Status: %q, Identifier: %q, Error: %q }",
ae.GroupName, ae.Status, ae.Identifier, ae.Error)
}
type StatusEvent struct {
@ -247,50 +246,52 @@ func (se StatusEvent) String() string {
status, gen, se.Identifier, se.Error)
}
//go:generate stringer -type=PruneEventOperation
type PruneEventOperation int
//go:generate stringer -type=PruneEventStatus -linecomment
type PruneEventStatus int
const (
PruneUnspecified PruneEventOperation = iota
Pruned
PruneSkipped
PrunePending PruneEventStatus = iota // Pending
PruneSuccessful // Successful
PruneSkipped // Skipped
PruneFailed // Failed
)
type PruneEvent struct {
GroupName string
Identifier object.ObjMetadata
Operation PruneEventOperation
Status PruneEventStatus
Object *unstructured.Unstructured
Error error
}
// String returns a string suitable for logging
func (pe PruneEvent) String() string {
return fmt.Sprintf("PruneEvent{ GroupName: %q, Operation: %q, Identifier: %q, Error: %q }",
pe.GroupName, pe.Operation, pe.Identifier, pe.Error)
return fmt.Sprintf("PruneEvent{ GroupName: %q, Status: %q, Identifier: %q, Error: %q }",
pe.GroupName, pe.Status, pe.Identifier, pe.Error)
}
//go:generate stringer -type=DeleteEventOperation
type DeleteEventOperation int
//go:generate stringer -type=DeleteEventStatus -linecomment
type DeleteEventStatus int
const (
DeleteUnspecified DeleteEventOperation = iota
Deleted
DeleteSkipped
DeletePending DeleteEventStatus = iota // Pending
DeleteSuccessful // Successful
DeleteSkipped // Skipped
DeleteFailed // Failed
)
type DeleteEvent struct {
GroupName string
Identifier object.ObjMetadata
Operation DeleteEventOperation
Status DeleteEventStatus
Object *unstructured.Unstructured
Error error
}
// String returns a string suitable for logging
func (de DeleteEvent) String() string {
return fmt.Sprintf("DeleteEvent{ GroupName: %q, Operation: %q, Identifier: %q, Error: %q }",
de.GroupName, de.Operation, de.Identifier, de.Error)
return fmt.Sprintf("DeleteEvent{ GroupName: %q, Status: %q, Identifier: %q, Error: %q }",
de.GroupName, de.Status, de.Identifier, de.Error)
}
type ValidationEvent struct {

View File

@ -1,25 +0,0 @@
// Code generated by "stringer -type=PruneEventOperation"; DO NOT EDIT.
package event
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[PruneUnspecified-0]
_ = x[Pruned-1]
_ = x[PruneSkipped-2]
}
const _PruneEventOperation_name = "PruneUnspecifiedPrunedPruneSkipped"
var _PruneEventOperation_index = [...]uint8{0, 16, 22, 34}
func (i PruneEventOperation) String() string {
if i < 0 || i >= PruneEventOperation(len(_PruneEventOperation_index)-1) {
return "PruneEventOperation(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _PruneEventOperation_name[_PruneEventOperation_index[i]:_PruneEventOperation_index[i+1]]
}

View File

@ -0,0 +1,26 @@
// Code generated by "stringer -type=PruneEventStatus -linecomment"; DO NOT EDIT.
package event
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[PrunePending-0]
_ = x[PruneSuccessful-1]
_ = x[PruneSkipped-2]
_ = x[PruneFailed-3]
}
const _PruneEventStatus_name = "PendingSuccessfulSkippedFailed"
var _PruneEventStatus_index = [...]uint8{0, 7, 17, 24, 30}
func (i PruneEventStatus) String() string {
if i < 0 || i >= PruneEventStatus(len(_PruneEventStatus_index)-1) {
return "PruneEventStatus(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _PruneEventStatus_name[_PruneEventStatus_index[i]:_PruneEventStatus_index[i+1]]
}

View File

@ -1,27 +0,0 @@
// Code generated by "stringer -type=WaitEventOperation -linecomment"; DO NOT EDIT.
package event
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[ReconcilePending-0]
_ = x[Reconciled-1]
_ = x[ReconcileSkipped-2]
_ = x[ReconcileTimeout-3]
_ = x[ReconcileFailed-4]
}
const _WaitEventOperation_name = "PendingReconciledSkippedTimeoutFailed"
var _WaitEventOperation_index = [...]uint8{0, 7, 17, 24, 31, 37}
func (i WaitEventOperation) String() string {
if i < 0 || i >= WaitEventOperation(len(_WaitEventOperation_index)-1) {
return "WaitEventOperation(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _WaitEventOperation_name[_WaitEventOperation_index[i]:_WaitEventOperation_index[i+1]]
}

View File

@ -0,0 +1,27 @@
// Code generated by "stringer -type=WaitEventStatus -linecomment"; DO NOT EDIT.
package event
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[ReconcilePending-0]
_ = x[ReconcileSuccessful-1]
_ = x[ReconcileSkipped-2]
_ = x[ReconcileTimeout-3]
_ = x[ReconcileFailed-4]
}
const _WaitEventStatus_name = "PendingSuccessfulSkippedTimeoutFailed"
var _WaitEventStatus_index = [...]uint8{0, 7, 17, 24, 31, 37}
func (i WaitEventStatus) String() string {
if i < 0 || i >= WaitEventStatus(len(_WaitEventStatus_index)-1) {
return "WaitEventStatus(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _WaitEventStatus_name[_WaitEventStatus_index[i]:_WaitEventStatus_index[i+1]]
}

View File

@ -43,7 +43,7 @@ func (pef PruneEventFactory) CreateSuccessEvent(obj *unstructured.Unstructured)
Type: event.PruneType,
PruneEvent: event.PruneEvent{
GroupName: pef.groupName,
Operation: event.Pruned,
Status: event.PruneSuccessful,
Object: obj,
Identifier: object.UnstructuredToObjMetadata(obj),
},
@ -55,7 +55,7 @@ func (pef PruneEventFactory) CreateSkippedEvent(obj *unstructured.Unstructured,
Type: event.PruneType,
PruneEvent: event.PruneEvent{
GroupName: pef.groupName,
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Object: obj,
Identifier: object.UnstructuredToObjMetadata(obj),
Error: err,
@ -85,7 +85,7 @@ func (def DeleteEventFactory) CreateSuccessEvent(obj *unstructured.Unstructured)
Type: event.DeleteType,
DeleteEvent: event.DeleteEvent{
GroupName: def.groupName,
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Object: obj,
Identifier: object.UnstructuredToObjMetadata(obj),
},
@ -97,7 +97,7 @@ func (def DeleteEventFactory) CreateSkippedEvent(obj *unstructured.Unstructured,
Type: event.DeleteType,
DeleteEvent: event.DeleteEvent{
GroupName: def.groupName,
Operation: event.DeleteSkipped,
Status: event.DeleteSkipped,
Object: obj,
Identifier: object.UnstructuredToObjMetadata(obj),
Error: err,

View File

@ -46,16 +46,16 @@ func TestEventFactory(t *testing.T) {
var actualObj *unstructured.Unstructured
var err error
if tc.expectedType == event.PruneType {
if event.Pruned != actualEvent.PruneEvent.Operation {
t.Errorf("success event expected operation (Pruned), got (%s)",
actualEvent.PruneEvent.Operation)
if event.PruneSuccessful != actualEvent.PruneEvent.Status {
t.Errorf("success event expected status (PruneSuccessful), got (%s)",
actualEvent.PruneEvent.Status)
}
actualObj = actualEvent.PruneEvent.Object
err = actualEvent.PruneEvent.Error
} else {
if event.Deleted != actualEvent.DeleteEvent.Operation {
t.Errorf("success event expected operation (Deleted), got (%s)",
actualEvent.DeleteEvent.Operation)
if event.DeleteSuccessful != actualEvent.DeleteEvent.Status {
t.Errorf("success event expected status (DeleteSuccessful), got (%s)",
actualEvent.DeleteEvent.Status)
}
actualObj = actualEvent.DeleteEvent.Object
err = actualEvent.DeleteEvent.Error
@ -73,16 +73,16 @@ func TestEventFactory(t *testing.T) {
tc.expectedType, actualEvent.Type)
}
if tc.expectedType == event.PruneType {
if event.PruneSkipped != actualEvent.PruneEvent.Operation {
t.Errorf("skipped event expected operation (PruneSkipped), got (%s)",
actualEvent.PruneEvent.Operation)
if event.PruneSkipped != actualEvent.PruneEvent.Status {
t.Errorf("skipped event expected status (PruneSkipped), got (%s)",
actualEvent.PruneEvent.Status)
}
actualObj = actualEvent.PruneEvent.Object
err = actualEvent.PruneEvent.Error
} else {
if event.DeleteSkipped != actualEvent.DeleteEvent.Operation {
t.Errorf("skipped event expected operation (DeleteSkipped), got (%s)",
actualEvent.DeleteEvent.Operation)
if event.DeleteSkipped != actualEvent.DeleteEvent.Status {
t.Errorf("skipped event expected status (DeleteSkipped), got (%s)",
actualEvent.DeleteEvent.Status)
}
actualObj = actualEvent.DeleteEvent.Object
err = actualEvent.DeleteEvent.Error

View File

@ -111,19 +111,19 @@ func (p *Pruner) Prune(
// Check filters to see if we're prevented from pruning/deleting object.
var filterErr error
for _, pruneFilter := range pruneFilters {
klog.V(6).Infof("evaluating prune filter %s: %s", pruneFilter.Name(), id)
klog.V(6).Infof("prune filter evaluating (filter: %s, object: %s)", pruneFilter.Name(), id)
filterErr = pruneFilter.Filter(obj)
if filterErr != nil {
var fatalErr *filter.FatalError
if errors.As(filterErr, &fatalErr) {
if klog.V(5).Enabled() {
klog.Errorf("error filtering (object: %q, filter: %q): %v", id, pruneFilter.Name(), fatalErr.Err)
klog.Errorf("prune filter errored (filter: %s, object: %s): %v", pruneFilter.Name(), id, fatalErr.Err)
}
taskContext.SendEvent(eventFactory.CreateFailedEvent(id, fatalErr.Err))
taskContext.InventoryManager().AddFailedDelete(id)
break
}
klog.V(4).Infof("prune filtered (object: %q, filter: %q): %v", id, pruneFilter.Name(), filterErr)
klog.V(4).Infof("prune filtered (filter: %s, object: %s): %v", pruneFilter.Name(), id, filterErr)
// Remove the inventory annotation if deletion was prevented.
// This abandons the object so it won't be pruned by future applier runs.

View File

@ -205,7 +205,7 @@ func TestPrune(t *testing.T) {
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Identifier: object.UnstructuredToObjMetadata(pod),
Operation: event.Pruned,
Status: event.PruneSuccessful,
Object: pod,
},
},
@ -219,7 +219,7 @@ func TestPrune(t *testing.T) {
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Identifier: object.UnstructuredToObjMetadata(pod),
Operation: event.Pruned,
Status: event.PruneSuccessful,
Object: pod,
},
},
@ -227,7 +227,7 @@ func TestPrune(t *testing.T) {
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Identifier: object.UnstructuredToObjMetadata(pdb),
Operation: event.Pruned,
Status: event.PruneSuccessful,
Object: pdb,
},
},
@ -235,7 +235,7 @@ func TestPrune(t *testing.T) {
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Identifier: object.UnstructuredToObjMetadata(namespace),
Operation: event.Pruned,
Status: event.PruneSuccessful,
Object: namespace,
},
},
@ -249,7 +249,7 @@ func TestPrune(t *testing.T) {
Type: event.DeleteType,
DeleteEvent: event.DeleteEvent{
Identifier: object.UnstructuredToObjMetadata(pod),
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Object: pod,
},
},
@ -263,7 +263,7 @@ func TestPrune(t *testing.T) {
Type: event.DeleteType,
DeleteEvent: event.DeleteEvent{
Identifier: object.UnstructuredToObjMetadata(pod),
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Object: pod,
},
},
@ -271,7 +271,7 @@ func TestPrune(t *testing.T) {
Type: event.DeleteType,
DeleteEvent: event.DeleteEvent{
Identifier: object.UnstructuredToObjMetadata(pdb),
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Object: pdb,
},
},
@ -279,7 +279,7 @@ func TestPrune(t *testing.T) {
Type: event.DeleteType,
DeleteEvent: event.DeleteEvent{
Identifier: object.UnstructuredToObjMetadata(namespace),
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Object: namespace,
},
},
@ -293,7 +293,7 @@ func TestPrune(t *testing.T) {
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Identifier: object.UnstructuredToObjMetadata(pod),
Operation: event.Pruned,
Status: event.PruneSuccessful,
Object: pod,
},
},
@ -311,7 +311,7 @@ func TestPrune(t *testing.T) {
Type: event.DeleteType,
DeleteEvent: event.DeleteEvent{
Identifier: object.UnstructuredToObjMetadata(pod),
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Object: pod,
},
},
@ -331,7 +331,7 @@ func TestPrune(t *testing.T) {
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Identifier: object.UnstructuredToObjMetadata(pod),
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Object: pod,
Error: testutil.EqualError(&filter.ApplyPreventedDeletionError{
UID: "pod-uid",
@ -357,7 +357,7 @@ func TestPrune(t *testing.T) {
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Identifier: object.UnstructuredToObjMetadata(pod),
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Object: pod,
Error: testutil.EqualError(&filter.ApplyPreventedDeletionError{
UID: "pod-uid",
@ -368,7 +368,7 @@ func TestPrune(t *testing.T) {
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Identifier: object.UnstructuredToObjMetadata(pdb),
Operation: event.Pruned,
Status: event.PruneSuccessful,
Object: pdb,
},
},
@ -389,7 +389,7 @@ func TestPrune(t *testing.T) {
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Identifier: object.UnstructuredToObjMetadata(podDeletionPrevention),
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Object: testutil.Mutate(podDeletionPrevention.DeepCopy(),
testutil.DeleteOwningInv(t, testInventoryLabel)),
Error: testutil.EqualError(&filter.AnnotationPreventedDeletionError{
@ -402,7 +402,7 @@ func TestPrune(t *testing.T) {
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Identifier: testutil.ToIdentifier(t, pdbDeletePreventionManifest),
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Object: testutil.Unstructured(t, pdbDeletePreventionManifest,
testutil.DeleteOwningInv(t, testInventoryLabel)),
Error: testutil.EqualError(&filter.AnnotationPreventedDeletionError{
@ -433,7 +433,7 @@ func TestPrune(t *testing.T) {
Type: event.DeleteType,
DeleteEvent: event.DeleteEvent{
Identifier: object.UnstructuredToObjMetadata(podDeletionPrevention),
Operation: event.DeleteSkipped,
Status: event.DeleteSkipped,
Object: testutil.Mutate(podDeletionPrevention.DeepCopy(),
testutil.DeleteOwningInv(t, testInventoryLabel)),
Error: testutil.EqualError(&filter.AnnotationPreventedDeletionError{
@ -446,7 +446,7 @@ func TestPrune(t *testing.T) {
Type: event.DeleteType,
DeleteEvent: event.DeleteEvent{
Identifier: testutil.ToIdentifier(t, pdbDeletePreventionManifest),
Operation: event.DeleteSkipped,
Status: event.DeleteSkipped,
Object: testutil.Unstructured(t, pdbDeletePreventionManifest,
testutil.DeleteOwningInv(t, testInventoryLabel)),
Error: testutil.EqualError(&filter.AnnotationPreventedDeletionError{
@ -474,7 +474,7 @@ func TestPrune(t *testing.T) {
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Identifier: object.UnstructuredToObjMetadata(podDeletionPrevention),
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Object: testutil.Mutate(podDeletionPrevention.DeepCopy(),
testutil.DeleteOwningInv(t, testInventoryLabel)),
Error: testutil.EqualError(&filter.AnnotationPreventedDeletionError{
@ -486,8 +486,8 @@ func TestPrune(t *testing.T) {
{
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Status: event.PruneSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod),
Operation: event.Pruned,
Object: pod,
},
},
@ -512,7 +512,7 @@ func TestPrune(t *testing.T) {
Type: event.PruneType,
PruneEvent: event.PruneEvent{
Identifier: object.UnstructuredToObjMetadata(namespace),
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Object: namespace,
Error: testutil.EqualError(&filter.NamespaceInUseError{
Namespace: namespace.GetName(),

View File

@ -114,19 +114,19 @@ func (a *ApplyTask) Start(taskContext *taskrunner.TaskContext) {
// Check filters to see if we're prevented from applying.
var filterErr error
for _, applyFilter := range a.Filters {
klog.V(6).Infof("evaluating apply filter %s: %s", applyFilter.Name(), id)
klog.V(6).Infof("apply filter evaluating (filter: %s, object: %s)", applyFilter.Name(), id)
filterErr = applyFilter.Filter(obj)
if filterErr != nil {
var fatalErr *filter.FatalError
if errors.As(filterErr, &fatalErr) {
if klog.V(5).Enabled() {
klog.Errorf("error filtering (object: %q, filter: %q): %v", id, applyFilter.Name(), fatalErr.Err)
klog.Errorf("apply filter errored (filter: %s, object: %s): %v", applyFilter.Name(), id, fatalErr.Err)
}
taskContext.SendEvent(a.createApplyFailedEvent(id, err))
taskContext.InventoryManager().AddFailedApply(id)
break
}
klog.V(4).Infof("apply filtered (object: %q, filter: %q): %v", id, applyFilter.Name(), filterErr)
klog.V(4).Infof("apply filtered (filter: %s, object: %s): %v", applyFilter.Name(), id, filterErr)
taskContext.SendEvent(a.createApplySkippedEvent(id, obj, filterErr))
taskContext.InventoryManager().AddSkippedApply(id)
break
@ -262,7 +262,7 @@ func (a *ApplyTask) createApplySkippedEvent(id object.ObjMetadata, resource *uns
ApplyEvent: event.ApplyEvent{
GroupName: a.Name(),
Identifier: id,
Operation: event.Unchanged,
Status: event.ApplySkipped,
Resource: resource,
Error: err,
},

View File

@ -27,9 +27,9 @@ type KubectlPrinterAdapter struct {
// resourcePrinterImpl implements the ResourcePrinter interface. But
// instead of printing, it emits information on the provided channel.
type resourcePrinterImpl struct {
applyOperation event.ApplyEventOperation
ch chan<- event.Event
groupName string
applyStatus event.ApplyEventStatus
ch chan<- event.Event
groupName string
}
// PrintObj takes the provided object and operation and emits
@ -44,7 +44,7 @@ func (r *resourcePrinterImpl) PrintObj(obj runtime.Object, _ io.Writer) error {
ApplyEvent: event.ApplyEvent{
GroupName: r.groupName,
Identifier: id,
Operation: r.applyOperation,
Status: r.applyStatus,
Resource: obj.(*unstructured.Unstructured),
},
}
@ -57,26 +57,26 @@ type toPrinterFunc func(string) (printers.ResourcePrinter, error)
// is the type required by the ApplyOptions.
func (p *KubectlPrinterAdapter) toPrinterFunc() toPrinterFunc {
return func(operation string) (printers.ResourcePrinter, error) {
applyOperation, err := operationToApplyOperationConst(operation)
applyStatus, err := kubectlOperationToApplyStatus(operation)
return &resourcePrinterImpl{
ch: p.ch,
applyOperation: applyOperation,
groupName: p.groupName,
ch: p.ch,
applyStatus: applyStatus,
groupName: p.groupName,
}, err
}
}
func operationToApplyOperationConst(operation string) (event.ApplyEventOperation, error) {
func kubectlOperationToApplyStatus(operation string) (event.ApplyEventStatus, error) {
switch operation {
case "serverside-applied":
return event.ServersideApplied, nil
return event.ApplySuccessful, nil
case "created":
return event.Created, nil
return event.ApplySuccessful, nil
case "unchanged":
return event.Unchanged, nil
return event.ApplySuccessful, nil
case "configured":
return event.Configured, nil
return event.ApplySuccessful, nil
default:
return event.ApplyEventOperation(0), fmt.Errorf("unknown operation %s", operation)
return event.ApplyEventStatus(0), fmt.Errorf("unknown operation %s", operation)
}
}

View File

@ -50,6 +50,6 @@ func TestKubectlPrinterAdapter(t *testing.T) {
wg.Wait()
assert.NoError(t, err)
assert.Equal(t, event.ServersideApplied, msg.ApplyEvent.Operation)
assert.Equal(t, event.ApplySuccessful, msg.ApplyEvent.Status)
assert.Equal(t, deployment, msg.ApplyEvent.Resource)
}

View File

@ -163,7 +163,7 @@ func (tsr *TaskStatusRunner) Run(
ActionGroupEvent: event.ActionGroupEvent{
GroupName: currentTask.Name(),
Action: currentTask.Action(),
Type: event.Finished,
Status: event.Finished,
},
})
if msg.Err != nil {
@ -212,7 +212,7 @@ func nextTask(taskQueue chan Task, taskContext *TaskContext) (Task, bool) {
ActionGroupEvent: event.ActionGroupEvent{
GroupName: tsk.Name(),
Action: tsk.Action(),
Type: event.Started,
Status: event.Started,
},
})

View File

@ -102,22 +102,22 @@ func TestBaseRunner(t *testing.T) {
{
GroupName: "wait",
Identifier: depID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
{
GroupName: "wait",
Identifier: cmID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
{
GroupName: "wait",
Identifier: cmID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
{
GroupName: "wait",
Identifier: depID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
},
@ -149,22 +149,22 @@ func TestBaseRunner(t *testing.T) {
{
GroupName: "wait",
Identifier: depID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
{
GroupName: "wait",
Identifier: cmID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
{
GroupName: "wait",
Identifier: cmID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
{
GroupName: "wait",
Identifier: depID,
Operation: event.ReconcileTimeout,
Status: event.ReconcileTimeout,
},
},
},
@ -204,22 +204,22 @@ func TestBaseRunner(t *testing.T) {
{
GroupName: "wait",
Identifier: depID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
{
GroupName: "wait",
Identifier: cmID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
{
GroupName: "wait",
Identifier: cmID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
{
GroupName: "wait",
Identifier: depID,
Operation: event.ReconcileTimeout,
Status: event.ReconcileTimeout,
},
},
},

View File

@ -131,13 +131,13 @@ func (w *WaitTask) Start(taskContext *TaskContext) {
}()
}
func (w *WaitTask) sendEvent(taskContext *TaskContext, id object.ObjMetadata, op event.WaitEventOperation) {
func (w *WaitTask) sendEvent(taskContext *TaskContext, id object.ObjMetadata, status event.WaitEventStatus) {
taskContext.SendEvent(event.Event{
Type: event.WaitType,
WaitEvent: event.WaitEvent{
GroupName: w.Name(),
Identifier: id,
Operation: op,
Status: status,
},
})
}
@ -168,7 +168,7 @@ func (w *WaitTask) startInner(taskContext *TaskContext) {
// Object never applied or deleted!
klog.Errorf("Failed to mark object as successful reconcile: %v", err)
}
w.sendEvent(taskContext, id, event.Reconciled)
w.sendEvent(taskContext, id, event.ReconcileSuccessful)
default:
err := taskContext.InventoryManager().SetPendingReconcile(id)
if err != nil {
@ -286,7 +286,7 @@ func (w *WaitTask) handleChangedUID(taskContext *TaskContext, id object.ObjMetad
// Object never applied or deleted!
klog.Errorf("Failed to mark object as successful reconcile: %v", err)
}
w.sendEvent(taskContext, id, event.Reconciled)
w.sendEvent(taskContext, id, event.ReconcileSuccessful)
case AllCurrent:
// Object deleted and recreated by another actor after apply.
// Treat as failure (unverifiable).
@ -334,7 +334,7 @@ func (w *WaitTask) StatusUpdate(taskContext *TaskContext, id object.ObjMetadata)
klog.Errorf("Failed to mark object as successful reconcile: %v", err)
}
w.pending = w.pending.Remove(id)
w.sendEvent(taskContext, id, event.Reconciled)
w.sendEvent(taskContext, id, event.ReconcileSuccessful)
case w.failedByID(taskContext, id):
// failed - remove from pending & send event
err := taskContext.InventoryManager().SetFailedReconcile(id)
@ -367,7 +367,7 @@ func (w *WaitTask) StatusUpdate(taskContext *TaskContext, id object.ObjMetadata)
klog.Errorf("Failed to mark object as successful reconcile: %v", err)
}
w.failed = w.failed.Remove(id)
w.sendEvent(taskContext, id, event.Reconciled)
w.sendEvent(taskContext, id, event.ReconcileSuccessful)
} else if !w.failedByID(taskContext, id) {
// If a resource is no longer reported as Failed and is not Reconciled,
// they should just go back to InProgress.

View File

@ -162,7 +162,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment2 pending
@ -171,7 +171,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment3 skipped
@ -180,7 +180,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment3ID,
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
},
},
// deployment4 skipped
@ -189,7 +189,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment4ID,
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
},
},
// current events next, in the order of status updates
@ -199,7 +199,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
// deployment2 current
@ -208,7 +208,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
}
@ -333,7 +333,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment2 pending
@ -342,7 +342,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment3 skipped
@ -351,7 +351,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment3ID,
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
},
},
// deployment4 skipped
@ -360,7 +360,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment4ID,
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
},
},
// current events next, in the order of status updates
@ -370,7 +370,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
// timeout events last, in the order provided to the WaitTask
@ -380,7 +380,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.ReconcileTimeout,
Status: event.ReconcileTimeout,
},
},
}
@ -485,7 +485,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeploymentID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
}
@ -572,7 +572,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeploymentID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
}
@ -666,7 +666,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeploymentID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment1 reconciled
@ -675,7 +675,7 @@ loop:
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeploymentID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
}
@ -760,7 +760,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment2 pending
@ -769,7 +769,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment1 is failed
@ -778,7 +778,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcileFailed,
Status: event.ReconcileFailed,
},
},
// deployment2 current
@ -787,7 +787,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
},
@ -843,7 +843,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment2 pending
@ -852,7 +852,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment2 current
@ -861,7 +861,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
// deployment1 is failed
@ -870,7 +870,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcileFailed,
Status: event.ReconcileFailed,
},
},
},
@ -932,7 +932,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment2 pending
@ -941,7 +941,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment1 is failed
@ -950,7 +950,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcileFailed,
Status: event.ReconcileFailed,
},
},
// deployment1 is current
@ -959,7 +959,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
// deployment2 current
@ -968,7 +968,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
},
@ -1030,7 +1030,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment2 pending
@ -1039,7 +1039,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment1 is failed
@ -1048,7 +1048,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcileFailed,
Status: event.ReconcileFailed,
},
},
// deployment1 pending
@ -1057,7 +1057,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment2 current
@ -1066,7 +1066,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
// deployment1 timed out
@ -1075,7 +1075,7 @@ func TestWaitTask_Failed(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcileTimeout,
Status: event.ReconcileTimeout,
},
},
},
@ -1209,7 +1209,7 @@ func TestWaitTask_UIDChanged(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment2 pending
@ -1218,7 +1218,7 @@ func TestWaitTask_UIDChanged(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment1 is failed
@ -1227,7 +1227,7 @@ func TestWaitTask_UIDChanged(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcileFailed,
Status: event.ReconcileFailed,
},
},
// deployment2 current
@ -1236,7 +1236,7 @@ func TestWaitTask_UIDChanged(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
},
@ -1296,7 +1296,7 @@ func TestWaitTask_UIDChanged(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment2 pending
@ -1305,7 +1305,7 @@ func TestWaitTask_UIDChanged(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
},
},
// deployment1 is replaced
@ -1314,7 +1314,7 @@ func TestWaitTask_UIDChanged(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment1ID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
// deployment2 not found
@ -1323,7 +1323,7 @@ func TestWaitTask_UIDChanged(t *testing.T) {
WaitEvent: event.WaitEvent{
GroupName: taskName,
Identifier: testDeployment2ID,
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
},
},
},

View File

@ -9,6 +9,7 @@
// * Current
// * Failed
// * Terminating
// * NotFound
// * Unknown
//
// Computing the status of a resources can be done by calling the

View File

@ -25,6 +25,7 @@ type Formatter interface {
s stats.Stats,
c Collector,
) error
FormatSummary(s stats.Stats) error
}
type FormatterFactory func(previewStrategy common.DryRunStrategy) Formatter
@ -107,6 +108,10 @@ func (b *BaseListPrinter) Print(ch <-chan event.Event, previewStrategy common.Dr
}
}
}
if err := formatter.FormatSummary(statsCollector); err != nil {
return err
}
return printcommon.ResultErrorFromStats(statsCollector)
}

View File

@ -73,8 +73,16 @@ func (c *countingFormatter) FormatErrorEvent(e event.ErrorEvent) error {
return nil
}
func (c *countingFormatter) FormatActionGroupEvent(e event.ActionGroupEvent, _ []event.ActionGroup, _ stats.Stats,
_ Collector) error {
func (c *countingFormatter) FormatActionGroupEvent(
e event.ActionGroupEvent,
_ []event.ActionGroup,
_ stats.Stats,
_ Collector,
) error {
c.actionGroupEvent = append(c.actionGroupEvent, e)
return nil
}
func (c *countingFormatter) FormatSummary(s stats.Stats) error {
return nil
}

View File

@ -10,7 +10,8 @@ import (
)
// Stats captures the summarized numbers from apply/prune/delete and
// reconciliation of resources.
// reconciliation of resources. Each item in a stats list represents the stats
// from all the events in a single action group.
type Stats struct {
ApplyStats ApplyStats
PruneStats PruneStats
@ -32,52 +33,32 @@ func (s *Stats) FailedReconciliationSum() int {
func (s *Stats) Handle(e event.Event) {
switch e.Type {
case event.ApplyType:
if e.ApplyEvent.Error != nil &&
e.ApplyEvent.Operation != event.Unchanged {
s.ApplyStats.IncFailed()
return
}
s.ApplyStats.Inc(e.ApplyEvent.Operation)
s.ApplyStats.Inc(e.ApplyEvent.Status)
case event.PruneType:
if e.PruneEvent.Error != nil &&
e.PruneEvent.Operation != event.PruneSkipped {
s.PruneStats.IncFailed()
return
}
s.PruneStats.Inc(e.PruneEvent.Operation)
s.PruneStats.Inc(e.PruneEvent.Status)
case event.DeleteType:
if e.DeleteEvent.Error != nil &&
e.DeleteEvent.Operation != event.DeleteSkipped {
s.DeleteStats.IncFailed()
return
}
s.DeleteStats.Inc(e.DeleteEvent.Operation)
s.DeleteStats.Inc(e.DeleteEvent.Status)
case event.WaitType:
s.WaitStats.Inc(e.WaitEvent.Operation)
s.WaitStats.Inc(e.WaitEvent.Status)
}
}
type ApplyStats struct {
ServersideApplied int
Created int
Unchanged int
Configured int
Failed int
Successful int
Skipped int
Failed int
}
func (a *ApplyStats) Inc(op event.ApplyEventOperation) {
func (a *ApplyStats) Inc(op event.ApplyEventStatus) {
switch op {
case event.ApplyUnspecified:
case event.ServersideApplied:
a.ServersideApplied++
case event.Created:
a.Created++
case event.Unchanged:
a.Unchanged++
case event.Configured:
a.Configured++
case event.ApplySuccessful:
a.Successful++
case event.ApplySkipped:
a.Skipped++
case event.ApplyFailed:
a.Failed++
default:
panic(fmt.Errorf("unknown apply operation %s", op.String()))
panic(fmt.Errorf("invalid apply status %s", op.String()))
}
}
@ -86,22 +67,25 @@ func (a *ApplyStats) IncFailed() {
}
func (a *ApplyStats) Sum() int {
return a.ServersideApplied + a.Configured + a.Unchanged + a.Created + a.Failed
return a.Successful + a.Skipped + a.Failed
}
type PruneStats struct {
Pruned int
Skipped int
Failed int
Successful int
Skipped int
Failed int
}
func (p *PruneStats) Inc(op event.PruneEventOperation) {
func (p *PruneStats) Inc(op event.PruneEventStatus) {
switch op {
case event.PruneUnspecified:
case event.Pruned:
p.Pruned++
case event.PruneSuccessful:
p.Successful++
case event.PruneSkipped:
p.Skipped++
case event.PruneFailed:
p.Failed++
default:
panic(fmt.Errorf("invalid prune status %s", op.String()))
}
}
@ -109,19 +93,26 @@ func (p *PruneStats) IncFailed() {
p.Failed++
}
type DeleteStats struct {
Deleted int
Skipped int
Failed int
func (p *PruneStats) Sum() int {
return p.Successful + p.Skipped + p.Failed
}
func (d *DeleteStats) Inc(op event.DeleteEventOperation) {
type DeleteStats struct {
Successful int
Skipped int
Failed int
}
func (d *DeleteStats) Inc(op event.DeleteEventStatus) {
switch op {
case event.DeleteUnspecified:
case event.Deleted:
d.Deleted++
case event.DeleteSuccessful:
d.Successful++
case event.DeleteSkipped:
d.Skipped++
case event.DeleteFailed:
d.Failed++
default:
panic(fmt.Errorf("invalid delete status %s", op.String()))
}
}
@ -129,22 +120,34 @@ func (d *DeleteStats) IncFailed() {
d.Failed++
}
func (d *DeleteStats) Sum() int {
return d.Successful + d.Skipped + d.Failed
}
type WaitStats struct {
Reconciled int
Successful int
Timeout int
Failed int
Skipped int
}
func (w *WaitStats) Inc(op event.WaitEventOperation) {
switch op {
case event.Reconciled:
w.Reconciled++
func (w *WaitStats) Inc(status event.WaitEventStatus) {
switch status {
case event.ReconcilePending:
// ignore - should be replaced by one of the others before the WaitTask exits
case event.ReconcileSuccessful:
w.Successful++
case event.ReconcileSkipped:
w.Skipped++
case event.ReconcileTimeout:
w.Timeout++
case event.ReconcileFailed:
w.Failed++
default:
panic(fmt.Errorf("invalid wait status %s", status.String()))
}
}
func (w *WaitStats) Sum() int {
return w.Successful + w.Skipped + w.Failed + w.Timeout
}

View File

@ -58,21 +58,16 @@ func (ef *formatter) FormatValidationEvent(ve event.ValidationEvent) error {
return nil
}
func (ef *formatter) FormatApplyEvent(ae event.ApplyEvent) error {
gk := ae.Identifier.GroupKind
name := ae.Identifier.Name
if ae.Error != nil {
if ae.Operation == event.Unchanged {
ef.print("%s apply skipped: %s", resourceIDToString(gk, name),
ae.Error.Error())
} else {
ef.print("%s apply failed: %s", resourceIDToString(gk, name),
ae.Error.Error())
}
return nil
func (ef *formatter) FormatApplyEvent(e event.ApplyEvent) error {
gk := e.Identifier.GroupKind
name := e.Identifier.Name
if e.Error != nil {
ef.print("%s apply %s: %s", resourceIDToString(gk, name),
strings.ToLower(e.Status.String()), e.Error.Error())
} else {
ef.print("%s apply %s", resourceIDToString(gk, name),
strings.ToLower(e.Status.String()))
}
ef.print("%s %s", resourceIDToString(gk, name),
strings.ToLower(ae.Operation.String()))
return nil
}
@ -82,69 +77,37 @@ func (ef *formatter) FormatStatusEvent(se event.StatusEvent) error {
return nil
}
func (ef *formatter) FormatPruneEvent(pe event.PruneEvent) error {
gk := pe.Identifier.GroupKind
name := pe.Identifier.Name
if pe.Error != nil {
if pe.Operation == event.PruneSkipped {
ef.print("%s prune skipped: %s", resourceIDToString(gk, name),
pe.Error.Error())
} else {
ef.print("%s prune failed: %s", resourceIDToString(gk, name),
pe.Error.Error())
}
return nil
}
switch pe.Operation {
case event.Pruned:
ef.print("%s pruned", resourceIDToString(gk, name))
case event.PruneSkipped:
ef.print("%s prune skipped", resourceIDToString(gk, name))
func (ef *formatter) FormatPruneEvent(e event.PruneEvent) error {
gk := e.Identifier.GroupKind
name := e.Identifier.Name
if e.Error != nil {
ef.print("%s prune %s: %s", resourceIDToString(gk, name),
strings.ToLower(e.Status.String()), e.Error.Error())
} else {
ef.print("%s prune %s", resourceIDToString(gk, name),
strings.ToLower(e.Status.String()))
}
return nil
}
func (ef *formatter) FormatDeleteEvent(de event.DeleteEvent) error {
gk := de.Identifier.GroupKind
name := de.Identifier.Name
if de.Error != nil {
if de.Operation == event.DeleteSkipped {
ef.print("%s delete skipped: %s", resourceIDToString(gk, name),
de.Error.Error())
} else {
ef.print("%s delete failed: %s", resourceIDToString(gk, name),
de.Error.Error())
}
return nil
}
switch de.Operation {
case event.Deleted:
ef.print("%s deleted", resourceIDToString(gk, name))
case event.DeleteSkipped:
ef.print("%s delete skipped", resourceIDToString(gk, name))
func (ef *formatter) FormatDeleteEvent(e event.DeleteEvent) error {
gk := e.Identifier.GroupKind
name := e.Identifier.Name
if e.Error != nil {
ef.print("%s delete %s: %s", resourceIDToString(gk, name),
strings.ToLower(e.Status.String()), e.Error.Error())
} else {
ef.print("%s delete %s", resourceIDToString(gk, name),
strings.ToLower(e.Status.String()))
}
return nil
}
func (ef *formatter) FormatWaitEvent(we event.WaitEvent) error {
gk := we.Identifier.GroupKind
name := we.Identifier.Name
switch we.Operation {
case event.ReconcilePending:
ef.print("%s reconcile pending", resourceIDToString(gk, name))
case event.Reconciled:
ef.print("%s reconciled", resourceIDToString(gk, name))
case event.ReconcileSkipped:
ef.print("%s reconcile skipped", resourceIDToString(gk, name))
case event.ReconcileTimeout:
ef.print("%s reconcile timeout", resourceIDToString(gk, name))
case event.ReconcileFailed:
ef.print("%s reconcile failed", resourceIDToString(gk, name))
}
func (ef *formatter) FormatWaitEvent(e event.WaitEvent) error {
gk := e.Identifier.GroupKind
name := e.Identifier.Name
ef.print("%s reconcile %s", resourceIDToString(gk, name),
strings.ToLower(e.Status.String()))
return nil
}
@ -158,40 +121,43 @@ func (ef *formatter) FormatActionGroupEvent(
s stats.Stats,
_ list.Collector,
) error {
if age.Action == event.ApplyAction &&
age.Type == event.Finished &&
list.IsLastActionGroup(age, ags) {
switch age.Action {
case event.ApplyAction:
ef.print("apply phase %s", strings.ToLower(age.Status.String()))
case event.PruneAction:
ef.print("prune phase %s", strings.ToLower(age.Status.String()))
case event.DeleteAction:
ef.print("delete phase %s", strings.ToLower(age.Status.String()))
case event.WaitAction:
ef.print("reconcile phase %s", strings.ToLower(age.Status.String()))
case event.InventoryAction:
ef.print("inventory update %s", strings.ToLower(age.Status.String()))
default:
return fmt.Errorf("invalid action group action: %+v", age)
}
return nil
}
func (ef *formatter) FormatSummary(s stats.Stats) error {
if s.ApplyStats != (stats.ApplyStats{}) {
as := s.ApplyStats
output := fmt.Sprintf("%d resource(s) applied. %d created, %d unchanged, %d configured, %d failed",
as.Sum(), as.Created, as.Unchanged, as.Configured, as.Failed)
// Only print information about serverside apply if some of the
// resources actually were applied serverside.
if as.ServersideApplied > 0 {
output += fmt.Sprintf(", %d serverside applied", as.ServersideApplied)
}
ef.print(output)
ef.print("apply result: %d attempted, %d successful, %d skipped, %d failed",
as.Sum(), as.Successful, as.Skipped, as.Failed)
}
if age.Action == event.PruneAction &&
age.Type == event.Finished &&
list.IsLastActionGroup(age, ags) {
if s.PruneStats != (stats.PruneStats{}) {
ps := s.PruneStats
ef.print("%d resource(s) pruned, %d skipped, %d failed to prune", ps.Pruned, ps.Skipped, ps.Failed)
ef.print("prune result: %d attempted, %d successful, %d skipped, %d failed",
ps.Sum(), ps.Successful, ps.Skipped, ps.Failed)
}
if age.Action == event.DeleteAction &&
age.Type == event.Finished &&
list.IsLastActionGroup(age, ags) {
if s.DeleteStats != (stats.DeleteStats{}) {
ds := s.DeleteStats
ef.print("%d resource(s) deleted, %d skipped, %d failed to delete", ds.Deleted, ds.Skipped, ds.Failed)
ef.print("delete result: %d attempted, %d successful, %d skipped, %d failed",
ds.Sum(), ds.Successful, ds.Skipped, ds.Failed)
}
if age.Action == event.WaitAction &&
age.Type == event.Finished &&
list.IsLastActionGroup(age, ags) {
if s.WaitStats != (stats.WaitStats{}) {
ws := s.WaitStats
ef.print("%d resource(s) reconciled, %d skipped, %d failed to reconcile, %d timed out", ws.Reconciled,
ws.Skipped, ws.Failed, ws.Timeout)
ef.print("reconcile result: %d attempted, %d successful, %d skipped, %d failed, %d timed out",
ws.Sum(), ws.Successful, ws.Skipped, ws.Failed, ws.Timeout)
}
return nil
}

View File

@ -34,30 +34,31 @@ func TestFormatter_FormatApplyEvent(t *testing.T) {
"resource created without no dryrun": {
previewStrategy: common.DryRunNone,
event: event.ApplyEvent{
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: "deployment.apps/my-dep created",
expected: "deployment.apps/my-dep apply successful",
},
"resource updated with client dryrun": {
previewStrategy: common.DryRunClient,
event: event.ApplyEvent{
Operation: event.Configured,
Status: event.ApplySuccessful,
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
},
expected: "deployment.apps/my-dep configured",
expected: "deployment.apps/my-dep apply successful",
},
"resource updated with server dryrun": {
previewStrategy: common.DryRunServer,
event: event.ApplyEvent{
Operation: event.Configured,
Status: event.ApplySuccessful,
Identifier: createIdentifier("batch", "CronJob", "foo", "my-cron"),
},
expected: "cronjob.batch/my-cron configured",
expected: "cronjob.batch/my-cron apply successful",
},
"apply event with error should display the error": {
previewStrategy: common.DryRunServer,
event: event.ApplyEvent{
Status: event.ApplyFailed,
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
Error: fmt.Errorf("this is a test error"),
},
@ -66,7 +67,7 @@ func TestFormatter_FormatApplyEvent(t *testing.T) {
"apply event with skip error should display the error": {
previewStrategy: common.DryRunServer,
event: event.ApplyEvent{
Operation: event.Unchanged,
Status: event.ApplySkipped,
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
Error: fmt.Errorf("this is a test error"),
},
@ -142,16 +143,16 @@ func TestFormatter_FormatPruneEvent(t *testing.T) {
"resource pruned without no dryrun": {
previewStrategy: common.DryRunNone,
event: event.PruneEvent{
Operation: event.Pruned,
Status: event.PruneSuccessful,
Object: createObject("apps", "Deployment", "", "my-dep"),
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: "deployment.apps/my-dep pruned",
expected: "deployment.apps/my-dep prune successful",
},
"resource skipped with client dryrun": {
previewStrategy: common.DryRunClient,
event: event.PruneEvent{
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Object: createObject("apps", "Deployment", "", "my-dep"),
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
},
@ -160,6 +161,7 @@ func TestFormatter_FormatPruneEvent(t *testing.T) {
"resource with prune error": {
previewStrategy: common.DryRunNone,
event: event.PruneEvent{
Status: event.PruneFailed,
Object: createObject("apps", "Deployment", "", "my-dep"),
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
Error: fmt.Errorf("this is a test"),
@ -170,7 +172,7 @@ func TestFormatter_FormatPruneEvent(t *testing.T) {
"resource with prune skip error": {
previewStrategy: common.DryRunNone,
event: event.PruneEvent{
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Object: createObject("batch", "CronJob", "foo", "my-cron"),
Identifier: createIdentifier("batch", "CronJob", "foo", "my-cron"),
Error: fmt.Errorf("this is a test"),
@ -201,16 +203,16 @@ func TestFormatter_FormatDeleteEvent(t *testing.T) {
"resource deleted without no dryrun": {
previewStrategy: common.DryRunNone,
event: event.DeleteEvent{
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
Object: createObject("apps", "Deployment", "default", "my-dep"),
},
expected: "deployment.apps/my-dep deleted",
expected: "deployment.apps/my-dep delete successful",
},
"resource skipped with client dryrun": {
previewStrategy: common.DryRunClient,
event: event.DeleteEvent{
Operation: event.DeleteSkipped,
Status: event.DeleteSkipped,
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
Object: createObject("apps", "Deployment", "", "my-dep"),
},
@ -219,6 +221,7 @@ func TestFormatter_FormatDeleteEvent(t *testing.T) {
"resource with delete error": {
previewStrategy: common.DryRunServer,
event: event.DeleteEvent{
Status: event.DeleteFailed,
Object: createObject("apps", "Deployment", "", "my-dep"),
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
Error: fmt.Errorf("this is a test"),
@ -228,7 +231,7 @@ func TestFormatter_FormatDeleteEvent(t *testing.T) {
"resource with delete skip error": {
previewStrategy: common.DryRunServer,
event: event.DeleteEvent{
Operation: event.DeleteSkipped,
Status: event.DeleteSkipped,
Object: createObject("batch", "CronJob", "foo", "my-cron"),
Identifier: createIdentifier("batch", "CronJob", "foo", "my-cron"),
Error: fmt.Errorf("this is a test"),
@ -260,35 +263,35 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
previewStrategy: common.DryRunNone,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: "deployment.apps/my-dep reconciled",
expected: "deployment.apps/my-dep reconcile successful",
},
"resource reconciled (client-side dry-run)": {
previewStrategy: common.DryRunClient,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: "deployment.apps/my-dep reconciled",
expected: "deployment.apps/my-dep reconcile successful",
},
"resource reconciled (server-side dry-run)": {
previewStrategy: common.DryRunServer,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: "deployment.apps/my-dep reconciled",
expected: "deployment.apps/my-dep reconcile successful",
},
"resource reconcile timeout": {
previewStrategy: common.DryRunNone,
event: event.WaitEvent{
GroupName: "wait-1",
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
Operation: event.ReconcileTimeout,
Status: event.ReconcileTimeout,
},
expected: "deployment.apps/my-dep reconcile timeout",
},
@ -297,7 +300,7 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
event: event.WaitEvent{
GroupName: "wait-1",
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
Operation: event.ReconcileTimeout,
Status: event.ReconcileTimeout,
},
expected: "deployment.apps/my-dep reconcile timeout",
},
@ -306,7 +309,7 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
event: event.WaitEvent{
GroupName: "wait-1",
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
Operation: event.ReconcileTimeout,
Status: event.ReconcileTimeout,
},
expected: "deployment.apps/my-dep reconcile timeout",
},
@ -314,7 +317,7 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
previewStrategy: common.DryRunNone,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: "deployment.apps/my-dep reconcile skipped",
@ -323,7 +326,7 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
previewStrategy: common.DryRunClient,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: "deployment.apps/my-dep reconcile skipped",
@ -332,7 +335,7 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
previewStrategy: common.DryRunServer,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: "deployment.apps/my-dep reconcile skipped",
@ -341,7 +344,7 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
previewStrategy: common.DryRunNone,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.ReconcileFailed,
Status: event.ReconcileFailed,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: "deployment.apps/my-dep reconcile failed",

View File

@ -0,0 +1,19 @@
// Copyright 2020 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package events
import (
"testing"
"k8s.io/cli-runtime/pkg/genericclioptions"
"sigs.k8s.io/cli-utils/pkg/printers/printer"
printertesting "sigs.k8s.io/cli-utils/pkg/printers/testutil"
)
func TestPrint(t *testing.T) {
printertesting.PrintResultErrorTest(t, func() printer.Printer {
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
return NewPrinter(ioStreams)
})
}

View File

@ -7,69 +7,91 @@
//
// Every event will contain the following properties:
// * timestamp: RFC3339-formatted timestamp describing when the event happened.
// * type: Describes the type of the operation which the event is related to. Values
// can be apply, status, prune, delete, or error.
// * eventType: Describes the type of the event. The set of possible values depends on the
// the value of the type field.
// * type: Describes the type of the operation which the event is related to.
// Type values include:
// * validation - ValidationEvent
// * error - ErrorEvent
// * group - ActionGroupEvent
// * apply - ApplyEvent
// * prune - PruneEvent
// * delete - DeleteEvent
// * wait - WaitEvent
// * status - StatusEvent
// * summary - aggregate stats collected by the printer
//
// All the different types have a similar structure, with the exception of the
// error type. There is one event type pertaining to a specific resource, it being that
// it is applied, pruned or its status was updated, and there is a separate event type
// when all resources have been applied, deleted and so on. For any event that
// pertains to a particular resource, the fields group, kind, name and namespace
// will always be present.
// Validation events correspond to zero or more objects. For these events, the
// objects field includes a list of object identifiers. These generally fire
// first before most other events.
//
// Events of type apply can have two different values for eventType, each which comes
// with a specific set of fields:
// * resourceApplied: A resource has been applied to the cluster.
// * fields identifying the resource.
// * operation: The operation that was performed on the resource. Must be one of
// created, configured, unchanged and serversideApplied.
// * completed: All resources have been applied.
// * count: Total number of resources applied
// * createdCount: Number of resources created.
// * configuredCount: Number of resources configured.
// * unchangedCount: Number of resources unchanged.
// * serversideAppliedCount: Number of resources applied serverside.
// Validation events have the following fields:
// * objects (array of objects) - a list of object identifiers
// * group (string, optional) - The object's API group.
// * kind (string) - The object's kind.
// * name (string) - The object's name.
// * namespace (string, optional) - The object's namespace.
// * timestamp (string) - ISO-8601 format
// * type (string) - "validation"
// * error (string) - a fatal error message specific to these objects
//
// Events of type status is a notification when either the status of resource
// has changed, or when a set of resources has reached their desired status. Events
// of type status can have three different values for eventType:
// * resourceStatus: The status has changed for a resource.
// * fields identifying the resource.
// * status: The new status for the resource.
// * message: Text that provides more information about the resource status.
// * completed: All resources have reached the desired status.
// * error: An error occurred when trying to get the status for a resource.
// * fields identifying the resource.
// * error: The error message.
// Error events corespond to a fatal error received outside of a specific task
// or operation.
//
// Events of type prune can have two different values for eventType, each which comes
// with a specific set of fields:
// * resourcePruned: A resource has been pruned or was intended to be pruned but has been
// skipped due to the presence of a lifecycle directive.
// * fields identifying the resource.
// * operation: The operation that was performed on the resource. Must be one
// of pruned or skipped.
// * completed: All resources have been pruned or skipped.
// * count: Total number of resources pruned or skipped.
// * prunedCount: Number of resources pruned.
// * skippedCount: Number of resources skipped.
// Error events have the following fields:
// * timestamp (string) - ISO-8601 format
// * type (string) - "error"
// * error (string) - a fatal error message
//
// Events of type delete can have two different values for eventType, each which comes
// with a specific set of fields:
// * resourceDeleted: A resource has been deleted or was intended to be deleted but has been
// skipped due to the presence of a lifecycle directive.
// * fields identifying the resource.
// * operation: The operation that was performed on the resource. Must be one
// of deleted or skipped.
// * completed: All resources have been deleted or skipped.
// * count: Total number of resources deleted or skipped.
// * deletedCount: Number of resources deleted.
// * skippedCount: Number of resources skipped.
// Group events correspond to a group of events of the same type: apply, prune,
// delete, or wait.
//
// Group events have the following fields:
// * action (string) - One of: "Apply", "Prune", "Delete", or "Wait".
// * status (string) - One of: "Started" or "Finished"
// * timestamp (string) - ISO-8601 format
// * type (string) - "group"
//
// Operation events (apply, prune, delete, and wait) corespond to an operation
// performed on a single object. For these events, the
// group, kind, name, and namespace fields identify the object.
//
// Operation events have the following fields:
// * group (string, optional) - The object's API group.
// * kind (string) - The object's kind.
// * name (string) - The object's name.
// * namespace (string, optional) - The object's namespace.
// * status (string) - One of: "Pending", "Successful", "Skipped", "Failed", or
// "Timeout".
// * timestamp (string) - ISO-8601 format
// * type (string) - "apply", "prune", "delete", or "wait"
// * error (string, optional) - A non-fatal error message specific to this object
//
// Status types are asynchronous events that correspond to status updates for
// a specific object.
//
// Status events have the following fields:
// * group (string, optional) - The object's API group.
// * kind (string) - The object's kind.
// * name (string) - The object's name.
// * namespace (string, optional) - The object's namespace.
// * status (string) - One of: "InProgress", "Failed", "Current", "Terminating",
// "NotFound", or "Unknown".
// * message (string) - Human readable description of the status.
// * timestamp (string) - ISO-8601 format
// * type (string) - "status"
//
// Summary types are a meta-event sent by the printer to summarize some stats
// that have been collected from other events. For these events, the action
// field corresponds to the event type being summarized: Apply, Prune, Delete,
// and Wait.
//
// Summary events have the following fields:
// * action (string) - One of: "Apply", "Prune", "Delete", or "Wait".
// * count (number) - Total number of objects attempted for this action
// * successful (number) - Number of objects for which the action was successful.
// * skipped (number) - Number of objects for which the action was skipped.
// * failed (number) - Number of objects for which the action failed.
// * timeout (number, optional) - Number of objects for which the action timed out.
// * timestamp (string) - ISO-8601 format
// * type (string) - "summary"
//
// Events of type error means there is an unrecoverable error and further
// processing will stop. Only a single value for eventType is possible:
// * error: A fatal error has happened.
// * error: The error message.
package json

View File

@ -21,11 +21,13 @@ func NewFormatter(ioStreams genericclioptions.IOStreams,
_ common.DryRunStrategy) list.Formatter {
return &formatter{
ioStreams: ioStreams,
now: time.Now,
}
}
type formatter struct {
ioStreams genericclioptions.IOStreams
now func() time.Time
}
func (jf *formatter) FormatValidationEvent(ve event.ValidationEvent) error {
@ -42,23 +44,19 @@ func (jf *formatter) FormatValidationEvent(ve event.ValidationEvent) error {
for i, id := range ve.Identifiers {
objects[i] = jf.baseResourceEvent(id)
}
return jf.printEvent("validation", "validation", map[string]interface{}{
return jf.printEvent("validation", map[string]interface{}{
"objects": objects,
"error": err.Error(),
})
}
func (jf *formatter) FormatApplyEvent(ae event.ApplyEvent) error {
eventInfo := jf.baseResourceEvent(ae.Identifier)
if ae.Error != nil {
eventInfo["error"] = ae.Error.Error()
// skipped apply sets both error and operation
if ae.Operation != event.Unchanged {
return jf.printEvent("apply", "resourceFailed", eventInfo)
}
func (jf *formatter) FormatApplyEvent(e event.ApplyEvent) error {
eventInfo := jf.baseResourceEvent(e.Identifier)
if e.Error != nil {
eventInfo["error"] = e.Error.Error()
}
eventInfo["operation"] = ae.Operation.String()
return jf.printEvent("apply", "resourceApplied", eventInfo)
eventInfo["status"] = e.Status.String()
return jf.printEvent("apply", eventInfo)
}
func (jf *formatter) FormatStatusEvent(se event.StatusEvent) error {
@ -69,44 +67,36 @@ func (jf *formatter) printResourceStatus(se event.StatusEvent) error {
eventInfo := jf.baseResourceEvent(se.Identifier)
eventInfo["status"] = se.PollResourceInfo.Status.String()
eventInfo["message"] = se.PollResourceInfo.Message
return jf.printEvent("status", "resourceStatus", eventInfo)
return jf.printEvent("status", eventInfo)
}
func (jf *formatter) FormatPruneEvent(pe event.PruneEvent) error {
eventInfo := jf.baseResourceEvent(pe.Identifier)
if pe.Error != nil {
eventInfo["error"] = pe.Error.Error()
// skipped prune sets both error and operation
if pe.Operation != event.PruneSkipped {
return jf.printEvent("prune", "resourceFailed", eventInfo)
}
func (jf *formatter) FormatPruneEvent(e event.PruneEvent) error {
eventInfo := jf.baseResourceEvent(e.Identifier)
if e.Error != nil {
eventInfo["error"] = e.Error.Error()
}
eventInfo["operation"] = pe.Operation.String()
return jf.printEvent("prune", "resourcePruned", eventInfo)
eventInfo["status"] = e.Status.String()
return jf.printEvent("prune", eventInfo)
}
func (jf *formatter) FormatDeleteEvent(de event.DeleteEvent) error {
eventInfo := jf.baseResourceEvent(de.Identifier)
if de.Error != nil {
eventInfo["error"] = de.Error.Error()
// skipped delete sets both error and operation
if de.Operation != event.DeleteSkipped {
return jf.printEvent("delete", "resourceFailed", eventInfo)
}
func (jf *formatter) FormatDeleteEvent(e event.DeleteEvent) error {
eventInfo := jf.baseResourceEvent(e.Identifier)
if e.Error != nil {
eventInfo["error"] = e.Error.Error()
}
eventInfo["operation"] = de.Operation.String()
return jf.printEvent("delete", "resourceDeleted", eventInfo)
eventInfo["status"] = e.Status.String()
return jf.printEvent("delete", eventInfo)
}
func (jf *formatter) FormatWaitEvent(we event.WaitEvent) error {
eventInfo := jf.baseResourceEvent(we.Identifier)
eventInfo["operation"] = we.Operation.String()
return jf.printEvent("wait", "resourceReconciled", eventInfo)
func (jf *formatter) FormatWaitEvent(e event.WaitEvent) error {
eventInfo := jf.baseResourceEvent(e.Identifier)
eventInfo["status"] = e.Status.String()
return jf.printEvent("wait", eventInfo)
}
func (jf *formatter) FormatErrorEvent(ee event.ErrorEvent) error {
return jf.printEvent("error", "error", map[string]interface{}{
"error": ee.Err.Error(),
func (jf *formatter) FormatErrorEvent(e event.ErrorEvent) error {
return jf.printEvent("error", map[string]interface{}{
"error": e.Err.Error(),
})
}
@ -116,52 +106,108 @@ func (jf *formatter) FormatActionGroupEvent(
s stats.Stats,
_ list.Collector,
) error {
if age.Action == event.ApplyAction && age.Type == event.Finished &&
list.IsLastActionGroup(age, ags) {
content := map[string]interface{}{
"action": age.Action.String(),
"status": age.Status.String(),
}
switch age.Action {
case event.ApplyAction:
if age.Status == event.Finished {
as := s.ApplyStats
content["count"] = as.Sum()
content["successful"] = as.Successful
content["skipped"] = as.Skipped
content["failed"] = as.Failed
}
case event.PruneAction:
if age.Status == event.Finished {
ps := s.PruneStats
content["count"] = ps.Sum()
content["successful"] = ps.Successful
content["skipped"] = ps.Skipped
content["failed"] = ps.Failed
}
case event.DeleteAction:
if age.Status == event.Finished {
ds := s.DeleteStats
content["count"] = ds.Sum()
content["successful"] = ds.Successful
content["skipped"] = ds.Skipped
content["failed"] = ds.Failed
}
case event.WaitAction:
if age.Status == event.Finished {
ws := s.WaitStats
content["count"] = ws.Sum()
content["successful"] = ws.Successful
content["skipped"] = ws.Skipped
content["failed"] = ws.Failed
content["timeout"] = ws.Timeout
}
case event.InventoryAction:
// no extra content
default:
return fmt.Errorf("invalid action group action: %+v", age)
}
return jf.printEvent("group", content)
}
func (jf *formatter) FormatSummary(s stats.Stats) error {
if s.ApplyStats != (stats.ApplyStats{}) {
as := s.ApplyStats
if err := jf.printEvent("apply", "completed", map[string]interface{}{
"count": as.Sum(),
"createdCount": as.Created,
"unchangedCount": as.Unchanged,
"configuredCount": as.Configured,
"serverSideCount": as.ServersideApplied,
"failedCount": as.Failed,
}); err != nil {
err := jf.printEvent("summary", map[string]interface{}{
"action": event.ApplyAction.String(),
"count": as.Sum(),
"successful": as.Successful,
"skipped": as.Skipped,
"failed": as.Failed,
})
if err != nil {
return err
}
}
if age.Action == event.PruneAction && age.Type == event.Finished &&
list.IsLastActionGroup(age, ags) {
if s.PruneStats != (stats.PruneStats{}) {
ps := s.PruneStats
return jf.printEvent("prune", "completed", map[string]interface{}{
"pruned": ps.Pruned,
"skipped": ps.Skipped,
"failed": ps.Failed,
err := jf.printEvent("summary", map[string]interface{}{
"action": event.PruneAction.String(),
"count": ps.Sum(),
"successful": ps.Successful,
"skipped": ps.Skipped,
"failed": ps.Failed,
})
if err != nil {
return err
}
}
if age.Action == event.DeleteAction && age.Type == event.Finished &&
list.IsLastActionGroup(age, ags) {
if s.DeleteStats != (stats.DeleteStats{}) {
ds := s.DeleteStats
return jf.printEvent("delete", "completed", map[string]interface{}{
"deleted": ds.Deleted,
"skipped": ds.Skipped,
"failed": ds.Failed,
err := jf.printEvent("summary", map[string]interface{}{
"action": event.DeleteAction.String(),
"count": ds.Sum(),
"successful": ds.Successful,
"skipped": ds.Skipped,
"failed": ds.Failed,
})
if err != nil {
return err
}
}
if age.Action == event.WaitAction && age.Type == event.Finished &&
list.IsLastActionGroup(age, ags) {
if s.WaitStats != (stats.WaitStats{}) {
ws := s.WaitStats
return jf.printEvent("wait", "completed", map[string]interface{}{
"reconciled": ws.Reconciled,
err := jf.printEvent("summary", map[string]interface{}{
"action": event.WaitAction.String(),
"count": ws.Sum(),
"successful": ws.Successful,
"skipped": ws.Skipped,
"timeout": ws.Timeout,
"failed": ws.Failed,
"timeout": ws.Timeout,
})
if err != nil {
return err
}
}
return nil
}
@ -174,11 +220,10 @@ func (jf *formatter) baseResourceEvent(identifier object.ObjMetadata) map[string
}
}
func (jf *formatter) printEvent(t, eventType string, content map[string]interface{}) error {
func (jf *formatter) printEvent(t string, content map[string]interface{}) error {
m := make(map[string]interface{})
m["timestamp"] = time.Now().UTC().Format(time.RFC3339)
m["timestamp"] = jf.now().UTC().Format(time.RFC3339)
m["type"] = t
m["eventType"] = eventType
for key, val := range content {
m[key] = val
}

View File

@ -8,8 +8,10 @@ import (
"errors"
"strings"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/cli-runtime/pkg/genericclioptions"
@ -22,6 +24,7 @@ import (
"sigs.k8s.io/cli-utils/pkg/object/validation"
"sigs.k8s.io/cli-utils/pkg/print/list"
"sigs.k8s.io/cli-utils/pkg/print/stats"
"sigs.k8s.io/cli-utils/pkg/testutil"
)
func TestFormatter_FormatApplyEvent(t *testing.T) {
@ -33,17 +36,16 @@ func TestFormatter_FormatApplyEvent(t *testing.T) {
"resource created without dryrun": {
previewStrategy: common.DryRunNone,
event: event.ApplyEvent{
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: []map[string]interface{}{
{
"eventType": "resourceApplied",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "default",
"operation": "Created",
"status": "Successful",
"timestamp": "",
"type": "apply",
},
@ -52,17 +54,16 @@ func TestFormatter_FormatApplyEvent(t *testing.T) {
"resource updated with client dryrun": {
previewStrategy: common.DryRunClient,
event: event.ApplyEvent{
Operation: event.Configured,
Status: event.ApplySuccessful,
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
},
expected: []map[string]interface{}{
{
"eventType": "resourceApplied",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "",
"operation": "Configured",
"status": "Successful",
"timestamp": "",
"type": "apply",
},
@ -71,35 +72,35 @@ func TestFormatter_FormatApplyEvent(t *testing.T) {
"resource updated with server dryrun": {
previewStrategy: common.DryRunServer,
event: event.ApplyEvent{
Operation: event.Configured,
Status: event.ApplySuccessful,
Identifier: createIdentifier("batch", "CronJob", "foo", "my-cron"),
},
expected: []map[string]interface{}{
{
"eventType": "resourceApplied",
"group": "batch",
"kind": "CronJob",
"name": "my-cron",
"namespace": "foo",
"operation": "Configured",
"status": "Successful",
"timestamp": "",
"type": "apply",
},
},
},
"resource apply error": {
"resource apply failed": {
previewStrategy: common.DryRunNone,
event: event.ApplyEvent{
Status: event.ApplyFailed,
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
Error: errors.New("example error"),
},
expected: []map[string]interface{}{
{
"eventType": "resourceFailed",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "",
"status": "Failed",
"timestamp": "",
"type": "apply",
"error": "example error",
@ -109,18 +110,17 @@ func TestFormatter_FormatApplyEvent(t *testing.T) {
"resource apply skip error": {
previewStrategy: common.DryRunNone,
event: event.ApplyEvent{
Operation: event.Unchanged,
Status: event.ApplySkipped,
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
Error: errors.New("example error"),
},
expected: []map[string]interface{}{
{
"eventType": "resourceApplied",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "",
"operation": "Unchanged",
"status": "Skipped",
"timestamp": "",
"type": "apply",
"error": "example error",
@ -179,7 +179,6 @@ func TestFormatter_FormatStatusEvent(t *testing.T) {
},
},
expected: map[string]interface{}{
"eventType": "resourceStatus",
"group": "apps",
"kind": "Deployment",
"message": "Resource is Current",
@ -213,16 +212,15 @@ func TestFormatter_FormatPruneEvent(t *testing.T) {
"resource pruned without dryrun": {
previewStrategy: common.DryRunNone,
event: event.PruneEvent{
Operation: event.Pruned,
Status: event.PruneSuccessful,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: map[string]interface{}{
"eventType": "resourcePruned",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "default",
"operation": "Pruned",
"status": "Successful",
"timestamp": "",
"type": "prune",
},
@ -230,32 +228,32 @@ func TestFormatter_FormatPruneEvent(t *testing.T) {
"resource skipped with client dryrun": {
previewStrategy: common.DryRunClient,
event: event.PruneEvent{
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
},
expected: map[string]interface{}{
"eventType": "resourcePruned",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "",
"operation": "PruneSkipped",
"status": "Skipped",
"timestamp": "",
"type": "prune",
},
},
"resource prune error": {
"resource prune failed": {
previewStrategy: common.DryRunNone,
event: event.PruneEvent{
Status: event.PruneFailed,
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
Error: errors.New("example error"),
},
expected: map[string]interface{}{
"eventType": "resourceFailed",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "",
"status": "Failed",
"timestamp": "",
"type": "prune",
"error": "example error",
@ -264,17 +262,16 @@ func TestFormatter_FormatPruneEvent(t *testing.T) {
"resource prune skip error": {
previewStrategy: common.DryRunNone,
event: event.PruneEvent{
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
Error: errors.New("example error"),
},
expected: map[string]interface{}{
"eventType": "resourcePruned",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "",
"operation": "PruneSkipped",
"status": "Skipped",
"timestamp": "",
"type": "prune",
"error": "example error",
@ -304,16 +301,15 @@ func TestFormatter_FormatDeleteEvent(t *testing.T) {
"resource deleted without no dryrun": {
previewStrategy: common.DryRunNone,
event: event.DeleteEvent{
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: map[string]interface{}{
"eventType": "resourceDeleted",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "default",
"operation": "Deleted",
"status": "Successful",
"timestamp": "",
"type": "delete",
},
@ -321,32 +317,32 @@ func TestFormatter_FormatDeleteEvent(t *testing.T) {
"resource skipped with client dryrun": {
previewStrategy: common.DryRunClient,
event: event.DeleteEvent{
Operation: event.DeleteSkipped,
Status: event.DeleteSkipped,
Identifier: createIdentifier("apps", "Deployment", "", "my-dep"),
},
expected: map[string]interface{}{
"eventType": "resourceDeleted",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "",
"operation": "DeleteSkipped",
"status": "Skipped",
"timestamp": "",
"type": "delete",
},
},
"resource delete error": {
"resource delete failed": {
previewStrategy: common.DryRunNone,
event: event.DeleteEvent{
Status: event.DeleteFailed,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
Error: errors.New("example error"),
},
expected: map[string]interface{}{
"eventType": "resourceFailed",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "default",
"status": "Failed",
"timestamp": "",
"type": "delete",
"error": "example error",
@ -355,17 +351,16 @@ func TestFormatter_FormatDeleteEvent(t *testing.T) {
"resource delete skip error": {
previewStrategy: common.DryRunNone,
event: event.DeleteEvent{
Operation: event.DeleteSkipped,
Status: event.DeleteSkipped,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
Error: errors.New("example error"),
},
expected: map[string]interface{}{
"eventType": "resourceDeleted",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "default",
"operation": "DeleteSkipped",
"status": "Skipped",
"timestamp": "",
"type": "delete",
"error": "example error",
@ -396,16 +391,15 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
previewStrategy: common.DryRunNone,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: map[string]interface{}{
"eventType": "resourceReconciled",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "default",
"operation": "Reconciled",
"status": "Successful",
"timestamp": "",
"type": "wait",
},
@ -414,16 +408,15 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
previewStrategy: common.DryRunClient,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: map[string]interface{}{
"eventType": "resourceReconciled",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "default",
"operation": "Reconciled",
"status": "Successful",
"timestamp": "",
"type": "wait",
},
@ -432,16 +425,15 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
previewStrategy: common.DryRunServer,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: map[string]interface{}{
"eventType": "resourceReconciled",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "default",
"operation": "Reconciled",
"status": "Successful",
"timestamp": "",
"type": "wait",
},
@ -450,16 +442,15 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
previewStrategy: common.DryRunServer,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: map[string]interface{}{
"eventType": "resourceReconciled",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "default",
"operation": "Pending",
"status": "Pending",
"timestamp": "",
"type": "wait",
},
@ -468,16 +459,15 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
previewStrategy: common.DryRunServer,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: map[string]interface{}{
"eventType": "resourceReconciled",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "default",
"operation": "Skipped",
"status": "Skipped",
"timestamp": "",
"type": "wait",
},
@ -486,16 +476,15 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
previewStrategy: common.DryRunServer,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.ReconcileTimeout,
Status: event.ReconcileTimeout,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: map[string]interface{}{
"eventType": "resourceReconciled",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "default",
"operation": "Timeout",
"status": "Timeout",
"timestamp": "",
"type": "wait",
},
@ -504,16 +493,15 @@ func TestFormatter_FormatWaitEvent(t *testing.T) {
previewStrategy: common.DryRunNone,
event: event.WaitEvent{
GroupName: "wait-1",
Operation: event.ReconcileFailed,
Status: event.ReconcileFailed,
Identifier: createIdentifier("apps", "Deployment", "default", "my-dep"),
},
expected: map[string]interface{}{
"eventType": "resourceReconciled",
"group": "apps",
"kind": "Deployment",
"name": "my-dep",
"namespace": "default",
"operation": "Failed",
"status": "Failed",
"timestamp": "",
"type": "wait",
},
@ -546,7 +534,7 @@ func TestFormatter_FormatActionGroupEvent(t *testing.T) {
event: event.ActionGroupEvent{
GroupName: "age-1",
Action: event.ApplyAction,
Type: event.Finished,
Status: event.Finished,
},
actionGroups: []event.ActionGroup{
{
@ -558,14 +546,26 @@ func TestFormatter_FormatActionGroupEvent(t *testing.T) {
Action: event.ApplyAction,
},
},
expected: map[string]interface{}{},
statsCollector: stats.Stats{
ApplyStats: stats.ApplyStats{},
},
expected: map[string]interface{}{
"action": "Apply",
"count": 0,
"failed": 0,
"skipped": 0,
"status": "Finished",
"successful": 0,
"timestamp": "2022-03-24T01:35:04Z",
"type": "group",
},
},
"the last apply action group finished": {
previewStrategy: common.DryRunNone,
event: event.ActionGroupEvent{
GroupName: "age-2",
Action: event.ApplyAction,
Type: event.Finished,
Status: event.Finished,
},
actionGroups: []event.ActionGroup{
{
@ -579,19 +579,18 @@ func TestFormatter_FormatActionGroupEvent(t *testing.T) {
},
statsCollector: stats.Stats{
ApplyStats: stats.ApplyStats{
ServersideApplied: 42,
Successful: 42,
},
},
expected: map[string]interface{}{
"eventType": "completed",
"configuredCount": 0,
"count": 42,
"createdCount": 0,
"failedCount": 0,
"serverSideCount": 42,
"timestamp": "2022-01-06T05:22:48Z",
"type": "apply",
"unchangedCount": 0,
"action": "Apply",
"count": 42,
"failed": 0,
"skipped": 0,
"status": "Finished",
"successful": 42,
"timestamp": "2022-03-24T01:35:04Z",
"type": "group",
},
},
"last prune action group started": {
@ -599,7 +598,7 @@ func TestFormatter_FormatActionGroupEvent(t *testing.T) {
event: event.ActionGroupEvent{
GroupName: "age-2",
Action: event.PruneAction,
Type: event.Started,
Status: event.Started,
},
actionGroups: []event.ActionGroup{
{
@ -611,7 +610,12 @@ func TestFormatter_FormatActionGroupEvent(t *testing.T) {
Action: event.PruneAction,
},
},
expected: map[string]interface{}{},
expected: map[string]interface{}{
"action": "Prune",
"status": "Started",
"timestamp": "2022-03-24T01:51:36Z",
"type": "group",
},
},
}
@ -668,7 +672,6 @@ func TestFormatter_FormatValidationEvent(t *testing.T) {
),
},
expected: map[string]interface{}{
"eventType": "validation",
"type": "validation",
"timestamp": "",
"objects": []interface{}{
@ -763,7 +766,6 @@ func TestFormatter_FormatValidationEvent(t *testing.T) {
),
},
expected: map[string]interface{}{
"eventType": "validation",
"type": "validation",
"timestamp": "",
"objects": []interface{}{
@ -802,6 +804,93 @@ func TestFormatter_FormatValidationEvent(t *testing.T) {
}
}
func TestFormatter_FormatSummary(t *testing.T) {
now := time.Now()
nowStr := now.UTC().Format(time.RFC3339)
testCases := map[string]struct {
statsCollector stats.Stats
expected []map[string]interface{}
}{
"apply prune wait": {
statsCollector: stats.Stats{
ApplyStats: stats.ApplyStats{
Successful: 1,
Skipped: 2,
Failed: 3,
},
PruneStats: stats.PruneStats{
Successful: 3,
Skipped: 2,
Failed: 1,
},
WaitStats: stats.WaitStats{
Successful: 4,
Skipped: 6,
Failed: 1,
Timeout: 1,
},
},
expected: []map[string]interface{}{
{
"action": "Apply",
"count": float64(6),
"successful": float64(1),
"skipped": float64(2),
"failed": float64(3),
"timestamp": nowStr,
"type": "summary",
},
{
"action": "Prune",
"count": float64(6),
"successful": float64(3),
"skipped": float64(2),
"failed": float64(1),
"timestamp": nowStr,
"type": "summary",
},
{
"action": "Wait",
"count": float64(12),
"successful": float64(4),
"skipped": float64(6),
"failed": float64(1),
"timeout": float64(1),
"timestamp": nowStr,
"type": "summary",
},
},
},
}
for tn, tc := range testCases {
t.Run(tn, func(t *testing.T) {
ioStreams, _, out, _ := genericclioptions.NewTestIOStreams() //nolint:dogsled
jf := &formatter{
ioStreams: ioStreams,
// fake time func
now: func() time.Time { return now },
}
err := jf.FormatSummary(tc.statsCollector)
assert.NoError(t, err)
assertOutputLines(t, tc.expected, out.String())
})
}
}
func assertOutputLines(t *testing.T, expectedMaps []map[string]interface{}, actual string) {
actual = strings.TrimRight(actual, "\n")
lines := strings.Split(actual, "\n")
actualMaps := make([]map[string]interface{}, len(lines))
for i, line := range lines {
err := json.Unmarshal([]byte(line), &actualMaps[i])
require.NoError(t, err)
}
testutil.AssertEqual(t, expectedMaps, actualMaps)
}
// nolint:unparam
func assertOutput(t *testing.T, expectedMap map[string]interface{}, actual string) bool {
if len(expectedMap) == 0 {

View File

@ -0,0 +1,19 @@
// Copyright 2020 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package json
import (
"testing"
"k8s.io/cli-runtime/pkg/genericclioptions"
"sigs.k8s.io/cli-utils/pkg/printers/printer"
printertesting "sigs.k8s.io/cli-utils/pkg/printers/testutil"
)
func TestPrint(t *testing.T) {
printertesting.PrintResultErrorTest(t, func() printer.Printer {
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
return NewPrinter(ioStreams)
})
}

View File

@ -58,6 +58,9 @@ type resourceStateCollector struct {
// the latest state for the given resource.
resourceInfos map[object.ObjMetadata]*resourceInfo
// stats collect statistics from handled events
stats stats.Stats
err error
}
@ -82,21 +85,21 @@ type resourceInfo struct {
// the desired action on the resource.
Error error
// ApplyOpResult contains the result after
// ApplyStatus contains the result after
// a resource has been applied to the cluster.
ApplyOpResult event.ApplyEventOperation
ApplyStatus event.ApplyEventStatus
// PruneOpResult contains the result after
// PruneStatus contains the result after
// a prune operation on a resource
PruneOpResult event.PruneEventOperation
PruneStatus event.PruneEventStatus
// DeleteOpResult contains the result after
// DeleteStatus contains the result after
// a delete operation on a resource
DeleteOpResult event.DeleteEventOperation
DeleteStatus event.DeleteEventStatus
// WaitOpResult contains the result after
// WaitStatus contains the result after
// a wait operation on a resource
WaitOpResult event.WaitEventOperation
WaitStatus event.WaitEventStatus
}
// Identifier returns the identifier for the given resource.
@ -193,6 +196,8 @@ func (r *resourceStateCollector) processEvent(ev event.Event) error {
r.processApplyEvent(ev.ApplyEvent)
case event.PruneType:
r.processPruneEvent(ev.PruneEvent)
case event.DeleteType:
r.processDeleteEvent(ev.DeleteEvent)
case event.WaitType:
r.processWaitEvent(ev.WaitEvent)
case event.ErrorType:
@ -253,7 +258,8 @@ func (r *resourceStateCollector) processApplyEvent(e event.ApplyEvent) {
if e.Error != nil {
previous.Error = e.Error
}
previous.ApplyOpResult = e.Operation
previous.ApplyStatus = e.Status
r.stats.ApplyStats.Inc(e.Status)
}
// processPruneEvent handles event related to prune operations.
@ -268,7 +274,24 @@ func (r *resourceStateCollector) processPruneEvent(e event.PruneEvent) {
if e.Error != nil {
previous.Error = e.Error
}
previous.PruneOpResult = e.Operation
previous.PruneStatus = e.Status
r.stats.PruneStats.Inc(e.Status)
}
// processDeleteEvent handles event related to delete operations.
func (r *resourceStateCollector) processDeleteEvent(e event.DeleteEvent) {
identifier := e.Identifier
klog.V(7).Infof("processing delete event for %s", identifier)
previous, found := r.resourceInfos[identifier]
if !found {
klog.V(4).Infof("%s delete event not found in ResourceInfos; no processing", identifier)
return
}
if e.Error != nil {
previous.Error = e.Error
}
previous.DeleteStatus = e.Status
r.stats.DeleteStats.Inc(e.Status)
}
// processPruneEvent handles event related to prune operations.
@ -280,7 +303,8 @@ func (r *resourceStateCollector) processWaitEvent(e event.WaitEvent) {
klog.V(4).Infof("%s wait event not found in ResourceInfos; no processing", identifier)
return
}
previous.WaitOpResult = e.Operation
previous.WaitStatus = e.Status
r.stats.WaitStats.Inc(e.Status)
}
// ResourceState contains the latest state for all the resources.
@ -316,10 +340,10 @@ func (r *resourceStateCollector) LatestState() *ResourceState {
identifier: ri.identifier,
resourceStatus: ri.resourceStatus,
ResourceAction: ri.ResourceAction,
ApplyOpResult: ri.ApplyOpResult,
PruneOpResult: ri.PruneOpResult,
DeleteOpResult: ri.DeleteOpResult,
WaitOpResult: ri.WaitOpResult,
ApplyStatus: ri.ApplyStatus,
PruneStatus: ri.PruneStatus,
DeleteStatus: ri.DeleteStatus,
WaitStatus: ri.WaitStatus,
})
}
sort.Sort(resourceInfos)
@ -330,33 +354,6 @@ func (r *resourceStateCollector) LatestState() *ResourceState {
}
}
// Stats returns a summary of the results from the actuation operation
// as a stats.Stats object.
func (r *resourceStateCollector) Stats() stats.Stats {
var s stats.Stats
for _, res := range r.resourceInfos {
switch res.ResourceAction {
case event.ApplyAction:
if res.Error != nil {
s.ApplyStats.IncFailed()
}
s.ApplyStats.Inc(res.ApplyOpResult)
case event.PruneAction:
if res.Error != nil {
s.PruneStats.IncFailed()
}
s.PruneStats.Inc(res.PruneOpResult)
case event.DeleteAction:
if res.Error != nil {
s.DeleteStats.IncFailed()
}
s.DeleteStats.Inc(res.DeleteOpResult)
}
s.WaitStats.Inc(res.WaitOpResult)
}
return s
}
type ResourceInfos []*resourceInfo
func (g ResourceInfos) Len() int {

View File

@ -68,7 +68,7 @@ func (t *Printer) Print(ch <-chan event.Event, _ common.DryRunStrategy, _ bool)
}
// If no fatal errors happened, we will return a ResultError if
// one or more resources failed to apply/prune or reconcile.
return printcommon.ResultErrorFromStats(coll.Stats())
return printcommon.ResultErrorFromStats(coll.stats)
}
// columns defines the columns we want to print
@ -96,12 +96,12 @@ var (
var text string
switch resInfo.ResourceAction {
case event.ApplyAction:
if resInfo.ApplyOpResult != event.ApplyUnspecified {
text = resInfo.ApplyOpResult.String()
if resInfo.ApplyStatus != event.ApplyFailed {
text = resInfo.ApplyStatus.String()
}
case event.PruneAction:
if resInfo.PruneOpResult != event.PruneUnspecified {
text = resInfo.PruneOpResult.String()
if resInfo.PruneStatus != event.PruneFailed {
text = resInfo.PruneStatus.String()
}
}
@ -133,7 +133,7 @@ var (
var text string
switch resInfo.ResourceAction {
case event.WaitAction:
text = resInfo.WaitOpResult.String()
text = resInfo.WaitStatus.String()
}
if len(text) > width {

View File

@ -14,11 +14,6 @@ import (
printertesting "sigs.k8s.io/cli-utils/pkg/printers/testutil"
)
var (
createdOpResult = event.Created
prunedOpResult = event.Pruned
)
func TestActionColumnDef(t *testing.T) {
testCases := map[string]struct {
resource table.Resource
@ -33,31 +28,31 @@ func TestActionColumnDef(t *testing.T) {
"neither applied nor pruned": {
resource: &resourceInfo{},
columnWidth: 15,
expectedOutput: "",
expectedOutput: "Pending",
},
"applied": {
resource: &resourceInfo{
ResourceAction: event.ApplyAction,
ApplyOpResult: createdOpResult,
ApplyStatus: event.ApplySuccessful,
},
columnWidth: 15,
expectedOutput: "Created",
expectedOutput: "Successful",
},
"pruned": {
resource: &resourceInfo{
ResourceAction: event.PruneAction,
PruneOpResult: prunedOpResult,
PruneStatus: event.PruneSuccessful,
},
columnWidth: 15,
expectedOutput: "Pruned",
expectedOutput: "Successful",
},
"trimmed output": {
resource: &resourceInfo{
ResourceAction: event.ApplyAction,
ApplyOpResult: createdOpResult,
ApplyStatus: event.ApplySuccessful,
},
columnWidth: 5,
expectedOutput: "Creat",
expectedOutput: "Succe",
},
}

View File

@ -57,20 +57,54 @@ func PrintResultErrorTest(t *testing.T, f PrinterFactoryFunc) {
},
},
},
{
Type: event.ActionGroupType,
ActionGroupEvent: event.ActionGroupEvent{
GroupName: "apply-1",
Action: event.ApplyAction,
Status: event.Started,
},
},
{
Type: event.ApplyType,
ApplyEvent: event.ApplyEvent{
Operation: event.Created,
GroupName: "apply-1",
Status: event.ApplySuccessful,
Identifier: deploymentIdentifier,
},
},
{
Type: event.ActionGroupType,
ActionGroupEvent: event.ActionGroupEvent{
GroupName: "apply-1",
Action: event.ApplyAction,
Status: event.Finished,
},
},
{
Type: event.ActionGroupType,
ActionGroupEvent: event.ActionGroupEvent{
GroupName: "wait-1",
Action: event.WaitAction,
Status: event.Started,
},
},
{
Type: event.WaitType,
WaitEvent: event.WaitEvent{
Operation: event.Reconciled,
GroupName: "wait-1",
Status: event.ReconcileSuccessful,
Identifier: deploymentIdentifier,
},
},
{
Type: event.ActionGroupType,
ActionGroupEvent: event.ActionGroupEvent{
GroupName: "wait-1",
Action: event.WaitAction,
Status: event.Finished,
},
},
},
expectedErr: nil,
},
@ -97,25 +131,59 @@ func PrintResultErrorTest(t *testing.T, f PrinterFactoryFunc) {
},
},
},
{
Type: event.ActionGroupType,
ActionGroupEvent: event.ActionGroupEvent{
GroupName: "apply-1",
Action: event.ApplyAction,
Status: event.Started,
},
},
{
Type: event.ApplyType,
ApplyEvent: event.ApplyEvent{
Operation: event.Created,
GroupName: "apply-1",
Status: event.ApplySuccessful,
Identifier: deploymentIdentifier,
},
},
{
Type: event.ActionGroupType,
ActionGroupEvent: event.ActionGroupEvent{
GroupName: "apply-1",
Action: event.ApplyAction,
Status: event.Finished,
},
},
{
Type: event.ActionGroupType,
ActionGroupEvent: event.ActionGroupEvent{
GroupName: "wait-1",
Action: event.WaitAction,
Status: event.Started,
},
},
{
Type: event.WaitType,
WaitEvent: event.WaitEvent{
Operation: event.ReconcileFailed,
GroupName: "wait-1",
Status: event.ReconcileFailed,
Identifier: deploymentIdentifier,
},
},
{
Type: event.ActionGroupType,
ActionGroupEvent: event.ActionGroupEvent{
GroupName: "wait-1",
Action: event.WaitAction,
Status: event.Finished,
},
},
},
expectedErr: &printcommon.ResultError{
Stats: stats.Stats{
ApplyStats: stats.ApplyStats{
Created: 1,
Successful: 1,
},
WaitStats: stats.WaitStats{
Failed: 1,
@ -146,21 +214,55 @@ func PrintResultErrorTest(t *testing.T, f PrinterFactoryFunc) {
},
},
},
{
Type: event.ActionGroupType,
ActionGroupEvent: event.ActionGroupEvent{
GroupName: "apply-1",
Action: event.ApplyAction,
Status: event.Started,
},
},
{
Type: event.ApplyType,
ApplyEvent: event.ApplyEvent{
Operation: event.ApplyUnspecified,
GroupName: "apply-1",
Status: event.ApplyFailed,
Identifier: deploymentIdentifier,
Error: fmt.Errorf("apply failed"),
},
},
{
Type: event.ActionGroupType,
ActionGroupEvent: event.ActionGroupEvent{
GroupName: "apply-1",
Action: event.ApplyAction,
Status: event.Finished,
},
},
{
Type: event.ActionGroupType,
ActionGroupEvent: event.ActionGroupEvent{
GroupName: "wait-1",
Action: event.WaitAction,
Status: event.Started,
},
},
{
Type: event.WaitType,
WaitEvent: event.WaitEvent{
Operation: event.ReconcileSkipped,
GroupName: "wait-1",
Status: event.ReconcileSkipped,
Identifier: deploymentIdentifier,
},
},
{
Type: event.ActionGroupType,
ActionGroupEvent: event.ActionGroupEvent{
GroupName: "wait-1",
Action: event.WaitAction,
Status: event.Finished,
},
},
},
expectedErr: &printcommon.ResultError{
Stats: stats.Stats{

View File

@ -39,39 +39,39 @@ type ExpErrorEvent struct {
type ExpActionGroupEvent struct {
GroupName string
Action event.ResourceAction
Type event.ActionGroupEventType
Type event.ActionGroupEventStatus
}
type ExpApplyEvent struct {
GroupName string
Operation event.ApplyEventOperation
Status event.ApplyEventStatus
Identifier object.ObjMetadata
Error error
}
type ExpStatusEvent struct {
Identifier object.ObjMetadata
Status status.Status
Identifier object.ObjMetadata
Error error
}
type ExpPruneEvent struct {
GroupName string
Operation event.PruneEventOperation
Status event.PruneEventStatus
Identifier object.ObjMetadata
Error error
}
type ExpDeleteEvent struct {
GroupName string
Operation event.DeleteEventOperation
Status event.DeleteEventStatus
Identifier object.ObjMetadata
Error error
}
type ExpWaitEvent struct {
GroupName string
Operation event.WaitEventOperation
Status event.WaitEventStatus
Identifier object.ObjMetadata
}
@ -142,7 +142,7 @@ func isMatch(ee ExpEvent, e event.Event) bool {
return false
}
if agee.Type != age.Type {
if agee.Type != age.Status {
return false
}
return true
@ -167,7 +167,7 @@ func isMatch(ee ExpEvent, e event.Event) bool {
}
}
if aee.Operation != ae.Operation {
if aee.Status != ae.Status {
return false
}
@ -215,7 +215,7 @@ func isMatch(ee ExpEvent, e event.Event) bool {
}
}
if pee.Operation != pe.Operation {
if pee.Status != pe.Status {
return false
}
@ -243,7 +243,7 @@ func isMatch(ee ExpEvent, e event.Event) bool {
}
}
if dee.Operation != de.Operation {
if dee.Status != de.Status {
return false
}
@ -271,7 +271,7 @@ func isMatch(ee ExpEvent, e event.Event) bool {
}
}
if wee.Operation != we.Operation {
if wee.Status != we.Status {
return false
}
return true
@ -332,7 +332,7 @@ func EventToExpEvent(e event.Event) ExpEvent {
ActionGroupEvent: &ExpActionGroupEvent{
GroupName: e.ActionGroupEvent.GroupName,
Action: e.ActionGroupEvent.Action,
Type: e.ActionGroupEvent.Type,
Type: e.ActionGroupEvent.Status,
},
}
@ -342,7 +342,7 @@ func EventToExpEvent(e event.Event) ExpEvent {
ApplyEvent: &ExpApplyEvent{
GroupName: e.ApplyEvent.GroupName,
Identifier: e.ApplyEvent.Identifier,
Operation: e.ApplyEvent.Operation,
Status: e.ApplyEvent.Status,
Error: e.ApplyEvent.Error,
},
}
@ -363,7 +363,7 @@ func EventToExpEvent(e event.Event) ExpEvent {
PruneEvent: &ExpPruneEvent{
GroupName: e.PruneEvent.GroupName,
Identifier: e.PruneEvent.Identifier,
Operation: e.PruneEvent.Operation,
Status: e.PruneEvent.Status,
Error: e.PruneEvent.Error,
},
}
@ -374,7 +374,7 @@ func EventToExpEvent(e event.Event) ExpEvent {
DeleteEvent: &ExpDeleteEvent{
GroupName: e.DeleteEvent.GroupName,
Identifier: e.DeleteEvent.Identifier,
Operation: e.DeleteEvent.Operation,
Status: e.DeleteEvent.Status,
Error: e.DeleteEvent.Error,
},
}
@ -385,7 +385,7 @@ func EventToExpEvent(e event.Event) ExpEvent {
WaitEvent: &ExpWaitEvent{
GroupName: e.WaitEvent.GroupName,
Identifier: e.WaitEvent.Identifier,
Operation: e.WaitEvent.Operation,
Status: e.WaitEvent.Status,
},
}
@ -454,12 +454,12 @@ func (ape GroupedEventsByID) Less(i, j int) bool {
// don't change order if not the same task group
return false
}
if ape[i].WaitEvent.Operation != ape[j].WaitEvent.Operation {
// don't change order if not the same operation
if ape[i].WaitEvent.Status != ape[j].WaitEvent.Status {
// don't change order if not the same status
return false
}
if ape[i].WaitEvent.Operation != event.Reconciled {
// pending, skipped, and timeout operations are predictably ordered
if ape[i].WaitEvent.Status != event.ReconcileSuccessful {
// pending, skipped, and timeout status are predictably ordered
// using the order in WaitTask.Ids.
// So we only need to sort Reconciled events, which occur in the
// order the Waitask receives StatusEvents with Current/NotFound.

View File

@ -77,7 +77,7 @@ func applyAndDestroyTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
Error: nil,
},
@ -105,7 +105,7 @@ func applyAndDestroyTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
},
},
@ -114,7 +114,7 @@ func applyAndDestroyTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
},
},
@ -217,7 +217,7 @@ func applyAndDestroyTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-0",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
Error: nil,
},
@ -245,7 +245,7 @@ func applyAndDestroyTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
},
},
@ -254,7 +254,7 @@ func applyAndDestroyTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
},
},

View File

@ -85,7 +85,7 @@ func continueOnErrorTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
Error: nil,
},
@ -113,7 +113,7 @@ func continueOnErrorTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
Identifier: object.UnstructuredToObjMetadata(invalidCrdObj),
},
},
@ -122,7 +122,7 @@ func continueOnErrorTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -131,7 +131,7 @@ func continueOnErrorTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},

View File

@ -79,7 +79,7 @@ func crdTest(ctx context.Context, _ client.Client, invConfig invconfig.Inventory
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(crdObj),
Error: nil,
},
@ -107,7 +107,7 @@ func crdTest(ctx context.Context, _ client.Client, invConfig invconfig.Inventory
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(crdObj),
},
},
@ -116,7 +116,7 @@ func crdTest(ctx context.Context, _ client.Client, invConfig invconfig.Inventory
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(crdObj),
},
},
@ -143,7 +143,7 @@ func crdTest(ctx context.Context, _ client.Client, invConfig invconfig.Inventory
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-1",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(crObj),
Error: nil,
},
@ -171,7 +171,7 @@ func crdTest(ctx context.Context, _ client.Client, invConfig invconfig.Inventory
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(crObj),
},
},
@ -180,7 +180,7 @@ func crdTest(ctx context.Context, _ client.Client, invConfig invconfig.Inventory
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(crObj),
},
},
@ -239,7 +239,7 @@ func crdTest(ctx context.Context, _ client.Client, invConfig invconfig.Inventory
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-0",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(crObj),
Error: nil,
},
@ -267,7 +267,7 @@ func crdTest(ctx context.Context, _ client.Client, invConfig invconfig.Inventory
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(crObj),
},
},
@ -276,7 +276,7 @@ func crdTest(ctx context.Context, _ client.Client, invConfig invconfig.Inventory
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(crObj),
},
},
@ -303,7 +303,7 @@ func crdTest(ctx context.Context, _ client.Client, invConfig invconfig.Inventory
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-1",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(crdObj),
Error: nil,
},
@ -331,7 +331,7 @@ func crdTest(ctx context.Context, _ client.Client, invConfig invconfig.Inventory
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(crdObj),
},
},
@ -340,7 +340,7 @@ func crdTest(ctx context.Context, _ client.Client, invConfig invconfig.Inventory
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(crdObj),
},
},

View File

@ -87,7 +87,7 @@ func dependencyFilterTest(ctx context.Context, c client.Client, invConfig invcon
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
Error: nil,
},
@ -115,7 +115,7 @@ func dependencyFilterTest(ctx context.Context, c client.Client, invConfig invcon
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
},
},
@ -124,7 +124,7 @@ func dependencyFilterTest(ctx context.Context, c client.Client, invConfig invcon
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
},
},
@ -151,7 +151,7 @@ func dependencyFilterTest(ctx context.Context, c client.Client, invConfig invcon
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-1",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
Error: nil,
},
@ -179,7 +179,7 @@ func dependencyFilterTest(ctx context.Context, c client.Client, invConfig invcon
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -188,7 +188,7 @@ func dependencyFilterTest(ctx context.Context, c client.Client, invConfig invcon
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -284,7 +284,7 @@ func dependencyFilterTest(ctx context.Context, c client.Client, invConfig invcon
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Unchanged,
Status: event.ApplySkipped,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
Error: testutil.EqualError(&filter.DependencyActuationMismatchError{
Object: object.UnstructuredToObjMetadata(pod1Obj),
@ -318,7 +318,7 @@ func dependencyFilterTest(ctx context.Context, c client.Client, invConfig invcon
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -345,7 +345,7 @@ func dependencyFilterTest(ctx context.Context, c client.Client, invConfig invcon
EventType: event.PruneType,
PruneEvent: &testutil.ExpPruneEvent{
GroupName: "prune-0",
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
Error: testutil.EqualError(&filter.DependencyActuationMismatchError{
Object: object.UnstructuredToObjMetadata(pod2Obj),
@ -379,7 +379,7 @@ func dependencyFilterTest(ctx context.Context, c client.Client, invConfig invcon
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
},
},

View File

@ -95,7 +95,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
},
},
@ -104,7 +104,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(namespace2Obj),
},
},
@ -131,7 +131,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
},
},
@ -140,7 +140,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(namespace2Obj),
},
},
@ -149,7 +149,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
},
},
@ -158,7 +158,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(namespace2Obj),
},
},
@ -185,7 +185,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-1",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
Error: nil,
},
@ -213,7 +213,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
},
},
@ -222,7 +222,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
},
},
@ -249,7 +249,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-2",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(pod3Obj),
Error: nil,
},
@ -277,7 +277,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-2",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod3Obj),
},
},
@ -286,7 +286,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-2",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod3Obj),
},
},
@ -313,7 +313,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-3",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
Error: nil,
},
@ -341,7 +341,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-3",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -350,7 +350,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-3",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -436,7 +436,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-0",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
Error: nil,
},
@ -464,7 +464,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -473,7 +473,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -500,7 +500,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-1",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod3Obj),
Error: nil,
},
@ -528,7 +528,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod3Obj),
},
},
@ -537,7 +537,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod3Obj),
},
},
@ -564,7 +564,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-2",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
Error: nil,
},
@ -592,7 +592,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-2",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
},
},
@ -601,7 +601,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-2",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
},
},
@ -628,7 +628,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-3",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(namespace2Obj),
},
},
@ -637,7 +637,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-3",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
},
},
@ -664,7 +664,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-3",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(namespace2Obj),
},
},
@ -673,7 +673,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-3",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
},
},
@ -682,7 +682,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-3",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
},
},
@ -691,7 +691,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-3",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(namespace2Obj),
},
},

View File

@ -87,7 +87,7 @@ func dryRunTest(ctx context.Context, c client.Client, invConfig invconfig.Invent
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
Error: nil,
},
@ -115,7 +115,7 @@ func dryRunTest(ctx context.Context, c client.Client, invConfig invconfig.Invent
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-1",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(podBObj),
Error: nil,
},
@ -223,7 +223,7 @@ func dryRunTest(ctx context.Context, c client.Client, invConfig invconfig.Invent
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-0",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(podBObj),
Error: nil,
},
@ -251,7 +251,7 @@ func dryRunTest(ctx context.Context, c client.Client, invConfig invconfig.Invent
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-1",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
Error: nil,
},

View File

@ -91,7 +91,7 @@ func inventoryPolicyMustMatchTest(ctx context.Context, c client.Client, invConfi
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Unchanged,
Status: event.ApplySkipped,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
Error: &inventory.PolicyPreventedActuationError{
Strategy: actuation.ActuationStrategyApply,
@ -123,7 +123,7 @@ func inventoryPolicyMustMatchTest(ctx context.Context, c client.Client, invConfi
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
},
},
@ -252,7 +252,7 @@ func inventoryPolicyAdoptIfNoInventoryTest(ctx context.Context, c client.Client,
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Configured,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
Error: nil,
},
@ -280,7 +280,7 @@ func inventoryPolicyAdoptIfNoInventoryTest(ctx context.Context, c client.Client,
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
},
},
@ -289,7 +289,7 @@ func inventoryPolicyAdoptIfNoInventoryTest(ctx context.Context, c client.Client,
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
},
},
@ -434,7 +434,7 @@ func inventoryPolicyAdoptAllTest(ctx context.Context, c client.Client, invConfig
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Configured,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
Error: nil,
},
@ -462,7 +462,7 @@ func inventoryPolicyAdoptAllTest(ctx context.Context, c client.Client, invConfig
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
},
},
@ -471,7 +471,7 @@ func inventoryPolicyAdoptAllTest(ctx context.Context, c client.Client, invConfig
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
},
},

View File

@ -93,7 +93,7 @@ func mutationTest(ctx context.Context, c client.Client, invConfig invconfig.Inve
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(podBObj),
Error: nil,
},
@ -121,7 +121,7 @@ func mutationTest(ctx context.Context, c client.Client, invConfig invconfig.Inve
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(podBObj),
},
},
@ -130,7 +130,7 @@ func mutationTest(ctx context.Context, c client.Client, invConfig invconfig.Inve
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(podBObj),
},
},
@ -157,7 +157,7 @@ func mutationTest(ctx context.Context, c client.Client, invConfig invconfig.Inve
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-1",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(podAObj),
Error: nil,
},
@ -185,7 +185,7 @@ func mutationTest(ctx context.Context, c client.Client, invConfig invconfig.Inve
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(podAObj),
},
},
@ -194,7 +194,7 @@ func mutationTest(ctx context.Context, c client.Client, invConfig invconfig.Inve
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(podAObj),
},
},
@ -281,7 +281,7 @@ func mutationTest(ctx context.Context, c client.Client, invConfig invconfig.Inve
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-0",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(podAObj),
Error: nil,
},
@ -309,7 +309,7 @@ func mutationTest(ctx context.Context, c client.Client, invConfig invconfig.Inve
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(podAObj),
},
},
@ -318,7 +318,7 @@ func mutationTest(ctx context.Context, c client.Client, invConfig invconfig.Inve
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(podAObj),
},
},
@ -345,7 +345,7 @@ func mutationTest(ctx context.Context, c client.Client, invConfig invconfig.Inve
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-1",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(podBObj),
Error: nil,
},
@ -373,7 +373,7 @@ func mutationTest(ctx context.Context, c client.Client, invConfig invconfig.Inve
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(podBObj),
},
},
@ -382,7 +382,7 @@ func mutationTest(ctx context.Context, c client.Client, invConfig invconfig.Inve
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(podBObj),
},
},

View File

@ -89,7 +89,7 @@ func namespaceFilterTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
Error: nil,
},
@ -117,7 +117,7 @@ func namespaceFilterTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
},
},
@ -126,7 +126,7 @@ func namespaceFilterTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
},
},
@ -153,7 +153,7 @@ func namespaceFilterTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-1",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(podBObj),
Error: nil,
},
@ -181,7 +181,7 @@ func namespaceFilterTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(podBObj),
},
},
@ -190,7 +190,7 @@ func namespaceFilterTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(podBObj),
},
},
@ -281,7 +281,7 @@ func namespaceFilterTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Unchanged,
Status: event.ApplySkipped,
Identifier: object.UnstructuredToObjMetadata(podBObj),
Error: testutil.EqualError(&filter.DependencyActuationMismatchError{
Object: object.UnstructuredToObjMetadata(podBObj),
@ -315,7 +315,7 @@ func namespaceFilterTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
Identifier: object.UnstructuredToObjMetadata(podBObj),
},
},
@ -342,7 +342,7 @@ func namespaceFilterTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.PruneType,
PruneEvent: &testutil.ExpPruneEvent{
GroupName: "prune-0",
Operation: event.PruneSkipped,
Status: event.PruneSkipped,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
Error: testutil.EqualError(&filter.NamespaceInUseError{
Namespace: namespace1Name,
@ -372,7 +372,7 @@ func namespaceFilterTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.ReconcileSkipped,
Status: event.ReconcileSkipped,
Identifier: object.UnstructuredToObjMetadata(namespace1Obj),
},
},

View File

@ -75,7 +75,7 @@ func pruneRetrieveErrorTest(ctx context.Context, c client.Client, invConfig invc
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
Error: nil,
},
@ -103,7 +103,7 @@ func pruneRetrieveErrorTest(ctx context.Context, c client.Client, invConfig invc
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -112,7 +112,7 @@ func pruneRetrieveErrorTest(ctx context.Context, c client.Client, invConfig invc
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -209,7 +209,7 @@ func pruneRetrieveErrorTest(ctx context.Context, c client.Client, invConfig invc
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
Error: nil,
},
@ -237,7 +237,7 @@ func pruneRetrieveErrorTest(ctx context.Context, c client.Client, invConfig invc
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
},
},
@ -246,7 +246,7 @@ func pruneRetrieveErrorTest(ctx context.Context, c client.Client, invConfig invc
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
},
},
@ -321,7 +321,7 @@ func pruneRetrieveErrorTest(ctx context.Context, c client.Client, invConfig invc
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-0",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
Error: nil,
},
@ -349,7 +349,7 @@ func pruneRetrieveErrorTest(ctx context.Context, c client.Client, invConfig invc
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
},
},
@ -358,7 +358,7 @@ func pruneRetrieveErrorTest(ctx context.Context, c client.Client, invConfig invc
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod2Obj),
},
},

View File

@ -65,7 +65,7 @@ func reconciliationTimeout(ctx context.Context, invConfig invconfig.InventoryCon
Expect(received).To(testutil.Equal(expEvents))
}
func expectedPodEvents(pod *unstructured.Unstructured, waitOperation event.WaitEventOperation) []testutil.ExpEvent {
func expectedPodEvents(pod *unstructured.Unstructured, waitStatus event.WaitEventStatus) []testutil.ExpEvent {
return []testutil.ExpEvent{
{
// InitTask
@ -104,7 +104,7 @@ func expectedPodEvents(pod *unstructured.Unstructured, waitOperation event.WaitE
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(pod),
Error: nil,
},
@ -132,7 +132,7 @@ func expectedPodEvents(pod *unstructured.Unstructured, waitOperation event.WaitE
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod),
},
},
@ -141,7 +141,7 @@ func expectedPodEvents(pod *unstructured.Unstructured, waitOperation event.WaitE
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: waitOperation,
Status: waitStatus,
Identifier: object.UnstructuredToObjMetadata(pod),
},
},

View File

@ -188,7 +188,7 @@ func skipInvalidTest(ctx context.Context, c client.Client, invConfig invconfig.I
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -215,7 +215,7 @@ func skipInvalidTest(ctx context.Context, c client.Client, invConfig invconfig.I
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -224,7 +224,7 @@ func skipInvalidTest(ctx context.Context, c client.Client, invConfig invconfig.I
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -251,7 +251,7 @@ func skipInvalidTest(ctx context.Context, c client.Client, invConfig invconfig.I
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-1",
Operation: event.Created,
Status: event.ApplySuccessful,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
},
},
@ -278,7 +278,7 @@ func skipInvalidTest(ctx context.Context, c client.Client, invConfig invconfig.I
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
},
},
@ -287,7 +287,7 @@ func skipInvalidTest(ctx context.Context, c client.Client, invConfig invconfig.I
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-1",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(deployment1Obj),
},
},
@ -384,7 +384,7 @@ func skipInvalidTest(ctx context.Context, c client.Client, invConfig invconfig.I
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
GroupName: "prune-0",
Operation: event.Deleted,
Status: event.DeleteSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -411,7 +411,7 @@ func skipInvalidTest(ctx context.Context, c client.Client, invConfig invconfig.I
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.ReconcilePending,
Status: event.ReconcilePending,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},
@ -420,7 +420,7 @@ func skipInvalidTest(ctx context.Context, c client.Client, invConfig invconfig.I
EventType: event.WaitType,
WaitEvent: &testutil.ExpWaitEvent{
GroupName: "wait-0",
Operation: event.Reconciled,
Status: event.ReconcileSuccessful,
Identifier: object.UnstructuredToObjMetadata(pod1Obj),
},
},

View File

@ -100,7 +100,7 @@ func thousandNamespacesTest(ctx context.Context, c client.Client, invConfig invc
}
for _, e := range applierEvents {
if e.Type == event.WaitType {
Expect(e.WaitEvent.Operation).To(BeElementOf(event.ReconcilePending, event.Reconciled), "WaitEvent: %v", e.WaitEvent)
Expect(e.WaitEvent.Status).To(BeElementOf(event.ReconcilePending, event.ReconcileSuccessful), "WaitEvent: %v", e.WaitEvent)
}
}
@ -140,7 +140,7 @@ func thousandNamespacesTest(ctx context.Context, c client.Client, invConfig invc
}
for _, e := range destroyerEvents {
if e.Type == event.WaitType {
Expect(e.WaitEvent.Operation).To(BeElementOf(event.ReconcilePending, event.Reconciled), "WaitEvent: %v", e.WaitEvent)
Expect(e.WaitEvent.Status).To(BeElementOf(event.ReconcilePending, event.ReconcileSuccessful), "WaitEvent: %v", e.WaitEvent)
}
}