VariableDefaults returns the default values for all variables in the module.
(ctx context.Context)
| 295 | |
| 296 | // VariableDefaults returns the default values for all variables in the module. |
| 297 | func (p *Parser) VariableDefaults(ctx context.Context) (map[string]string, error) { |
| 298 | // iterate through vars to get the default values for all |
| 299 | // required variables. |
| 300 | m := make(map[string]string) |
| 301 | for _, v := range p.module.Variables { |
| 302 | if v == nil { |
| 303 | continue |
| 304 | } |
| 305 | sv, err := interfaceToString(v.Default) |
| 306 | if err != nil { |
| 307 | return nil, xerrors.Errorf("can't convert variable default value to string: %v", err) |
| 308 | } |
| 309 | m[v.Name] = strings.Trim(sv, `"`) |
| 310 | } |
| 311 | p.logger.Debug(ctx, "found default values for variables", slog.F("defaults", m)) |
| 312 | return m, nil |
| 313 | } |
| 314 | |
| 315 | // CoderParameterDefaults returns the default values of all coder_parameter data sources |
| 316 | // in the parsed module. |
no test coverage detected