mirror of
https://github.com/thegeeklab/wp-docker-buildx.git
synced 2024-11-22 10:10:39 +00:00
update config.json messaging
This commit is contained in:
parent
cc112b3ed0
commit
528dc0a7b3
@ -7,7 +7,7 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/drone-plugins/drone-docker"
|
||||
docker "github.com/drone-plugins/drone-docker"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -249,7 +249,7 @@ func run(c *cli.Context) error {
|
||||
Username: c.String("docker.username"),
|
||||
Password: c.String("docker.password"),
|
||||
Email: c.String("docker.email"),
|
||||
DockerConfig: c.String("docker.config"),
|
||||
Config: c.String("docker.config"),
|
||||
},
|
||||
Build: docker.Build{
|
||||
Remote: c.String("remote.url"),
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
const dockerExe = "/usr/local/bin/docker"
|
||||
const dockerdExe = "/usr/local/bin/dockerd"
|
||||
const dockerrootconfdir = "/root/.docker/"
|
||||
const dockerHome = "/root/.docker/"
|
||||
|
||||
func (p Plugin) startDaemon() {
|
||||
cmd := commandDaemon(p.Daemon)
|
||||
|
31
docker.go
31
docker.go
@ -2,11 +2,12 @@ package docker
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -33,7 +34,7 @@ type (
|
||||
Username string // Docker registry username
|
||||
Password string // Docker registry password
|
||||
Email string // Docker registry email
|
||||
DockerConfig string // Docker Auth Config
|
||||
Config string // Docker Auth Config
|
||||
}
|
||||
|
||||
// Build defines Docker build parameters.
|
||||
@ -86,18 +87,13 @@ func (p Plugin) Exec() error {
|
||||
}
|
||||
|
||||
// Create Auth Config File
|
||||
if p.Login.DockerConfig != "" {
|
||||
fmt.Println("DockerConfig provided.")
|
||||
err_mkdir := os.MkdirAll(dockerrootconfdir, 0600)
|
||||
if err_mkdir != nil {
|
||||
fmt.Println("Error creating root's docker auth config directory: ")
|
||||
fmt.Println(err_mkdir)
|
||||
}
|
||||
conffile := fmt.Sprintf("%s%s", dockerrootconfdir, "config.json")
|
||||
err_mkconf := ioutil.WriteFile(conffile, []byte(p.Login.DockerConfig), 0600)
|
||||
if err_mkconf != nil {
|
||||
fmt.Println("Error creating root's docker auth configuration: ")
|
||||
fmt.Println(err_mkconf)
|
||||
if p.Login.Config != "" {
|
||||
os.MkdirAll(dockerHome, 0600)
|
||||
|
||||
path := filepath.Join(dockerHome, "config.json")
|
||||
err := ioutil.WriteFile(path, []byte(p.Login.Config), 0600)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error writeing config.json: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +106,12 @@ func (p Plugin) Exec() error {
|
||||
}
|
||||
}
|
||||
|
||||
if p.Login.Password != "" && p.Login.DockerConfig != "" {
|
||||
switch {
|
||||
case p.Login.Password != "":
|
||||
fmt.Println("Detected registry credentials")
|
||||
case p.Login.Config != "":
|
||||
fmt.Println("Detected registry credentials file")
|
||||
default:
|
||||
fmt.Println("Registry credentials or Docker config not provided. Guest mode enabled.")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user