MCPcopy Index your code
hub / github.com/devspace-sh/devspace / Apply

Method Apply

pkg/devspace/config/loader/patch/patch.go:16–35  ·  view source on GitHub ↗

Apply returns a YAML document that has been mutated per patch

(doc []byte)

Source from the content-addressed store, hash-verified

14
15// Apply returns a YAML document that has been mutated per patch
16func (p Patch) Apply(doc []byte) ([]byte, error) {
17 if len(p) == 0 {
18 return doc, nil
19 }
20
21 node := &yaml.Node{}
22 err := yamlutil.Unmarshal(doc, node)
23 if err != nil {
24 return nil, fmt.Errorf("failed unmarshaling doc: %s\n\n%s", string(doc), err)
25 }
26
27 for _, op := range p {
28 err = op.Perform(node)
29 if err != nil {
30 return nil, err
31 }
32 }
33
34 return yaml.Marshal(node)
35}
36
37func NewNode(raw *interface{}) (*yaml.Node, error) {
38 doc, err := yaml.Marshal(raw)

Callers 3

applyDeployPatchesMethod · 0.95
ApplyPatchesOnObjectFunction · 0.95
TestApplyFunction · 0.80

Calls 3

UnmarshalFunction · 0.92
PerformMethod · 0.80
ErrorfMethod · 0.45

Tested by 1

TestApplyFunction · 0.64