Skip to content

Commit b511f04

Browse files
fix: multiline for yaml on share
The following patch fixes a bug discovered on yaml marshalling when handling multiline input. Essentially, when pushing to an OCI artifact to an OCI complaint registry, the yaml for multiline indentation is removed. Causing issues with marshalling the yaml for usage. Tested the change by working locally and sharing to an OCI registry for comparison.
1 parent e2ae58b commit b511f04

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pkg/config/latest/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (c Agents) MarshalYAML() ([]byte, error) {
6868
})
6969
}
7070

71-
return yaml.Marshal(mapSlice)
71+
return yaml.MarshalWithOptions(mapSlice, yaml.Indent(2), yaml.UseLiteralStyleIfMultiline(true))
7272
}
7373

7474
func (c *Agents) First() AgentConfig {

pkg/oci/package.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func PackageFileAsOCIToStore(ctx context.Context, agentSource config.Source, art
4646
// Make sure we push a yaml with a version (Use latest if missing)
4747
if raw.Version == "" {
4848
cfg.Version = latest.Version
49-
data, err = yaml.MarshalWithOptions(cfg, yaml.Indent(2))
49+
data, err = yaml.MarshalWithOptions(cfg, yaml.Indent(2), yaml.UseLiteralStyleIfMultiline(true))
5050
if err != nil {
5151
return "", fmt.Errorf("marshaling config: %w", err)
5252
}

0 commit comments

Comments
 (0)