Merge branch 'master' into master
This commit is contained in:
commit
65bb87f497
@ -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 (
|
||||
@ -208,6 +208,11 @@ func main() {
|
||||
Usage: "docker email",
|
||||
EnvVar: "PLUGIN_EMAIL,DOCKER_EMAIL",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "docker.config",
|
||||
Usage: "docker json dockerconfig content",
|
||||
EnvVar: "PLUGIN_CONFIG",
|
||||
},
|
||||
cli.BoolTFlag{
|
||||
Name: "docker.purge",
|
||||
Usage: "docker should cleanup images",
|
||||
@ -244,6 +249,7 @@ func run(c *cli.Context) error {
|
||||
Username: c.String("docker.username"),
|
||||
Password: c.String("docker.password"),
|
||||
Email: c.String("docker.email"),
|
||||
Config: c.String("docker.config"),
|
||||
},
|
||||
Build: docker.Build{
|
||||
Remote: c.String("remote.url"),
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
|
||||
const dockerExe = "/usr/local/bin/docker"
|
||||
const dockerdExe = "/usr/local/bin/dockerd"
|
||||
const dockerHome = "/root/.docker/"
|
||||
|
||||
func (p Plugin) startDaemon() {
|
||||
cmd := commandDaemon(p.Daemon)
|
||||
|
@ -4,6 +4,7 @@ package docker
|
||||
|
||||
const dockerExe = "C:\\bin\\docker.exe"
|
||||
const dockerdExe = ""
|
||||
const dockerHome = "C:\\ProgramData\\docker\\"
|
||||
|
||||
func (p Plugin) startDaemon() {
|
||||
// this is a no-op on windows
|
||||
|
25
docker.go
25
docker.go
@ -2,8 +2,10 @@ package docker
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@ -32,6 +34,7 @@ type (
|
||||
Username string // Docker registry username
|
||||
Password string // Docker registry password
|
||||
Email string // Docker registry email
|
||||
Config string // Docker Auth Config
|
||||
}
|
||||
|
||||
// Build defines Docker build parameters.
|
||||
@ -83,6 +86,17 @@ func (p Plugin) Exec() error {
|
||||
time.Sleep(time.Second * 1)
|
||||
}
|
||||
|
||||
// Create Auth Config File
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
// login to the Docker registry
|
||||
if p.Login.Password != "" {
|
||||
cmd := commandLogin(p.Login)
|
||||
@ -90,8 +104,15 @@ func (p Plugin) Exec() error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error authenticating: %s", err)
|
||||
}
|
||||
} else {
|
||||
fmt.Println("Registry credentials not provided. Guest mode enabled.")
|
||||
}
|
||||
|
||||
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.")
|
||||
}
|
||||
|
||||
if p.Build.Squash && !p.Daemon.Experimental {
|
||||
|
Loading…
Reference in New Issue
Block a user