Skip to content

Commit

Permalink
fix: Fixes #53, do not extract manifests with empty content
Browse files Browse the repository at this point in the history
Signed-off-by: Dustin Scott <[email protected]>
  • Loading branch information
scottd018 committed Jul 23, 2024
1 parent 475a9f6 commit 85aa8e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/workload/v1/manifests/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,19 @@ func (manifest *Manifest) ExtractManifests() []string {

var content string

for _, line := range lines {
if strings.TrimRight(line, " ") == "---" {
for i := range lines {
if strings.TrimRight(lines[i], " ") == "---" {
if content != "" {
manifests = append(manifests, content)
content = ""
}
} else {
content = content + "\n" + line
content = content + "\n" + lines[i]
}
}

if content != "" {
// ensure content is not empty before appending it to the manifests slice
if strings.TrimSpace(content) != "" {
manifests = append(manifests, content)
}

Expand Down
3 changes: 3 additions & 0 deletions test/cases/edge-standalone/.workloadConfig/resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,6 @@ spec:
requests.memory: 4Gi
limits.cpu: "4"
limits.memory: 4Gi
# test the trailing yaml separator
# see https://github.com/nukleros/operator-builder/issues/53
---

0 comments on commit 85aa8e6

Please sign in to comment.