Skip to content

Commit

Permalink
internal/filetypes: rename top level "tags" field
Browse files Browse the repository at this point in the history
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 <[email protected]>
Change-Id: I7356d940634dfd05a40295e62c937e60f2874b5a
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200761
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
rogpeppe committed Sep 6, 2024
1 parent 2662ebe commit 3413f77
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion internal/filetypes/filetypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
35 changes: 18 additions & 17 deletions internal/filetypes/types.cue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package build
encoding!: #Encoding
interpretation?: #Interpretation
form?: #Form
// Note: tags includes values for non-boolean tags only.
tags?: [string]: string
}

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 3413f77

Please sign in to comment.