Skip to content

Commit 5b45b75

Browse files
authored
fix(linux): DOCKER_CONFIG path (runfinch#1102)
* fix(linux): DOCKER_CONFIG path Signed-off-by: Justin Alvarez <[email protected]> * rename DockerConfigPath to DockerConfigDir and update comment Signed-off-by: Justin Alvarez <[email protected]> --------- Signed-off-by: Justin Alvarez <[email protected]>
1 parent bdeb3c7 commit 5b45b75

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

Diff for: cmd/finch/main_native.go

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ var newApp = func(
8686
logger,
8787
fp.NerdctlConfigFilePath(),
8888
fp.BuildkitSocketPath(),
89+
fp.DockerConfigDir(),
8990
fp.FinchDependencyBinDir(),
9091
system.NewStdLib(),
9192
)

Diff for: pkg/command/nerdctl_native.go

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
const (
2121
EnvKeyNerdctlTOML = "NERDCTL_TOML"
2222
EnvKeyBuildkitHost = "BUILDKIT_HOST"
23+
EnvKeyDockerConfig = "DOCKER_CONFIG"
2324
)
2425

2526
type nerdctlCmdCreator struct {
@@ -28,6 +29,7 @@ type nerdctlCmdCreator struct {
2829
systemDeps NerdctlCmdCreatorSystemDeps
2930
nerdctlConfigPath string
3031
buildkitSocketPath string
32+
dockerConfigPath string
3133
binPath string
3234
}
3335

@@ -39,6 +41,7 @@ func NewNerdctlCmdCreator(
3941
logger flog.Logger,
4042
nerdctlConfigPath string,
4143
buildkitSocketPath string,
44+
dockerConfigPath string,
4245
binPath string,
4346
systemDeps NerdctlCmdCreatorSystemDeps,
4447
) NerdctlCmdCreator {
@@ -47,6 +50,7 @@ func NewNerdctlCmdCreator(
4750
logger: logger,
4851
nerdctlConfigPath: nerdctlConfigPath,
4952
buildkitSocketPath: buildkitSocketPath,
53+
dockerConfigPath: dockerConfigPath,
5054
binPath: binPath,
5155
systemDeps: systemDeps,
5256
}
@@ -65,6 +69,7 @@ func (ncc *nerdctlCmdCreator) create(stdin io.Reader, stdout, stderr io.Writer,
6569
newPathEnv = append(
6670
newPathEnv,
6771
fmt.Sprintf("%s=%s", EnvKeyNerdctlTOML, ncc.nerdctlConfigPath),
72+
fmt.Sprintf("%s=%s", EnvKeyDockerConfig, ncc.dockerConfigPath),
6873
fmt.Sprintf("%s=unix://%s", EnvKeyBuildkitHost, ncc.buildkitSocketPath),
6974
)
7075

Diff for: pkg/command/nerdctl_native_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
const (
1919
mockNerdctlConfigPath = "/etc/finch/nerdctl.toml"
2020
mockBuildkitSocketPath = "/etc/finch/buildkit"
21+
mockDockerConfigPath = "/etc/finch/docker"
2122
mockFinchBinPath = "/usr/lib/usrexec/finch"
2223
mockSystemPath = "/usr/bin"
2324
finalPath = mockFinchBinPath + command.EnvKeyPathJoiner + mockSystemPath
@@ -47,6 +48,7 @@ func TestLimaCmdCreator_Create(t *testing.T) {
4748
cmd.EXPECT().SetEnv([]string{
4849
fmt.Sprintf("%s=%s", command.EnvKeyPath, finalPath),
4950
fmt.Sprintf("%s=%s", command.EnvKeyNerdctlTOML, mockNerdctlConfigPath),
51+
fmt.Sprintf("%s=%s", command.EnvKeyDockerConfig, mockDockerConfigPath),
5052
fmt.Sprintf("%s=unix://%s", command.EnvKeyBuildkitHost, mockBuildkitSocketPath),
5153
})
5254
cmd.EXPECT().SetStdin(nil)
@@ -72,6 +74,7 @@ func TestLimaCmdCreator_Create(t *testing.T) {
7274
logger,
7375
mockNerdctlConfigPath,
7476
mockBuildkitSocketPath,
77+
mockDockerConfigPath,
7578
mockFinchBinPath,
7679
lcd,
7780
).Create(mockArgs...)

Diff for: pkg/path/finch_linux.go

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ func (fp Finch) BuildkitSocketPath() string {
3434
return filepath.Join(fp.FinchRuntimeDataDir(), "buildkit", "buildkitd.sock")
3535
}
3636

37+
// DockerConfigDir returns the path to the docker config file.
38+
// nerdctl uses ${DOCKER_CONFIG}/config.json for authentication with image registries.
39+
func (fp Finch) DockerConfigDir() string {
40+
return filepath.Join(string(fp), "docker")
41+
}
42+
3743
// FinchDependencyBinDir returns the path to Finch's local helper or dependency binaries.
3844
// Currently used for vended version of BuildKit.
3945
func (Finch) FinchDependencyBinDir() string {

0 commit comments

Comments
 (0)