WithDefaultConfigPath searches for default config files from working directory
(o *ProjectOptions)
| 153 | |
| 154 | // WithDefaultConfigPath searches for default config files from working directory |
| 155 | func WithDefaultConfigPath(o *ProjectOptions) error { |
| 156 | if len(o.ConfigPaths) > 0 { |
| 157 | return nil |
| 158 | } |
| 159 | pwd, err := o.GetWorkingDir() |
| 160 | if err != nil { |
| 161 | return err |
| 162 | } |
| 163 | for { |
| 164 | candidates := findFiles(DefaultFileNames, pwd) |
| 165 | if len(candidates) > 0 { |
| 166 | winner := candidates[0] |
| 167 | if len(candidates) > 1 { |
| 168 | logrus.Warnf("Found multiple config files with supported names: %s", strings.Join(candidates, ", ")) |
| 169 | logrus.Warnf("Using %s", winner) |
| 170 | } |
| 171 | o.ConfigPaths = append(o.ConfigPaths, winner) |
| 172 | |
| 173 | overrides := findFiles(DefaultOverrideFileNames, pwd) |
| 174 | if len(overrides) > 0 { |
| 175 | if len(overrides) > 1 { |
| 176 | logrus.Warnf("Found multiple override files with supported names: %s", strings.Join(overrides, ", ")) |
| 177 | logrus.Warnf("Using %s", overrides[0]) |
| 178 | } |
| 179 | o.ConfigPaths = append(o.ConfigPaths, overrides[0]) |
| 180 | } |
| 181 | return nil |
| 182 | } |
| 183 | parent := filepath.Dir(pwd) |
| 184 | if parent == pwd { |
| 185 | // no config file found, but that's not a blocker if caller only needs project name |
| 186 | return nil |
| 187 | } |
| 188 | pwd = parent |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | // WithEnv defines a key=value set of variables used for compose file interpolation |
| 193 | func WithEnv(env []string) ProjectOptionsFn { |
nothing calls this directly
no test coverage detected
searching dependent graphs…