Skip to content

Commit 7988140

Browse files
authored
remove cuego.Complete from cuecfg.Marshal (#1349)
## Summary `cuego.Complete` leads to non-trivial complexity when dealing with custom json marshalling. In particular, it does a round-trip JSON marshal/unmarshal and fields that are not handled by golang's json-framework can be lost. This interferes with custom marshalling/unmarshalling. `cuego.Complete` is only needed if we rely on the `cue:` annotations to autocomplete some fields (I mean, assign default values respecting cue constraints). We don't rely on this, so, right now it is superfluous. I also remove the `cue:` annotations in a couple of structs since we do not rely on them. ## How was it tested? - [x] `devbox init` should produce the expected output - [x] `devbox add` - [x] `devbox rm` testscript unit tests must pass
1 parent f38de16 commit 7988140

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

internal/cuecfg/cuecfg.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,12 @@ import (
88
"os"
99
"path/filepath"
1010

11-
"cuelang.org/go/cuego"
1211
"github.com/pkg/errors"
1312
)
1413

1514
// TODO: add support for .cue
1615

1716
func Marshal(valuePtr any, extension string) ([]byte, error) {
18-
err := cuego.Complete(valuePtr)
19-
if err != nil {
20-
return nil, errors.WithStack(err)
21-
}
22-
2317
switch extension {
2418
case ".json", ".lock":
2519
return MarshalJSON(valuePtr)

internal/devconfig/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const DefaultName = "devbox.json"
2222
type Config struct {
2323
// Packages is the slice of Nix packages that devbox makes available in
2424
// its environment. Deliberately do not omitempty.
25-
Packages []string `cue:"[...string]" json:"packages"`
25+
Packages []string `json:"packages"`
2626

2727
// Env allows specifying env variables
2828
Env map[string]string `json:"env,omitempty"`
@@ -52,7 +52,7 @@ type NixpkgsConfig struct {
5252

5353
// Stage contains a subset of fields from plansdk.Stage
5454
type Stage struct {
55-
Command string `cue:"string" json:"command"`
55+
Command string `json:"command"`
5656
}
5757

5858
func DefaultConfig() *Config {

0 commit comments

Comments
 (0)