Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/crossplane/common/load/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ func streamToUnstructured(stream [][]byte) ([]*unstructured.Unstructured, error)
if err := yaml.Unmarshal(y, u); err != nil {
return nil, errors.Wrap(err, "cannot parse YAML manifest")
}

// skip empty documents (empty files, or documents containing only comment)
if len(u.Object) == 0 {
continue
}

// extract pipeline input resources
if u.GetObjectKind().GroupVersionKind() == v1.CompositionGroupVersionKind {
// Convert the unstructured resource to a Composition
Expand Down
18 changes: 18 additions & 0 deletions cmd/crossplane/common/load/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,24 @@ spec:
err: nil,
},
},
"SkipEmptyDocuments": {
reason: "Return empty unstructured array for empty documents",
args: args{
stream: [][]byte{{}},
},
want: want{
resources: []*unstructured.Unstructured{},
},
},
"SkipDocumentsWithCommentOnly": {
reason: "Skip documents with only comments",
args: args{
stream: [][]byte{[]byte("# comment only\n")},
},
want: want{
resources: []*unstructured.Unstructured{},
},
},
}

for name, tc := range cases {
Expand Down
Loading