fix: Update PrintNamespacesList to use a YAML parser for multiple manifest files#9825
fix: Update PrintNamespacesList to use a YAML parser for multiple manifest files#9825ChrisGe4 merged 14 commits intoGoogleContainerTools:mainfrom
Conversation
…owed by a new line.
… followed by a new line.
|
What about |
|
Also YAML explicitly allows |
update commit msg
Right now this returns an error like: A file with just |
|
Sorry, that was a confusing example, but my point was that this is technically a valid YAML file: If you parse it, you get a map: My larger point is that trying to parse any structured format with a basic text-processing tools (like In short: if you want to parse YAML, use a YAML parser. |
|
Ok, updated to use https://pkg.go.dev/gopkg.in/yaml.v3 for parsing the multiple files, but kept the kubernetes file parser. So for the file with just "---" --> should that be valid then? |
|
Yeah, I think this looks great, thanks. |
…ifest files (#9825) * Update PrintNamespacesList to break on YAML file separator '---' followed by a new line. * fix: Update PrintNamespacesList to break on YAML file separator '---' followed by a new line. * fix: update yaml line break character and add more tests * fix: use yaml parser to process multiple files * fix: add test for single manifest w break at end * fix: remove unnecessary conversion * fix: update import * fix: if resourceToInfoMap is empty, return nil * fix: format * fix: log fmt write error and update empty manifest (with just ---) handling * fix: format * fix: fix imports * fix: add test case
…ifest files (GoogleContainerTools#9825) * Update PrintNamespacesList to break on YAML file separator '---' followed by a new line. * fix: Update PrintNamespacesList to break on YAML file separator '---' followed by a new line. * fix: update yaml line break character and add more tests * fix: use yaml parser to process multiple files * fix: add test for single manifest w break at end * fix: remove unnecessary conversion * fix: update import * fix: if resourceToInfoMap is empty, return nil * fix: format * fix: log fmt write error and update empty manifest (with just ---) handling * fix: format * fix: fix imports * fix: add test case
…ifest files (#9825) (#9833) * Update PrintNamespacesList to break on YAML file separator '---' followed by a new line. * fix: Update PrintNamespacesList to break on YAML file separator '---' followed by a new line. * fix: update yaml line break character and add more tests * fix: use yaml parser to process multiple files * fix: add test for single manifest w break at end * fix: remove unnecessary conversion * fix: update import * fix: if resourceToInfoMap is empty, return nil * fix: format * fix: log fmt write error and update empty manifest (with just ---) handling * fix: format * fix: fix imports * fix: add test case Co-authored-by: Katie Zhang <katiexzhang@gmail.com>
Multiple manifests may be defined in a single YAML file.
---is used to separate the different manifests.Before:
After:
Note: If a file just contains "---" it is considered empty and therefore valid and will just return an empty resourceToInfoMap.