Skip to content

Commit e3d6014

Browse files
authored
fix: rename tool version filename environment variable for clarity (#2101)
1 parent 40a7924 commit e3d6014

File tree

11 files changed

+62
-54
lines changed

11 files changed

+62
-54
lines changed

docs/ja-jp/manage/configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ pre_foo_bar = echo Executing with args: $@
177177
- 未設定の場合: `$HOME/.asdfrc`の値が使用されます。
178178
- 使用方法: `export ASDF_CONFIG_FILE=/home/john_doe/.config/asdf/.asdfrc`
179179

180-
### `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME`
180+
### `ASDF_TOOL_VERSIONS_FILENAME`
181181

182182
ツール名とバージョンの情報を格納するファイルのファイル名です。有効なファイル名であれば何でも設定できます。通常、`.tool-versions`ファイルを無視したい場合を除き、この値を変更するべきではありません。
183183

184184
- 未設定の場合: `.tool-versions`の値が使用されます。
185-
- 使用方法: `export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=tool_versions`
185+
- 使用方法: `export ASDF_TOOL_VERSIONS_FILENAME=tool_versions`
186186

187187
### `ASDF_DIR`
188188

@@ -220,7 +220,7 @@ pre_foo_bar = echo Executing with args: $@
220220
| 構成 || 値がセットされる過程 |
221221
| :------------------------------------ | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------ |
222222
| config file location | `$HOME/.asdfrc` | `ASDF_CONFIG_FILE`は空なので、`$HOME/.asdfrc`が使用されます。 |
223-
| default tool versions filename | `.tool-versions` | `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME`は空なので、`.tool-versions`が使用されます。 |
223+
| default tool versions filename | `.tool-versions` | `ASDF_TOOL_VERSIONS_FILENAME`は空なので、`.tool-versions`が使用されます。 |
224224
| asdf dir | `$HOME/.asdf` | `ASDF_DIR`は空なので、`bin/asdf`の親ディレクトリが使用されます。 |
225225
| asdf data dir | `$HOME/.asdf` | `ASDF_DATA_DIR`は空であり、`$HOME`が存在するので、`$HOME/.asdf`が使用されます。 |
226226
| concurrency | `auto` | `ASDF_CONCURRENCY`は空なので、[デフォルト構成](https://github.com/asdf-vm/asdf/blob/master/defaults)`concurrency`の値に依存します。 |

docs/ko-kr/manage/configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ pre_foo_bar = echo Executing with args: $@
183183
- 미설정 시: `$HOME/.asdfrc`가 사용됩니다.
184184
- 사용법: `export ASDF_CONFIG_FILE=/home/john_doe/.config/asdf/.asdfrc`
185185

186-
### `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME`
186+
### `ASDF_TOOL_VERSIONS_FILENAME`
187187

188188
툴 이름과 버전을 저장하는 파일의 파일이름입니다. 임의의 유효한 파일 이름이면 됩니다. 일반적으로, `.tool-version` 파일들을 무시하고 싶을 때 해당 값을 설정하세요.
189189

190190
- 미설정 시: `.tool-versions`가 사용됩니다.
191-
- 사용법: `export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=tool_versions`
191+
- 사용법: `export ASDF_TOOL_VERSIONS_FILENAME=tool_versions`
192192

193193
### `ASDF_DIR`
194194

@@ -226,7 +226,7 @@ pre_foo_bar = echo Executing with args: $@
226226
| 항목 || 값이 세팅되는 과정 |
227227
| :------------------------------------ | :--------------- | :--------------------------------------------------------------------------------------------------------------------------- |
228228
| config file location | `$HOME/.asdfrc` | `ASDF_CONFIG_FILE`가 비었으므로, `$HOME/.asdfrc`을 사용 |
229-
| default tool versions filename | `.tool-versions` | `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME`가 비었으므로, `.tool-versions`을 사용 |
229+
| default tool versions filename | `.tool-versions` | `ASDF_TOOL_VERSIONS_FILENAME`가 비었으므로, `.tool-versions`을 사용 |
230230
| asdf dir | `$HOME/.asdf` | `ASDF_DIR`가 비었으므로, `bin/asdf`의 한 단계 상위 디렉토리 사용 |
231231
| asdf data dir | `$HOME/.asdf` | `ASDF_DATA_DIR`가 비었으므로, `$HOME/.asdf``$HOME`으로 사용. |
232232
| concurrency | `auto` | `ASDF_CONCURRENCY`가 비었으므로, [기본 설정](https://github.com/asdf-vm/asdf/blob/master/defaults)`concurrency` 값에 의존 |

docs/manage/configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ Path to the `.asdfrc` configuration file. Can be set to any location. Must be an
177177
- If Unset: `$HOME/.asdfrc` will be used.
178178
- Usage: `export ASDF_CONFIG_FILE=/home/john_doe/.config/asdf/.asdfrc`
179179

180-
### `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME`
180+
### `ASDF_TOOL_VERSIONS_FILENAME`
181181

182182
The filename of the file storing the tool names and versions. Can be any valid filename. Typically, you should not set this value unless you want to ignore `.tool-versions` files.
183183

184184
- If Unset: `.tool-versions` will be used.
185-
- Usage: `export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=tool_versions`
185+
- Usage: `export ASDF_TOOL_VERSIONS_FILENAME=tool_versions`
186186

187187
### `ASDF_DIR`
188188

@@ -220,7 +220,7 @@ would result in the following outcomes:
220220
| Configuration | Value | Calculated by |
221221
| :------------------------------------ | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
222222
| config file location | `$HOME/.asdfrc` | `ASDF_CONFIG_FILE` is empty, so use `$HOME/.asdfrc` |
223-
| default tool versions filename | `.tool-versions` | `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME` is empty, so use `.tool-versions` |
223+
| default tool versions filename | `.tool-versions` | `ASDF_TOOL_VERSIONS_FILENAME` is empty, so use `.tool-versions` |
224224
| asdf dir | `$HOME/.asdf` | `ASDF_DIR` is empty, so use parent dir of `bin/asdf` |
225225
| asdf data dir | `$HOME/.asdf` | `ASDF_DATA_DIR` is empty so use `$HOME/.asdf` as `$HOME` exists. |
226226
| concurrency | `auto` | `ASDF_CONCURRENCY` is empty, so rely on `concurrency` value from the [default configuration](https://github.com/asdf-vm/asdf/blob/master/defaults) |

docs/pt-br/manage/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ legacy_version_file = yes
5656
## Variáveis de ambiente
5757

5858
- `ASDF_CONFIG_FILE` - O padrão é `~ /.asdfrc` conforme descrito acima. Pode ser definido para qualquer local.
59-
- `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME` - O nome do arquivo que armazena os nomes e versões das ferramentas. O padrão é `.tool-versions`. Pode ser qualquer nome de arquivo válido. Normalmente você não deve substituir o valor padrão, a menos que deseja que o asdf ignore os arquivos `.tool-versions`.
59+
- `ASDF_TOOL_VERSIONS_FILENAME` - O nome do arquivo que armazena os nomes e versões das ferramentas. O padrão é `.tool-versions`. Pode ser qualquer nome de arquivo válido. Normalmente você não deve substituir o valor padrão, a menos que deseja que o asdf ignore os arquivos `.tool-versions`.
6060
- `ASDF_DIR` - O padrão é `~/.asdf` - Localização dos arquivos `asdf`. Se você instalar `asdf` em algum outro diretório, defina-o para esse diretório. Por exemplo, se você estiver instalando através do AUR, você deve definir isso para `/opt/asdf-vm`.
6161
- `ASDF_DATA_DIR` - O padrão é `~/.asdf` - Local onde `asdf` instala plugins, correções e instalações. Pode ser definido para qualquer local antes de fornecer `asdf.sh` ou `asdf.fish` mencionado na seção acima. Para Elvish, isso pode ser definido acima de `use asdf`.

docs/zh-hans/manage/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ concurrency = auto
9292
## 环境变量
9393

9494
- `ASDF_CONFIG_FILE` - 如上所述默认为 `~/.asdfrc` 文件。可以被设置在任何位置。
95-
- `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME` - 存储工具名称和版本的文件名。默认为 `.tool-versions`。可以是任何有效的文件名。通常,除非你知道你希望 asdf 忽略 `.tool-versions` 文件,否则不应该覆盖默认值。
95+
- `ASDF_TOOL_VERSIONS_FILENAME` - 存储工具名称和版本的文件名。默认为 `.tool-versions`。可以是任何有效的文件名。通常,除非你知道你希望 asdf 忽略 `.tool-versions` 文件,否则不应该覆盖默认值。
9696
- `ASDF_DIR` - 默认为 `~/.asdf` - `asdf` 脚本的位置。如果你把 `asdf` 安装到了其他目录,请设置该变量到那个目录。比如,如果通过 AUR 进行安装,则应设置该变量为 `/opt/asdf-vm`
9797
- `ASDF_DATA_DIR` - 默认为 `~/.asdf` - `asdf` 安装插件、垫片和安装器的位置。可以被设置在上一节提到的生效 `asdf.sh` 或者 `asdf.fish` 之间的任何位置。对于 Elvish,这可以设置在 `use asdf` 上面。

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require (
77
github.com/mgechev/revive v1.7.0
88
github.com/otiai10/copy v1.14.0
99
github.com/rogpeppe/go-internal v1.12.0
10-
github.com/sethvargo/go-envconfig v1.1.1
1110
github.com/stretchr/testify v1.10.0
1211
github.com/urfave/cli/v3 v3.3.3
1312
golang.org/x/sys v0.31.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU
8989
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
9090
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
9191
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
92-
github.com/sethvargo/go-envconfig v1.1.1 h1:JDu8Q9baIzJf47NPkzhIB6aLYL0vQ+pPypoYrejS9QY=
93-
github.com/sethvargo/go-envconfig v1.1.1/go.mod h1:JLd0KFWQYzyENqnEPWWZ49i4vzZo/6nRidxI8YvGiHw=
9492
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
9593
github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY=
9694
github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M=

internal/config/config.go

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
package config
44

55
import (
6-
"context"
76
"io/fs"
87
"os"
98
"path/filepath"
109
"runtime"
1110
"strconv"
1211
"strings"
1312

14-
"github.com/sethvargo/go-envconfig"
1513
"gopkg.in/ini.v1"
1614
)
1715

@@ -35,14 +33,11 @@ var pluginRepoCheckDurationDefault = PluginRepoCheckDuration{Every: 60}
3533
// Config is the primary value this package builds and returns
3634
type Config struct {
3735
Home string
38-
ConfigFile string `env:"ASDF_CONFIG_FILE, overwrite"`
39-
DefaultToolVersionsFilename string `env:"ASDF_DEFAULT_TOOL_VERSIONS_FILENAME, overwrite"`
40-
// Unclear if this value will be needed with the golang implementation.
41-
// AsdfDir string
42-
DataDir string `env:"ASDF_DATA_DIR, overwrite"`
43-
// Field that stores the settings struct if it is loaded
44-
Settings Settings
45-
PluginIndexURL string
36+
ConfigFile string
37+
DefaultToolVersionsFilename string
38+
DataDir string
39+
Settings Settings
40+
PluginIndexURL string
4641
}
4742

4843
// Settings is a struct that stores config values from the asdfrc file
@@ -102,10 +97,26 @@ func LoadConfig() (Config, error) {
10297
return Config{}, err
10398
}
10499

105-
ctx := context.Background()
106-
err = envconfig.Process(ctx, config)
107-
if err != nil {
108-
return Config{}, err
100+
configFile := os.Getenv("ASDF_CONFIG_FILE")
101+
if configFile != "" {
102+
config.ConfigFile = configFile
103+
}
104+
105+
dataDir := os.Getenv("ASDF_DATA_DIR")
106+
if dataDir != "" {
107+
config.DataDir = dataDir
108+
}
109+
110+
versionFilename := os.Getenv("ASDF_TOOL_VERSIONS_FILENAME")
111+
if versionFilename != "" {
112+
config.DefaultToolVersionsFilename = versionFilename
113+
} else {
114+
// ASDF_TOOL_VERSIONS_FILENAME is the new environment variable name. It used
115+
// to be named ASDF_DEFAULT_TOOL_VERSIONS_FILENAME
116+
versionFilename = os.Getenv("ASDF_DEFAULT_TOOL_VERSIONS_FILENAME")
117+
if versionFilename != "" {
118+
config.DefaultToolVersionsFilename = versionFilename
119+
}
109120
}
110121

111122
config.Home = homeDir

internal/info/info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func Write(conf config.Config, version string, writer io.Writer) error {
4747
fmt.Fprintf(writer, "%s\n", version)
4848

4949
fmt.Fprintln(writer, "\nASDF INTERNAL VARIABLES:")
50-
fmt.Fprintf(writer, "ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=%s\n", conf.DefaultToolVersionsFilename)
50+
fmt.Fprintf(writer, "ASDF_TOOL_VERSIONS_FILENAME=%s\n", conf.DefaultToolVersionsFilename)
5151
fmt.Fprintf(writer, "ASDF_DATA_DIR=%s\n", conf.DataDir)
5252
fmt.Fprintf(writer, "ASDF_CONFIG_FILE=%s\n", conf.ConfigFile)
5353

test/utils.bats

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,18 @@ teardown() {
217217
[ "$output" = "" ]
218218
}
219219

220-
@test "find_versions should return \$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME if set" {
221-
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="$PROJECT_DIR/global-tool-versions"
222-
echo "dummy 0.1.0" >"$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME"
220+
@test "find_versions should return \$ASDF_TOOL_VERSIONS_FILENAME if set" {
221+
ASDF_TOOL_VERSIONS_FILENAME="$PROJECT_DIR/global-tool-versions"
222+
echo "dummy 0.1.0" >"$ASDF_TOOL_VERSIONS_FILENAME"
223223

224224
run find_versions "dummy" "$PROJECT_DIR"
225225
[ "$status" -eq 0 ]
226-
[ "$output" = "0.1.0|$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" ]
226+
[ "$output" = "0.1.0|$ASDF_TOOL_VERSIONS_FILENAME" ]
227227
}
228228

229-
@test "find_versions should check \$HOME legacy files before \$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" {
230-
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="$PROJECT_DIR/global-tool-versions"
231-
echo "dummy 0.2.0" >"$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME"
229+
@test "find_versions should check \$HOME legacy files before \$ASDF_TOOL_VERSIONS_FILENAME" {
230+
ASDF_TOOL_VERSIONS_FILENAME="$PROJECT_DIR/global-tool-versions"
231+
echo "dummy 0.2.0" >"$ASDF_TOOL_VERSIONS_FILENAME"
232232
echo "dummy 0.1.0" >"$HOME/.dummy-version"
233233
echo "legacy_version_file = yes" >"$HOME/.asdfrc"
234234

0 commit comments

Comments
 (0)