| 71 | type profilesParser struct{} |
| 72 | |
| 73 | func (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 | |
| 109 | func NewEagerParser() Parser { |
| 110 | return &eagerParser{} |