Skip to content

Commit

Permalink
fix: make run bundle use proper YAML library to split documents
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
  • Loading branch information
joelanford committed Sep 6, 2024
1 parent d2366be commit fc617fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog/fragments/fix-run-bundle-yaml-split.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
entries:
- description: >
Fix naive YAML split in `run bundle` command.
kind: "bugfix"
breaking: false
21 changes: 19 additions & 2 deletions internal/olm/operator/registry/fbcindex/fbc_registry_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
package fbcindex

import (
"bufio"
"context"
"errors"
"fmt"
"io"
"k8s.io/apimachinery/pkg/util/yaml"
"path"
"strings"
"time"
Expand Down Expand Up @@ -399,8 +402,22 @@ func (f *FBCRegistryPod) createConfigMaps(cs *v1alpha1.CatalogSource) ([]*corev1
// properly have all the FBC contents rendered in the registry pod.
func (f *FBCRegistryPod) partitionedConfigMaps() ([]*corev1.ConfigMap, error) {
var err error
// Split on the YAML separator `---`
yamlDefs := strings.Split(f.FBCContent, "---")

var yamlDefs []string
yamlReader := yaml.NewYAMLReader(bufio.NewReader(strings.NewReader(f.FBCContent)))
for {
doc, err := yamlReader.Read()
if errors.Is(err, io.EOF) {
break
}
if err != nil {
return nil, err
}
if len(doc) == 0 {
continue
}
yamlDefs = append(yamlDefs, string(doc))
}

configMaps, err := f.getConfigMaps(yamlDefs)
if err != nil {
Expand Down

0 comments on commit fc617fa

Please sign in to comment.