MCPcopy Create free account
hub / github.com/devspace-sh/devspace / Parse

Method Parse

pkg/devspace/config/loader/parser.go:73–107  ·  view source on GitHub ↗
(ctx context.Context, originalRawConfig map[string]interface{}, rawConfig map[string]interface{}, resolver variable.Resolver, log log.Logger)

Source from the content-addressed store, hash-verified

71type profilesParser struct{}
72
73func (p *profilesParser) Parse(ctx context.Context, originalRawConfig map[string]interface{}, rawConfig map[string]interface{}, resolver variable.Resolver, log log.Logger) (*latest.Config, map[string]interface{}, error) {
74 rawMap, err := copyRaw(originalRawConfig)
75 if err != nil {
76 return nil, nil, err
77 }
78
79 profiles, ok := rawMap["profiles"].([]interface{})
80 if !ok {
81 profiles = []interface{}{}
82 }
83
84 retProfiles := []*latest.ProfileConfig{}
85 for _, profile := range profiles {
86 profileMap, ok := profile.(map[string]interface{})
87 if !ok {
88 continue
89 }
90
91 profileConfig := &latest.ProfileConfig{}
92 o, err := yaml.Marshal(profileMap)
93 if err != nil {
94 continue
95 }
96 err = yamlutil.Unmarshal(o, profileConfig)
97 if err != nil {
98 continue
99 }
100
101 retProfiles = append(retProfiles, profileConfig)
102 }
103
104 retConfig := latest.NewRaw()
105 retConfig.Profiles = retProfiles
106 return retConfig, rawMap, nil
107}
108
109func NewEagerParser() Parser {
110 return &eagerParser{}

Callers

nothing calls this directly

Calls 3

UnmarshalFunction · 0.92
NewRawFunction · 0.92
copyRawFunction · 0.85

Tested by

no test coverage detected