mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Add new or legacy path util
This commit is contained in:
15
internal/command/cliconfig/util.go
Normal file
15
internal/command/cliconfig/util.go
Normal file
@@ -0,0 +1,15 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user