Skip to content

Commit

Permalink
cmd/cue: do not allow embedding of CUE file types (for now)
Browse files Browse the repository at this point in the history
Per the design proposed in https://cuelang.org/discussion/3264, we do
not allow CUE file type embeds for now. This CL fixes the MVP
implementation to match that initial decision, along with removing the
attempted embed of a CUE file across a module boundary. Preventing
embedding of files across module boundaries is fixed in another CL, but
this change to not attempt the CUE file type embed is needed now, and
the case covered in embed_err.txtar.

Fixes #3258.

Signed-off-by: Paul Jolly <paul@myitcv.io>
Change-Id: Ic12297750620ade0cd631a56f73f16c3d0ca156e
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1197337
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
myitcv committed Jul 8, 2024
1 parent 868c110 commit a0f2cac
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
12 changes: 0 additions & 12 deletions cmd/cue/cmd/testdata/script/embed.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ special: {
// probably be up to the loader to provide a fs.FS that handles this
// according to spec.
nestedModJSON: _ @embed(file="a/b/foo.json")
nestedModFile: _ @embed(file="a/b/cue.mod/modules.cue")
}

-- test.json --
Expand Down Expand Up @@ -124,7 +123,6 @@ special: {
underscoreDir: _
dotDir: _
nestedModJSON: _
nestedModFile: _
}
-- out/eval --
a: {
Expand Down Expand Up @@ -219,12 +217,6 @@ special: {
a: 1
b: 2
}
nestedModFile: {
module: "acme.com"
language: {
version: "v0.9.0"
}
}
}
-- out/export --
a: x: 34
Expand Down Expand Up @@ -285,9 +277,5 @@ special: {
a: 1
b: 2
}
nestedModFile: {
module: "acme.com"
language: version: "v0.9.0"
}
}
-- out/vet --
4 changes: 4 additions & 0 deletions cmd/cue/cmd/testdata/script/embed_err.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,7 @@ x: 5
./test.cue:39:10
@embed: open x\test.json: no such file or directory:
./test.cue:41:18
@embed: encoding "cue" not (yet) supported:
./test.cue:43:20
@embed: encoding "cue" not (yet) supported:
./test.cue:44:24
2 changes: 2 additions & 0 deletions cue/interpreter/embed/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ func (c *compiler) decodeFile(file, scope string, schema adt.Value) (adt.Expr, e
}

switch f.Encoding {
case build.CUE:
return nil, errors.Newf(c.pos, "encoding %q not (yet) supported", f.Encoding)
case build.JSONL:
return nil, errors.Newf(c.pos, "encoding %q not (yet) supported: requires support for streaming", f.Encoding)
case build.BinaryProto, build.TextProto:
Expand Down

0 comments on commit a0f2cac

Please sign in to comment.