mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 09:17:49 +08:00
driver(docker-container): fix incorrect path when writing certs
Replace invalid characters in the name of the base directory of certificates using the name of the registry which can contain for example a colon when the port is specified. Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
e5f701351c
commit
1c96fdaf03
@ -5,6 +5,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"github.com/pelletier/go-toml"
|
"github.com/pelletier/go-toml"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -19,6 +20,8 @@ const (
|
|||||||
DefaultBuildKitConfigDir = "/etc/buildkit"
|
DefaultBuildKitConfigDir = "/etc/buildkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var reInvalidCertsDir = regexp.MustCompile(`[^a-zA-Z0-9.-]+`)
|
||||||
|
|
||||||
// LoadConfigFiles creates a temp directory with BuildKit config and
|
// LoadConfigFiles creates a temp directory with BuildKit config and
|
||||||
// registry certificates ready to be copied to a container.
|
// registry certificates ready to be copied to a container.
|
||||||
func LoadConfigFiles(bkconfig string) (map[string][]byte, error) {
|
func LoadConfigFiles(bkconfig string) (map[string][]byte, error) {
|
||||||
@ -60,7 +63,7 @@ func LoadConfigFiles(bkconfig string) (map[string][]byte, error) {
|
|||||||
if regConf == nil {
|
if regConf == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
pfx := path.Join("certs", regName)
|
pfx := path.Join("certs", reInvalidCertsDir.ReplaceAllString(regName, "_"))
|
||||||
if regConf.Has("ca") {
|
if regConf.Has("ca") {
|
||||||
regCAs := regConf.GetArray("ca").([]string)
|
regCAs := regConf.GetArray("ca").([]string)
|
||||||
if len(regCAs) > 0 {
|
if len(regCAs) > 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user