Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(linux): DOCKER_CONFIG path #1102

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/finch/main_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ var newApp = func(
logger,
fp.NerdctlConfigFilePath(),
fp.BuildkitSocketPath(),
fp.DockerConfigPath(),
fp.FinchDependencyBinDir(),
system.NewStdLib(),
)
Expand Down
5 changes: 5 additions & 0 deletions pkg/command/nerdctl_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
const (
EnvKeyNerdctlTOML = "NERDCTL_TOML"
EnvKeyBuildkitHost = "BUILDKIT_HOST"
EnvKeyDockerConfig = "DOCKER_CONFIG"
)

type nerdctlCmdCreator struct {
Expand All @@ -28,6 +29,7 @@ type nerdctlCmdCreator struct {
systemDeps NerdctlCmdCreatorSystemDeps
nerdctlConfigPath string
buildkitSocketPath string
dockerConfigPath string
binPath string
}

Expand All @@ -39,6 +41,7 @@ func NewNerdctlCmdCreator(
logger flog.Logger,
nerdctlConfigPath string,
buildkitSocketPath string,
dockerConfigPath string,
binPath string,
systemDeps NerdctlCmdCreatorSystemDeps,
) NerdctlCmdCreator {
Expand All @@ -47,6 +50,7 @@ func NewNerdctlCmdCreator(
logger: logger,
nerdctlConfigPath: nerdctlConfigPath,
buildkitSocketPath: buildkitSocketPath,
dockerConfigPath: dockerConfigPath,
binPath: binPath,
systemDeps: systemDeps,
}
Expand All @@ -65,6 +69,7 @@ func (ncc *nerdctlCmdCreator) create(stdin io.Reader, stdout, stderr io.Writer,
newPathEnv = append(
newPathEnv,
fmt.Sprintf("%s=%s", EnvKeyNerdctlTOML, ncc.nerdctlConfigPath),
fmt.Sprintf("%s=%s", EnvKeyDockerConfig, ncc.dockerConfigPath),
fmt.Sprintf("%s=unix://%s", EnvKeyBuildkitHost, ncc.buildkitSocketPath),
)

Expand Down
3 changes: 3 additions & 0 deletions pkg/command/nerdctl_native_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
const (
mockNerdctlConfigPath = "/etc/finch/nerdctl.toml"
mockBuildkitSocketPath = "/etc/finch/buildkit"
mockDockerConfigPath = "/etc/finch/docker"
mockFinchBinPath = "/usr/lib/usrexec/finch"
mockSystemPath = "/usr/bin"
finalPath = mockFinchBinPath + command.EnvKeyPathJoiner + mockSystemPath
Expand Down Expand Up @@ -47,6 +48,7 @@ func TestLimaCmdCreator_Create(t *testing.T) {
cmd.EXPECT().SetEnv([]string{
fmt.Sprintf("%s=%s", command.EnvKeyPath, finalPath),
fmt.Sprintf("%s=%s", command.EnvKeyNerdctlTOML, mockNerdctlConfigPath),
fmt.Sprintf("%s=%s", command.EnvKeyDockerConfig, mockDockerConfigPath),
fmt.Sprintf("%s=unix://%s", command.EnvKeyBuildkitHost, mockBuildkitSocketPath),
})
cmd.EXPECT().SetStdin(nil)
Expand All @@ -72,6 +74,7 @@ func TestLimaCmdCreator_Create(t *testing.T) {
logger,
mockNerdctlConfigPath,
mockBuildkitSocketPath,
mockDockerConfigPath,
mockFinchBinPath,
lcd,
).Create(mockArgs...)
Expand Down
5 changes: 5 additions & 0 deletions pkg/path/finch_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ func (fp Finch) BuildkitSocketPath() string {
return filepath.Join(fp.FinchRuntimeDataDir(), "buildkit", "buildkitd.sock")
}

// DockerConfigPath returns the path to the docker config file.
func (fp Finch) DockerConfigPath() string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DockerConfigDir?

Also, should we add a comment here that nerdctl uses ${DOCKER_CONFIG}/config.json for the authentication with image registries.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest revision

return filepath.Join(string(fp), "docker")
}

// FinchDependencyBinDir returns the path to Finch's local helper or dependency binaries.
// Currently used for vended version of BuildKit.
func (Finch) FinchDependencyBinDir() string {
Expand Down
Loading