@@ -1,6 +1,7 @@
1package config
1package config
5 "encoding/json"
6 "encoding/json"
@@ -695,19 +696,22 @@ func hasAWSCredentials(env env.Env) bool {
696// GlobalConfig returns the global configuration file path for the application.
697// GlobalConfig returns the global configuration file path for the application.
697func GlobalConfig() string {
698func GlobalConfig() string {
699+ if crushGlobal := os.Getenv("CRUSH_GLOBAL_CONFIG"); crushGlobal != "" {
700+ return filepath.Join(crushGlobal, fmt.Sprintf("%s.json", appName))
698− xdgConfigHome := os.Getenv("XDG_CONFIG_HOME")
702+ if xdgConfigHome := os.Getenv("XDG_CONFIG_HOME"); xdgConfigHome != "" {
699− if xdgConfigHome != "" {
700 return filepath.Join(xdgConfigHome, appName, fmt.Sprintf("%s.json", appName))
703 return filepath.Join(xdgConfigHome, appName, fmt.Sprintf("%s.json", appName))
703 return filepath.Join(home.Dir(), ".config", appName, fmt.Sprintf("%s.json", appName))
705 return filepath.Join(home.Dir(), ".config", appName, fmt.Sprintf("%s.json", appName))
706// GlobalConfigData returns the path to the main data directory for the application.
708// GlobalConfigData returns the path to the main data directory for the application.
707// this config is used when the app overrides configurations instead of updating the global config.
709// this config is used when the app overrides configurations instead of updating the global config.
708func GlobalConfigData() string {
710func GlobalConfigData() string {
711+ if crushData := os.Getenv("CRUSH_GLOBAL_DATA"); crushData != "" {
712+ return filepath.Join(crushData, fmt.Sprintf("%s.json", appName))
709− xdgDataHome := os.Getenv("XDG_DATA_HOME")
714+ if xdgDataHome := os.Getenv("XDG_DATA_HOME"); xdgDataHome != "" {
710− if xdgDataHome != "" {
711 return filepath.Join(xdgDataHome, appName, fmt.Sprintf("%s.json", appName))
715 return filepath.Join(xdgDataHome, appName, fmt.Sprintf("%s.json", appName))
@@ -715,10 +719,10 @@ func GlobalConfigData() string {
715 // for windows, it should be in `%LOCALAPPDATA%/crush/`
719 // for windows, it should be in `%LOCALAPPDATA%/crush/`
716 // for linux and macOS, it should be in `$HOME/.local/share/crush/`
720 // for linux and macOS, it should be in `$HOME/.local/share/crush/`
717 if runtime.GOOS == "windows" {
721 if runtime.GOOS == "windows" {
722+ localAppData := cmp.Or(
718− localAppData := os.Getenv("LOCALAPPDATA")
723+ os.Getenv("LOCALAPPDATA"),
719− if localAppData == "" {
720− localAppData = filepath.Join(os.Getenv("USERPROFILE"), "AppData", "Local")
724+ filepath.Join(os.Getenv("USERPROFILE"), "AppData", "Local"),
722 return filepath.Join(localAppData, appName, fmt.Sprintf("%s.json", appName))
726 return filepath.Join(localAppData, appName, fmt.Sprintf("%s.json", appName))