@@ -10,7 +10,6 @@ import (
1010 "hash"
1111 "io/fs"
1212 "maps"
13- "regexp"
1413 "slices"
1514 "strings"
1615
@@ -55,7 +54,7 @@ func (r *SimpleRevisionGenerator) GenerateRevisionFromHelmRelease(
5554 helmRelease * release.Release , ext * ocv1.ClusterExtension ,
5655 objectLabels map [string ]string ,
5756) (* ocv1.ClusterExtensionRevision , error ) {
58- docs := splitYAMLDocuments (helmRelease .Manifest )
57+ docs := splitManifestDocuments (helmRelease .Manifest )
5958 objs := make ([]ocv1.ClusterExtensionRevisionObject , 0 , len (docs ))
6059 for _ , doc := range docs {
6160 obj := unstructured.Unstructured {}
@@ -171,16 +170,6 @@ func (m *BoxcutterStorageMigrator) Migrate(ctx context.Context, ext *ocv1.Cluste
171170 return err
172171 }
173172
174- docs := splitYAMLDocuments (helmRelease .Manifest )
175- objs := make ([]unstructured.Unstructured , 0 , len (docs ))
176- for _ , doc := range docs {
177- obj := unstructured.Unstructured {}
178- if err := yaml .Unmarshal ([]byte (doc ), & obj ); err != nil {
179- return err
180- }
181- objs = append (objs , obj )
182- }
183-
184173 rev , err := m .RevisionGenerator .GenerateRevisionFromHelmRelease (helmRelease , ext , objectLabels )
185174 if err != nil {
186175 return err
@@ -388,12 +377,13 @@ func (r *RegistryV1BundleRenderer) Render(bundleFS fs.FS, ext *ocv1.ClusterExten
388377 return r .BundleRenderer .Render (reg , ext .Spec .Namespace , render .WithTargetNamespaces (watchNamespace ), render .WithCertificateProvider (r .CertificateProvider ))
389378}
390379
391- var splitYAMLDocumentsRegEx = regexp .MustCompile (`(?m)^---$` )
392-
393- // Splits a YAML file into multiple documents.
394- func splitYAMLDocuments (file string ) (docs []string ) {
395- for _ , yamlDocument := range splitYAMLDocumentsRegEx .Split (string (strings .Trim (file , "---\n " )), - 1 ) {
396- docs = append (docs , strings .TrimSpace (string (yamlDocument )))
380+ func splitManifestDocuments (file string ) (docs []string ) {
381+ for _ , yamlDocument := range strings .Split (file , "\n " ) {
382+ yamlDocument = strings .TrimSpace (string (yamlDocument ))
383+ if len (yamlDocument ) == 0 {
384+ continue
385+ }
386+ docs = append (docs , yamlDocument )
397387 }
398388 return docs
399389}
0 commit comments