From 3413f77a5c03853be2817aa4b5b8fda7edfde1df Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Thu, 5 Sep 2024 14:37:06 +0100 Subject: [PATCH] internal/filetypes: rename top level "tags" field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When reviewing this code, I was struck by the ambiguity between the top level `tags` field and the `build.File.Tags` field (also encoded as a `tags` field in CUE), and it wasn't immediately obvious that the top level `tags` field didn't play a role in the latter. It doesn't, so make that clearer by renaming it to something that's clearly distinct. Signed-off-by: Roger Peppe Change-Id: I7356d940634dfd05a40295e62c937e60f2874b5a Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200761 Unity-Result: CUE porcuepine Reviewed-by: Daniel Martí TryBot-Result: CUEcueckoo --- internal/filetypes/filetypes.go | 2 +- internal/filetypes/types.cue | 35 +++++++++++++++++---------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/internal/filetypes/filetypes.go b/internal/filetypes/filetypes.go index 8c5f3a9c6..b813e6f32 100644 --- a/internal/filetypes/filetypes.go +++ b/internal/filetypes/filetypes.go @@ -320,7 +320,7 @@ func parseType(scope string, mode Mode) (modeVal, fileVal cue.Value, _ error) { if ok { fileVal = fileVal.FillPath(cue.MakePath(cue.Str("tags"), cue.Str(tagName)), tagVal) } else { - info := typesValue.LookupPath(cue.MakePath(cue.Str("tags"), cue.Str(tag))) + info := typesValue.LookupPath(cue.MakePath(cue.Str("tagInfo"), cue.Str(tag))) if !info.Exists() { return cue.Value{}, cue.Value{}, errors.Newf(token.NoPos, "unknown filetype %s", tag) } diff --git a/internal/filetypes/types.cue b/internal/filetypes/types.cue index 6fc5b7e20..e30141d1e 100644 --- a/internal/filetypes/types.cue +++ b/internal/filetypes/types.cue @@ -26,6 +26,7 @@ package build encoding!: #Encoding interpretation?: #Interpretation form?: #Form + // Note: tags includes values for non-boolean tags only. tags?: [string]: string } @@ -162,23 +163,23 @@ modes: [string]: { // extensions maps a file extension to its associated default file properties. extensions: { // "": _ - ".cue": tags.cue - ".json": tags.json - ".jsonl": tags.jsonl - ".ldjson": tags.jsonl - ".ndjson": tags.jsonl - ".yaml": tags.yaml - ".yml": tags.yaml - ".toml": tags.toml - ".txt": tags.text - ".go": tags.go - ".wasm": tags.binary - ".proto": tags.proto - ".textproto": tags.textproto - ".textpb": tags.textproto // perhaps also pbtxt + ".cue": tagInfo.cue + ".json": tagInfo.json + ".jsonl": tagInfo.jsonl + ".ldjson": tagInfo.jsonl + ".ndjson": tagInfo.jsonl + ".yaml": tagInfo.yaml + ".yml": tagInfo.yaml + ".toml": tagInfo.toml + ".txt": tagInfo.text + ".go": tagInfo.go + ".wasm": tagInfo.binary + ".proto": tagInfo.proto + ".textproto": tagInfo.textproto + ".textpb": tagInfo.textproto // perhaps also pbtxt // TODO: jsonseq, - // ".pb": tags.binpb // binarypb + // ".pb": tagInfo.binpb // binarypb } // encodings: "": error("no encoding specified") @@ -327,8 +328,8 @@ interpretations: pb: { stream: true } -// tags maps command line tags to file properties. -tags: { +// tagInfo maps command line tags to file properties. +tagInfo: { schema: form: "schema" graph: form: "graph" dag: form: "dag"