@@ -10,6 +10,7 @@ import (
1010 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1111 "sigs.k8s.io/cli-utils/pkg/apis/actuation"
1212 "sigs.k8s.io/cli-utils/pkg/apply/taskrunner"
13+ "sigs.k8s.io/cli-utils/pkg/common"
1314 "sigs.k8s.io/cli-utils/pkg/object"
1415)
1516
@@ -24,8 +25,9 @@ const (
2425// DependencyFilter implements ValidationFilter interface to determine if an
2526// object can be applied or deleted based on the status of it's dependencies.
2627type DependencyFilter struct {
27- TaskContext * taskrunner.TaskContext
28- Strategy actuation.ActuationStrategy
28+ TaskContext * taskrunner.TaskContext
29+ ActuationStrategy actuation.ActuationStrategy
30+ DryRunStrategy common.DryRunStrategy
2931}
3032
3133const DependencyFilterName = "DependencyFilter"
@@ -40,7 +42,7 @@ func (dnrf DependencyFilter) Name() string {
4042func (dnrf DependencyFilter ) Filter (obj * unstructured.Unstructured ) (bool , string , error ) {
4143 id := object .UnstructuredToObjMetadata (obj )
4244
43- switch dnrf .Strategy {
45+ switch dnrf .ActuationStrategy {
4446 case actuation .ActuationStrategyApply :
4547 // For apply, check dependencies (outgoing)
4648 for _ , depID := range dnrf .TaskContext .Graph ().Dependencies (id ) {
@@ -64,7 +66,7 @@ func (dnrf DependencyFilter) Filter(obj *unstructured.Unstructured) (bool, strin
6466 }
6567 }
6668 default :
67- panic (fmt .Sprintf ("invalid filter strategy: %q" , dnrf .Strategy ))
69+ panic (fmt .Sprintf ("invalid filter strategy: %q" , dnrf .ActuationStrategy ))
6870 }
6971 return false , "" , nil
7072}
@@ -91,9 +93,9 @@ func (dnrf DependencyFilter) filterByRelationStatus(id object.ObjMetadata, relat
9193
9294 // Dependencies must have the same actuation strategy.
9395 // If there is a mismatch, skip both.
94- if status .Strategy != dnrf .Strategy {
96+ if status .Strategy != dnrf .ActuationStrategy {
9597 return true , fmt .Sprintf ("%s skipped because %s is scheduled for %s: %q" ,
96- strings .ToLower (dnrf .Strategy .String ()),
98+ strings .ToLower (dnrf .ActuationStrategy .String ()),
9799 strings .ToLower (relationship .String ()),
98100 strings .ToLower (status .Strategy .String ()),
99101 id ), nil
@@ -103,7 +105,7 @@ func (dnrf DependencyFilter) filterByRelationStatus(id object.ObjMetadata, relat
103105 case actuation .ActuationPending :
104106 // If actuation is still pending, dependency sorting is probably broken.
105107 return false , "" , fmt .Errorf ("premature %s: %s %s actuation %s: %q" ,
106- strings .ToLower (dnrf .Strategy .String ()),
108+ strings .ToLower (dnrf .ActuationStrategy .String ()),
107109 strings .ToLower (relationship .String ()),
108110 strings .ToLower (status .Strategy .String ()),
109111 strings .ToLower (status .Actuation .String ()),
@@ -112,7 +114,7 @@ func (dnrf DependencyFilter) filterByRelationStatus(id object.ObjMetadata, relat
112114 // Skip!
113115 return true , fmt .Sprintf ("%s %s actuation %s: %q" ,
114116 strings .ToLower (relationship .String ()),
115- strings .ToLower (dnrf .Strategy .String ()),
117+ strings .ToLower (dnrf .ActuationStrategy .String ()),
116118 strings .ToLower (status .Actuation .String ()),
117119 id ), nil
118120 case actuation .ActuationSucceeded :
@@ -124,11 +126,17 @@ func (dnrf DependencyFilter) filterByRelationStatus(id object.ObjMetadata, relat
124126 id )
125127 }
126128
129+ // DryRun skips WaitTasks, so reconcile status can be ignored
130+ if dnrf .DryRunStrategy .ClientOrServerDryRun () {
131+ // Don't skip!
132+ return false , "" , nil
133+ }
134+
127135 switch status .Reconcile {
128136 case actuation .ReconcilePending :
129137 // If reconcile is still pending, dependency sorting is probably broken.
130138 return false , "" , fmt .Errorf ("premature %s: %s %s reconcile %s: %q" ,
131- strings .ToLower (dnrf .Strategy .String ()),
139+ strings .ToLower (dnrf .ActuationStrategy .String ()),
132140 strings .ToLower (relationship .String ()),
133141 strings .ToLower (status .Strategy .String ()),
134142 strings .ToLower (status .Reconcile .String ()),
@@ -137,7 +145,7 @@ func (dnrf DependencyFilter) filterByRelationStatus(id object.ObjMetadata, relat
137145 // Skip!
138146 return true , fmt .Sprintf ("%s %s reconcile %s: %q" ,
139147 strings .ToLower (relationship .String ()),
140- strings .ToLower (dnrf .Strategy .String ()),
148+ strings .ToLower (dnrf .ActuationStrategy .String ()),
141149 strings .ToLower (status .Reconcile .String ()),
142150 id ), nil
143151 case actuation .ReconcileSucceeded :
0 commit comments