diff --git a/x/api/defaults.go b/x/api/defaults.go index d714c7ae..1b836eef 100644 --- a/x/api/defaults.go +++ b/x/api/defaults.go @@ -54,13 +54,6 @@ func DefaultSocketPath() string { return filepath.Join(os.TempDir(), "docker-secrets-engine", "engine.sock") } -func DaemonSocketPath() string { - if dir, err := os.UserCacheDir(); err == nil { - return filepath.Join(dir, "docker-secrets-engine", "daemon.sock") - } - return filepath.Join(os.TempDir(), "docker-secrets-engine", "daemon.sock") -} - func DefaultSecretsEngineDirectory() (string, error) { dir, err := os.UserConfigDir() if err != nil { diff --git a/x/api/defaults_unix.go b/x/api/defaults_unix.go new file mode 100644 index 00000000..e0727063 --- /dev/null +++ b/x/api/defaults_unix.go @@ -0,0 +1,29 @@ +// Copyright 2025-2026 Docker, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !windows + +package api + +import ( + "os" + "path/filepath" +) + +func DaemonSocketPath() string { + if dir, err := os.UserCacheDir(); err == nil { + return filepath.Join(dir, "docker-secrets-engine", "daemon.sock") + } + return filepath.Join(os.TempDir(), "docker-secrets-engine", "daemon.sock") +} diff --git a/x/api/defaults_windows.go b/x/api/defaults_windows.go new file mode 100644 index 00000000..2809e6d7 --- /dev/null +++ b/x/api/defaults_windows.go @@ -0,0 +1,30 @@ +// Copyright 2025-2026 Docker, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build windows + +package api + +import ( + "os" + "path/filepath" +) + +func DaemonSocketPath() string { + base := os.Getenv("ProgramData") + if base == "" { + base = `C:\ProgramData` + } + return filepath.Join(base, "Docker", "SecretsEngine", "daemon.sock") +}