0
0
mirror of https://github.com/thegeeklab/wp-docker-buildx.git synced 2024-11-26 05:30:39 +00:00

update config.json messaging

This commit is contained in:
Brad Rydzewski 2020-03-24 13:49:10 -07:00
parent cc112b3ed0
commit 528dc0a7b3
3 changed files with 30 additions and 29 deletions

View File

@ -7,7 +7,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/drone-plugins/drone-docker" docker "github.com/drone-plugins/drone-docker"
) )
var ( var (
@ -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"),
DockerConfig: c.String("docker.config"), Config: c.String("docker.config"),
}, },
Build: docker.Build{ Build: docker.Build{
Remote: c.String("remote.url"), Remote: c.String("remote.url"),

View File

@ -9,7 +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/" const dockerHome = "/root/.docker/"
func (p Plugin) startDaemon() { func (p Plugin) startDaemon() {
cmd := commandDaemon(p.Daemon) cmd := commandDaemon(p.Daemon)

View File

@ -2,11 +2,12 @@ package docker
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"strings" "strings"
"time" "time"
"io/ioutil"
) )
type ( type (
@ -33,7 +34,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
DockerConfig string // Docker Auth Config Config string // Docker Auth Config
} }
// Build defines Docker build parameters. // Build defines Docker build parameters.
@ -86,18 +87,13 @@ func (p Plugin) Exec() error {
} }
// Create Auth Config File // Create Auth Config File
if p.Login.DockerConfig != "" { if p.Login.Config != "" {
fmt.Println("DockerConfig provided.") os.MkdirAll(dockerHome, 0600)
err_mkdir := os.MkdirAll(dockerrootconfdir, 0600)
if err_mkdir != nil { path := filepath.Join(dockerHome, "config.json")
fmt.Println("Error creating root's docker auth config directory: ") err := ioutil.WriteFile(path, []byte(p.Login.Config), 0600)
fmt.Println(err_mkdir) if err != nil {
} return fmt.Errorf("Error writeing config.json: %s", err)
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)
} }
} }
@ -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.") fmt.Println("Registry credentials or Docker config not provided. Guest mode enabled.")
} }