This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cue/cmd: hook up protobuf encodings types
Closes #606 Change-Id: I712ed6f9fc37d53b633a44ed87e4c71c1e018b0f Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9372 Reviewed-by: CUE cueckoo <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
- Loading branch information
Showing
10 changed files
with
275 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
cue eval schema.cue json+pb: data.json | ||
cmp stdout out/data1 | ||
|
||
cue eval schemaflag.cue -d '#X' json+pb: data.json | ||
cmp stdout out/data1 | ||
|
||
! cue eval schema.cue json+pb: data-err.json | ||
cmp stderr out/data-err | ||
|
||
cue eval .:nested yaml+pb: stream.yaml -l kind | ||
cmp stdout out/stream | ||
|
||
-- schema.cue -- | ||
a: int @protobuf(1,int64) // to string | ||
b: int @protobuf(2,int32) // also allow string | ||
c: int // also allow | ||
d: float | ||
s: string | ||
t: bytes | ||
|
||
-- nested.cue -- | ||
package nested | ||
|
||
A: { | ||
a: int @protobuf(1,int64) // to string | ||
b: bytes | ||
} | ||
|
||
B: { | ||
a: int @protobuf(1,int64) // to string | ||
s: string | ||
} | ||
|
||
-- schemaflag.cue -- | ||
#X: { | ||
a: int @protobuf(1,int64) // to string | ||
b: int @protobuf(2,int32) // also allow string | ||
c: int // also allow | ||
d: float | ||
s: string | ||
t: bytes | ||
} | ||
|
||
-- data.json -- | ||
{"a": "10", "b": "20", "c": 30, "d": "1.2", | ||
"s":"SGVsbG8sIOS4lueVjA==", | ||
"t": "SGVsbG8sIOS4lueVjA=="} | ||
|
||
-- data-err.json -- | ||
{"a": "10", "b": "20", "c": "30", "t": "SGVsbG8sIOS4lue???VjA==" } | ||
|
||
-- stream.yaml -- | ||
kind: "A" | ||
a: "10" | ||
b: "SGVsbG8sIOS4lueVjA==" | ||
--- | ||
kind: "B" | ||
a: "10" | ||
s: "SGVsbG8sIOS4lueVjA==" | ||
|
||
-- out/data1 -- | ||
a: 10 | ||
b: 20 | ||
c: 30 | ||
d: 1.2 | ||
s: "SGVsbG8sIOS4lueVjA==" | ||
t: 'Hello, 世界' | ||
-- out/stream -- | ||
A: { | ||
kind: "A" | ||
a: 10 | ||
b: 'Hello, 世界' | ||
} | ||
B: { | ||
kind: "B" | ||
a: 10 | ||
s: "SGVsbG8sIOS4lueVjA==" | ||
} | ||
-- out/data-err -- | ||
t: failed to decode base64: illegal base64 data at input byte 15: | ||
./data-err.json:1:40 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
cue eval topschema.cue foo.textproto | ||
cmp stdout out/topfoo.textproto | ||
|
||
cue eval -d '#X' schema.cue foo.textproto | ||
cmp stdout out/foo.textproto | ||
|
||
! cue eval -d '#X' schema.cue foo.textproto -l c | ||
cmp stderr out/stderr3 | ||
|
||
-- topschema.cue -- | ||
a: int | ||
b: [...int] | ||
c: string | ||
-- schema.cue -- | ||
#X: { | ||
a: int | ||
b: [...int] | ||
c: string | ||
} | ||
-- foo.textproto -- | ||
a: 4 | ||
b: 1 | ||
b: 2 | ||
b: 3 | ||
b: 4 | ||
b: 5 | ||
c: "foo" | ||
-- out/topfoo.textproto -- | ||
a: 4 | ||
b: [1, 2, 3, 4, 5] | ||
c: "foo" | ||
-- out/foo.textproto -- | ||
a: 4 | ||
b: [1, 2, 3, 4, 5] | ||
c: "foo" | ||
-- out/stderr3 -- | ||
cannot combine --schema flag with flag "path", "list", or "files" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.