Skip to content

Commit c3aebc0

Browse files
committed
Use yaml.Unmarshal
Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent db1aadd commit c3aebc0

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ if err != nil {
277277
}
278278
279279
// For YAML errors, use formatted output
280-
if err := yaml.UnmarshalWithOptions(data, &raw); err != nil {
280+
if err := yaml.Unmarshal(data, &raw); err != nil {
281281
return nil, fmt.Errorf("parsing config:\n%s", yaml.FormatError(err, true, true))
282282
}
283283

pkg/agentfile/resolver_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,13 +487,13 @@ func TestResolveAgentFile_OCIRef_HasAVersion(t *testing.T) {
487487
require.NoError(t, err)
488488
assert.NotEmpty(t, resolved)
489489

490-
content, err := os.ReadFile(resolved)
490+
storedContent, err := os.ReadFile(resolved)
491491
require.NoError(t, err)
492492
assert.Equal(t, `version: "2"
493493
agents:
494494
root:
495495
model: auto
496496
description: Test OCI agent
497497
instruction: You are a test OCI agent
498-
`, string(content))
498+
`, string(storedContent))
499499
}

pkg/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func LoadConfigBytes(ctx context.Context, data []byte) (*latest.Config, error) {
2828
var raw struct {
2929
Version string `yaml:"version,omitempty"`
3030
}
31-
if err := yaml.UnmarshalWithOptions(data, &raw); err != nil {
31+
if err := yaml.Unmarshal(data, &raw); err != nil {
3232
return nil, fmt.Errorf("looking for version in config file\n%s", yaml.FormatError(err, true, true))
3333
}
3434
if raw.Version == "" {

pkg/oci/package.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func PackageFileAsOCIToStore(ctx context.Context, filePath, artifactRef string,
4747
var raw struct {
4848
Version string `yaml:"version,omitempty"`
4949
}
50-
if err := yaml.UnmarshalWithOptions(data, &raw); err != nil {
50+
if err := yaml.Unmarshal(data, &raw); err != nil {
5151
return "", fmt.Errorf("looking for version in config file\n%s", yaml.FormatError(err, true, true))
5252
}
5353
// Make sure we push a yaml with a version (Use latest if missing)

0 commit comments

Comments
 (0)