Skip to content

Commit 8cbd951

Browse files
author
asib
authored
call patchRoot before running strict validation so that old-format … (#4488)
* call `patchRoot` before running strict validation so that old-format config files aren't automatically marked as invalid
1 parent be84fe9 commit 8cbd951

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

internal/appconfig/patches.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ func patchBuild(cfg map[string]any) (map[string]any, error) {
167167
switch k {
168168
case "build_target":
169169
cast["build-target"] = v
170+
delete(cast, "build_target")
170171
}
171172
}
172173

@@ -240,6 +241,8 @@ func patchCompute(cfg map[string]any) (map[string]any, error) {
240241
}
241242
}
242243
cfg["vm"] = compute
244+
delete(cfg, "compute")
245+
delete(cfg, "computes")
243246
return cfg, nil
244247
}
245248

@@ -261,6 +264,7 @@ func patchMounts(cfg map[string]any) (map[string]any, error) {
261264
}
262265
}
263266
cfg["mounts"] = mounts
267+
delete(cfg, "mount")
264268
return cfg, nil
265269
}
266270

@@ -276,6 +280,7 @@ func patchMetrics(cfg map[string]any) (map[string]any, error) {
276280
}
277281
}
278282
cfg["metrics"] = metrics
283+
delete(cfg, "metric")
279284
return cfg, nil
280285
}
281286

internal/appconfig/serde.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ func LoadConfigAsMap(path string) (rawConfig map[string]any, err error) {
7373
} else {
7474
err = toml.Unmarshal(buf, &rawConfig)
7575
}
76+
if err != nil {
77+
return nil, err
78+
}
7679

77-
return rawConfig, err
80+
return patchRoot(rawConfig)
7881
}
7982

8083
func (c *Config) WriteTo(w io.Writer, format string) (int64, error) {

0 commit comments

Comments
 (0)