mirror of
https://github.com/thegeeklab/wp-docker-buildx.git
synced 2024-11-26 05:30:39 +00:00
Using more generic configuration & respecting win
This commit is contained in:
parent
18c4e995d3
commit
063f479004
@ -209,9 +209,9 @@ func main() {
|
|||||||
EnvVar: "PLUGIN_EMAIL,DOCKER_EMAIL",
|
EnvVar: "PLUGIN_EMAIL,DOCKER_EMAIL",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "docker.authconfig",
|
Name: "docker.docker_config",
|
||||||
Usage: "docker json authconfig content",
|
Usage: "docker json dockerconfig content",
|
||||||
EnvVar: "PLUGIN_AUTHCONFIG,DOCKER_AUTHCONFIG",
|
EnvVar: "PLUGIN_DOCKER_CONFIG,DOCKER_CONFIG",
|
||||||
},
|
},
|
||||||
cli.BoolTFlag{
|
cli.BoolTFlag{
|
||||||
Name: "docker.purge",
|
Name: "docker.purge",
|
||||||
@ -249,7 +249,7 @@ func run(c *cli.Context) error {
|
|||||||
Username: c.String("docker.username"),
|
Username: c.String("docker.username"),
|
||||||
Password: c.String("docker.password"),
|
Password: c.String("docker.password"),
|
||||||
Email: c.String("docker.email"),
|
Email: c.String("docker.email"),
|
||||||
AuthConfig: c.String("docker.authconfig"),
|
DockerConfig: c.String("docker.docker_config"),
|
||||||
},
|
},
|
||||||
Build: docker.Build{
|
Build: docker.Build{
|
||||||
Remote: c.String("remote.url"),
|
Remote: c.String("remote.url"),
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
const dockerExe = "/usr/local/bin/docker"
|
const dockerExe = "/usr/local/bin/docker"
|
||||||
const dockerdExe = "/usr/local/bin/dockerd"
|
const dockerdExe = "/usr/local/bin/dockerd"
|
||||||
|
const dockerrootconfdir = "/root/.docker/"
|
||||||
|
|
||||||
func (p Plugin) startDaemon() {
|
func (p Plugin) startDaemon() {
|
||||||
cmd := commandDaemon(p.Daemon)
|
cmd := commandDaemon(p.Daemon)
|
||||||
|
@ -4,6 +4,7 @@ package docker
|
|||||||
|
|
||||||
const dockerExe = "C:\\bin\\docker.exe"
|
const dockerExe = "C:\\bin\\docker.exe"
|
||||||
const dockerdExe = ""
|
const dockerdExe = ""
|
||||||
|
const dockerrootconfdir = "C:\\ProgramData\\docker\"
|
||||||
|
|
||||||
func (p Plugin) startDaemon() {
|
func (p Plugin) startDaemon() {
|
||||||
// this is a no-op on windows
|
// this is a no-op on windows
|
||||||
|
38
docker.go
38
docker.go
@ -6,6 +6,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -32,7 +33,7 @@ type (
|
|||||||
Username string // Docker registry username
|
Username string // Docker registry username
|
||||||
Password string // Docker registry password
|
Password string // Docker registry password
|
||||||
Email string // Docker registry email
|
Email string // Docker registry email
|
||||||
AuthConfig string // Docker Auth Config
|
DockerConfig string // Docker Auth Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build defines Docker build parameters.
|
// Build defines Docker build parameters.
|
||||||
@ -85,32 +86,19 @@ func (p Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create Auth Config File
|
// Create Auth Config File
|
||||||
if p.Login.AuthConfig != "" {
|
if p.Login.DockerConfig != "" {
|
||||||
fmt.Println("AuthConfig provided.")
|
fmt.Println("DockerConfig provided.")
|
||||||
err_mkdir := os.MkdirAll("/root/.docker", 0600)
|
err_mkdir := os.MkdirAll(dockerrootconfdir, 0600)
|
||||||
if err_mkdir != nil {
|
if err_mkdir != nil {
|
||||||
fmt.Println("Error creating root's docker auth config directory: ")
|
fmt.Println("Error creating root's docker auth config directory: ")
|
||||||
fmt.Println(err_mkdir)
|
fmt.Println(err_mkdir)
|
||||||
}
|
}
|
||||||
cfile, err_create := os.Create("/root/.docker/config.json")
|
conffile := fmt.Sprintf("%s%s", dockerrootconfdir, "config.json")
|
||||||
if err_create != nil {
|
err_mkconf := ioutil.WriteFile(conffile, []byte(p.Login.DockerConfig), 0600)
|
||||||
fmt.Println("Error creating root's docker auth config file: ")
|
if err_mkconf != nil {
|
||||||
fmt.Println(err_create)
|
fmt.Println("Error creating root's docker auth configuration: ")
|
||||||
cfile.Close()
|
fmt.Println(err_mkconf)
|
||||||
}
|
}
|
||||||
err_chmod := os.Chmod("/root/.docker/config.json", 0600)
|
|
||||||
if err_chmod != nil {
|
|
||||||
fmt.Println("Error setting permissions on root's docker auth config file: ")
|
|
||||||
fmt.Println(err_chmod)
|
|
||||||
}
|
|
||||||
_, err_str := cfile.WriteString(p.Login.AuthConfig)
|
|
||||||
if err_str != nil {
|
|
||||||
fmt.Println("Error filling root's docker auth config file: ")
|
|
||||||
fmt.Println(err_str)
|
|
||||||
} else {
|
|
||||||
cfile.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// login to the Docker registry
|
// login to the Docker registry
|
||||||
@ -120,8 +108,10 @@ func (p Plugin) Exec() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error authenticating: %s", err)
|
return fmt.Errorf("Error authenticating: %s", err)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
fmt.Println("Registry credentials not provided. Guest mode enabled.")
|
|
||||||
|
if p.Login.Password != "" && p.Login.DockerConfig != "" {
|
||||||
|
fmt.Println("Registry credentials or Docker config not provided. Guest mode enabled.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Build.Squash && !p.Daemon.Experimental {
|
if p.Build.Squash && !p.Daemon.Experimental {
|
||||||
|
Loading…
Reference in New Issue
Block a user