| 174 | } |
| 175 | |
| 176 | func loadAWSProfileSettings(profile string) (awsProfileSettings, bool, error) { |
| 177 | settings := awsProfileSettings{Name: profile} |
| 178 | found := false |
| 179 | |
| 180 | for _, path := range sharedConfigFilesForDebug() { |
| 181 | file, err := os.Open(path) |
| 182 | if err != nil { |
| 183 | if errors.Is(err, os.ErrNotExist) { |
| 184 | continue |
| 185 | } |
| 186 | return awsProfileSettings{}, false, err |
| 187 | } |
| 188 | |
| 189 | fileFound, fileErr := parseAWSConfigProfile(file, profile, &settings) |
| 190 | _ = file.Close() |
| 191 | if fileErr != nil { |
| 192 | return awsProfileSettings{}, false, fmt.Errorf("parse %s: %w", path, fileErr) |
| 193 | } |
| 194 | found = found || fileFound |
| 195 | } |
| 196 | |
| 197 | return settings, found, nil |
| 198 | } |
| 199 | |
| 200 | func parseAWSConfigProfile(file *os.File, profile string, settings *awsProfileSettings) (bool, error) { |
| 201 | scanner := bufio.NewScanner(file) |