diff --git a/pkg/kapp/resourcesmisc/custom_waiting_resource.go b/pkg/kapp/resourcesmisc/custom_waiting_resource.go index f2902ec38..f3d8065e5 100644 --- a/pkg/kapp/resourcesmisc/custom_waiting_resource.go +++ b/pkg/kapp/resourcesmisc/custom_waiting_resource.go @@ -65,10 +65,16 @@ func (s CustomWaitingResource) IsDoneApplying() DoneApplyState { } if s.waitRule.Ytt != nil { + startTime, found := timeoutMap.Load(s.resource.Description()) + if !found { + timeoutMap.Store(s.resource.Description(), time.Now().Unix()) + } configObj, err := WaitRuleContractV1{ ResourceMatcher: ctlres.AnyMatcher{ Matchers: ctlconf.ResourceMatchers(s.waitRule.ResourceMatchers).AsResourceMatchers()}, - Starlark: s.waitRule.Ytt.FuncContractV1.Resource, + Starlark: s.waitRule.Ytt.FuncContractV1.Resource, + CurrentTime: time.Now().Unix(), + StartTime: startTime.(int64), }.Apply(s.resource) if err != nil { return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf( diff --git a/pkg/kapp/resourcesmisc/wait_rule_contract_v1.go b/pkg/kapp/resourcesmisc/wait_rule_contract_v1.go index e1344d9ac..077247eeb 100644 --- a/pkg/kapp/resourcesmisc/wait_rule_contract_v1.go +++ b/pkg/kapp/resourcesmisc/wait_rule_contract_v1.go @@ -16,6 +16,8 @@ import ( type WaitRuleContractV1 struct { ResourceMatcher ctlres.ResourceMatcher Starlark string + CurrentTime int64 + StartTime int64 } type waitRuleContractV1Result struct { @@ -48,6 +50,7 @@ func (t WaitRuleContractV1) evalYtt(res ctlres.Resource) (*WaitRuleContractV1Res } return yaml.Marshal(res.DeepCopyRaw()) } + opts.DataValuesFlags.KVsFromStrings = []string{fmt.Sprintf("startTime=%d", t.StartTime), fmt.Sprintf("currentTime=%d", t.CurrentTime)} filesToProcess := []*files.File{ files.MustNewFileFromSource(files.NewBytesSource("resource.star", []byte(t.Starlark))),