diff --git a/dagger/inputs_scan.go b/dagger/inputs_scan.go index a76f54a1..2b04becc 100644 --- a/dagger/inputs_scan.go +++ b/dagger/inputs_scan.go @@ -3,26 +3,43 @@ package dagger import ( "context" + "cuelang.org/go/cue" "dagger.io/go/dagger/compiler" "github.com/rs/zerolog/log" ) -func isReference(val *compiler.Value) bool { - _, ref := val.ReferencePath() +func isReference(val cue.Value) bool { + isRef := func(v cue.Value) bool { + _, ref := v.ReferencePath() - if ref.String() == "" || val.Path().String() == ref.String() { - // not a reference - return false + if ref.String() == "" || v.Path().String() == ref.String() { + // not a reference + return false + } + + for _, s := range ref.Selectors() { + if s.IsDefinition() { + // if we reference to a definition, we skip the check + return false + } + } + + return true } - for _, s := range ref.Selectors() { - if s.IsDefinition() { - // if we reference to a definition, we skip the check - return false + op, vals := val.Expr() + if op == cue.NoOp { + return isRef(val) + } + + for _, v := range vals { + // if the expr has an op (& or |, etc...), check the expr values, recursively + if isReference(v) { + return true } } - return true + return isRef(val) } func ScanInputs(ctx context.Context, value *compiler.Value) []*compiler.Value { @@ -31,7 +48,7 @@ func ScanInputs(ctx context.Context, value *compiler.Value) []*compiler.Value { value.Walk( func(val *compiler.Value) bool { - if isReference(val) { + if isReference(val.Cue()) { lg.Debug().Str("value.Path", val.Path().String()).Msg("found reference, stop walk") return false }