Skip to content

Commit 802a852

Browse files
committed
cmd/cue/cmd: only consider "kind" field for known tasks
Signed-off-by: Marcel van Lohuizen <mpvl@golang.org> Change-Id: Id443821af5e3b2740c741bc8c3823a1e6ba4031e Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/532278 Unity-Result: CUEcueckoo <cueckoo@cuelang.org> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Reviewed-by: Paul Jolly <paul@myitcv.io> Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
1 parent bd3b6ea commit 802a852

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cmd/cue/cmd/custom.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,16 @@ func isTask(v cue.Value) bool {
164164
if len(v.Path().Selectors()) == 0 {
165165
return false
166166
}
167-
return v.Kind() == cue.StructKind &&
168-
(v.Lookup("$id").Exists() || v.Lookup("kind").Exists())
167+
if v.Kind() != cue.StructKind {
168+
return false
169+
}
170+
if v.Lookup("$id").Exists() {
171+
return true
172+
}
173+
// Is it an existing legacy kind.
174+
str, err := v.Lookup("kind").String()
175+
_, ok := legacyKinds[str]
176+
return err == nil && ok
169177
}
170178

171179
var legacyKinds = map[string]string{
@@ -184,10 +192,10 @@ func newTaskFunc(cmd *Command) flow.TaskFunc {
184192
kind, err := v.Lookup("$id").String()
185193
if err != nil {
186194
// Lookup kind for backwards compatibility.
187-
// TODO: consider at some point whether kind can be removed.
195+
// This should not be supported for cue run.
188196
var err1 error
189197
kind, err1 = v.Lookup("kind").String()
190-
if err1 != nil {
198+
if err1 != nil || legacyKinds[kind] == "" {
191199
return nil, errors.Promote(err1, "newTask")
192200
}
193201
}

0 commit comments

Comments
 (0)