Move types and plan back to main dagger package

Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
This commit is contained in:
Helder Correia
2022-03-28 12:02:39 +00:00
parent b3bdd347e7
commit 5abd77f4f2
15 changed files with 132 additions and 131 deletions

View File

@@ -20,6 +20,11 @@ var (
cue.Str("$dagger"),
cue.Str("task"),
cue.Hid("_name", pkg.DaggerPackage))
corePath = cue.MakePath(
cue.Str("$dagger"),
cue.Str("task"),
cue.Hid("_name", pkg.DaggerCorePackage))
paths = []cue.Path{corePath, typePath}
)
// State is the state of the task.
@@ -64,12 +69,7 @@ func Lookup(v *compiler.Value) (Task, error) {
return nil, ErrNotTask
}
typ := v.LookupPath(typePath)
if !typ.Exists() {
return nil, ErrNotTask
}
typeString, err := typ.String()
typeString, err := lookupType(v)
if err != nil {
return nil, err
}
@@ -81,3 +81,13 @@ func Lookup(v *compiler.Value) (Task, error) {
return t, nil
}
func lookupType(v *compiler.Value) (string, error) {
for _, path := range paths {
typ := v.LookupPath(path)
if typ.Exists() {
return typ.String()
}
}
return "", ErrNotTask
}