mirror of
https://github.com/thegeeklab/wp-docker-buildx.git
synced 2024-11-22 20:20:39 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
65bb87f497
@ -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 (
|
||||||
@ -208,6 +208,11 @@ func main() {
|
|||||||
Usage: "docker email",
|
Usage: "docker email",
|
||||||
EnvVar: "PLUGIN_EMAIL,DOCKER_EMAIL",
|
EnvVar: "PLUGIN_EMAIL,DOCKER_EMAIL",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "docker.config",
|
||||||
|
Usage: "docker json dockerconfig content",
|
||||||
|
EnvVar: "PLUGIN_CONFIG",
|
||||||
|
},
|
||||||
cli.BoolTFlag{
|
cli.BoolTFlag{
|
||||||
Name: "docker.purge",
|
Name: "docker.purge",
|
||||||
Usage: "docker should cleanup images",
|
Usage: "docker should cleanup images",
|
||||||
@ -244,6 +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"),
|
||||||
|
Config: c.String("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 dockerHome = "/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 dockerHome = "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
|
||||||
|
25
docker.go
25
docker.go
@ -2,8 +2,10 @@ package docker
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -32,6 +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
|
||||||
|
Config string // Docker Auth Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build defines Docker build parameters.
|
// Build defines Docker build parameters.
|
||||||
@ -83,6 +86,17 @@ func (p Plugin) Exec() error {
|
|||||||
time.Sleep(time.Second * 1)
|
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
|
// login to the Docker registry
|
||||||
if p.Login.Password != "" {
|
if p.Login.Password != "" {
|
||||||
cmd := commandLogin(p.Login)
|
cmd := commandLogin(p.Login)
|
||||||
@ -90,8 +104,15 @@ 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.")
|
|
||||||
|
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 {
|
if p.Build.Squash && !p.Daemon.Experimental {
|
||||||
|
Loading…
Reference in New Issue
Block a user