Add resource skipping for store encoders
This commit is contained in:
31
server/automation/envoy/store_encode.gen.go
generated
31
server/automation/envoy/store_encode.gen.go
generated
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/cortezaproject/corteza/server/automation/types"
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoyx"
|
||||
"github.com/cortezaproject/corteza/server/pkg/expr"
|
||||
"github.com/cortezaproject/corteza/server/pkg/id"
|
||||
"github.com/cortezaproject/corteza/server/store"
|
||||
)
|
||||
@@ -119,6 +120,12 @@ func (e StoreEncoder) prepareWorkflow(ctx context.Context, p envoyx.EncodeParams
|
||||
|
||||
existing, hasExisting := existing[i]
|
||||
|
||||
// Run expressions on the nodes
|
||||
err = e.runEvals(ctx, hasExisting, n)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if hasExisting {
|
||||
// On existing, we don't need to re-do identifiers and references; simply
|
||||
// changing up the internal resource is enough.
|
||||
@@ -299,6 +306,12 @@ func (e StoreEncoder) prepareTrigger(ctx context.Context, p envoyx.EncodeParams,
|
||||
|
||||
existing, hasExisting := existing[i]
|
||||
|
||||
// Run expressions on the nodes
|
||||
err = e.runEvals(ctx, hasExisting, n)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if hasExisting {
|
||||
// On existing, we don't need to re-do identifiers and references; simply
|
||||
// changing up the internal resource is enough.
|
||||
@@ -465,3 +478,21 @@ func (e *StoreEncoder) grabStorer(p envoyx.EncodeParams) (s store.Storer, err er
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (e *StoreEncoder) runEvals(ctx context.Context, existing bool, n *envoyx.Node) (err error) {
|
||||
// Skip if
|
||||
if n.Config.SkipIfEval == nil {
|
||||
return
|
||||
}
|
||||
|
||||
aux, err := expr.EmptyVars().Cast(map[string]any{
|
||||
"missing": !existing,
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
n.Evaluated.Skip, err = n.Config.SkipIfEval.Test(ctx, aux.(*expr.Vars))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user