ReadConfig reads a builder configuration from the file path provided and returns the configuration along with any warnings encountered while parsing
(path string)
| 98 | // ReadConfig reads a builder configuration from the file path provided and returns the |
| 99 | // configuration along with any warnings encountered while parsing |
| 100 | func ReadConfig(path string) (config Config, warnings []string, err error) { |
| 101 | file, err := os.Open(filepath.Clean(path)) |
| 102 | if err != nil { |
| 103 | return Config{}, nil, errors.Wrap(err, "opening config file") |
| 104 | } |
| 105 | defer file.Close() |
| 106 | |
| 107 | config, err = parseConfig(file) |
| 108 | if err != nil { |
| 109 | return Config{}, nil, errors.Wrapf(err, "parse contents of '%s'", path) |
| 110 | } |
| 111 | |
| 112 | if len(config.Order) == 0 { |
| 113 | warnings = append(warnings, fmt.Sprintf("empty %s definition", style.Symbol("order"))) |
| 114 | } |
| 115 | |
| 116 | config.mergeStackWithImages() |
| 117 | |
| 118 | return config, warnings, nil |
| 119 | } |
| 120 | |
| 121 | // ValidateConfig validates the config |
| 122 | func ValidateConfig(c Config) error { |