mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-02-16 07:01:11 -05:00
16 lines
442 B
Go
16 lines
442 B
Go
package cliconfig
|
|
|
|
import "os"
|
|
|
|
func getNewOrLegacyPath(newPath string, legacyPath string) (string, error) {
|
|
// If the legacy directory exists, but the new directory does not, then use the legacy directory, for backwards compatibility reasons.
|
|
// Otherwise, use the new directory.
|
|
if _, err := os.Stat(legacyPath); err == nil {
|
|
if _, err := os.Stat(newPath); os.IsNotExist(err) {
|
|
return legacyPath, nil
|
|
}
|
|
}
|
|
|
|
return newPath, nil
|
|
}
|