MCPcopy
hub / github.com/databus23/helm-diff / Parse

Function Parse

manifest/parse.go:73–106  ·  view source on GitHub ↗

Parse parses manifest bytes into MappingResult

(manifest []byte, defaultNamespace string, normalizeManifests bool, excludedHooks ...string)

Source from the content-addressed store, hash-verified

71
72// Parse parses manifest bytes into MappingResult
73func Parse(manifest []byte, defaultNamespace string, normalizeManifests bool, excludedHooks ...string) map[string]*MappingResult {
74 scanner := bufio.NewScanner(io.MultiReader(strings.NewReader("\n"), bytes.NewReader(manifest)))
75 scanner.Split(scanYamlSpecs)
76 // Allow for tokens (specs) up to 10MiB in size
77 scanner.Buffer(make([]byte, bufio.MaxScanTokenSize), 10485760)
78
79 result := make(map[string]*MappingResult)
80
81 for scanner.Scan() {
82 content := bytes.TrimSpace(scanner.Bytes())
83 if len(content) == 0 {
84 continue
85 }
86
87 parsed, err := parseContent(content, defaultNamespace, normalizeManifests, excludedHooks...)
88 if err != nil {
89 log.Fatalf("%v", err)
90 }
91
92 for _, p := range parsed {
93 name := p.Name
94
95 if _, ok := result[name]; ok {
96 log.Printf("Error: Found duplicate key %#v in manifest", name)
97 } else {
98 result[name] = p
99 }
100 }
101 }
102 if err := scanner.Err(); err != nil {
103 log.Fatalf("Error reading input: %s", err)
104 }
105 return result
106}
107
108func ParseObject(object runtime.Object, defaultNamespace string, excludedHooks ...string) (*MappingResult, string, error) {
109 json, _ := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(object)

Callers 15

differentiateHelm3Method · 0.92
runMethod · 0.92
differentiateHelm3Method · 0.92
runHelm3Method · 0.92
backcastHelm3Method · 0.92
TestPodFunction · 0.85
TestPodNamespaceFunction · 0.85
TestPodHookFunction · 0.85

Calls 1

parseContentFunction · 0.85

Tested by 14

TestPodFunction · 0.68
TestPodNamespaceFunction · 0.68
TestPodHookFunction · 0.68
TestDeployV1Function · 0.68
TestDeployV1Beta1Function · 0.68
TestListFunction · 0.68
TestConfigMapListFunction · 0.68
TestSecretListFunction · 0.68