Add snapshot mode support (#13)

This commit is contained in:
Shubham Agrawal 2021-03-02 21:15:44 +05:30 committed by GitHub
parent 9cca954ec6
commit 658478d5ae
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 31 deletions

@ -15,6 +15,7 @@ steps:
repo: plugins/kaniko
auto_tag: true
auto_tag_suffix: linux-amd64
daemon_off: false
dockerfile: docker/docker/Dockerfile.linux.amd64
username:
from_secret: docker_username
@ -22,8 +23,8 @@ steps:
from_secret: docker_password
when:
event:
- push
- tag
exclude:
- pull_request
- name: gcr
image: plugins/docker
@ -31,6 +32,7 @@ steps:
repo: plugins/kaniko-gcr
auto_tag: true
auto_tag_suffix: linux-amd64
daemon_off: false
dockerfile: docker/gcr/Dockerfile.linux.amd64
username:
from_secret: docker_username
@ -38,8 +40,8 @@ steps:
from_secret: docker_password
when:
event:
- push
- tag
exclude:
- pull_request
- name: ecr
image: plugins/docker
@ -47,6 +49,7 @@ steps:
repo: plugins/kaniko-ecr
auto_tag: true
auto_tag_suffix: linux-amd64
daemon_off: false
dockerfile: docker/ecr/Dockerfile.linux.amd64
username:
from_secret: docker_username
@ -54,5 +57,5 @@ steps:
from_secret: docker_password
when:
event:
- push
- tag
exclude:
- pull_request

@ -49,5 +49,5 @@ docker run --rm \
-e PLUGIN_PASSWORD=bar \
-v $(pwd):/drone \
-w /drone \
plugins/kaniko-docker
plugins/kaniko:linux-amd64
```

@ -99,6 +99,11 @@ func main() {
Usage: "Skip registry tls verify",
EnvVar: "PLUGIN_SKIP_TLS_VERIFY",
},
cli.StringFlag{
Name: "snapshot-mode",
Usage: "Specify one of full, redo or time as snapshot mode",
EnvVar: "PLUGIN_SNAPSHOT_MODE",
},
}
if err := app.Run(os.Args); err != nil {
@ -122,6 +127,7 @@ func run(c *cli.Context) error {
Repo: c.String("repo"),
Labels: c.StringSlice("custom-labels"),
SkipTlsVerify: c.Bool("skip-tls-verify"),
SnapshotMode: c.String("snapshot-mode"),
},
}
return plugin.Exec()

@ -89,6 +89,11 @@ func main() {
Usage: "ECR secret key",
EnvVar: "PLUGIN_SECRET_KEY",
},
cli.StringFlag{
Name: "snapshot-mode",
Usage: "Specify one of full, redo or time as snapshot mode",
EnvVar: "PLUGIN_SNAPSHOT_MODE",
},
}
if err := app.Run(os.Args); err != nil {
@ -111,6 +116,7 @@ func run(c *cli.Context) error {
Target: c.String("target"),
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
Labels: c.StringSlice("custom-labels"),
SnapshotMode: c.String("snapshot-mode"),
},
}
return plugin.Exec()

@ -85,6 +85,11 @@ func main() {
Usage: "docker username",
EnvVar: "PLUGIN_JSON_KEY",
},
cli.StringFlag{
Name: "snapshot-mode",
Usage: "Specify one of full, redo or time as snapshot mode",
EnvVar: "PLUGIN_SNAPSHOT_MODE",
},
}
if err := app.Run(os.Args); err != nil {
@ -111,6 +116,7 @@ func run(c *cli.Context) error {
Target: c.String("target"),
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
Labels: c.StringSlice("custom-labels"),
SnapshotMode: c.String("snapshot-mode"),
},
}
return plugin.Exec()

@ -18,6 +18,7 @@ type (
Repo string // Docker build repository
Labels []string // Label map
SkipTlsVerify bool // Docker skip tls certificate verify for registry
SnapshotMode string // Kaniko snapshot mode
}
// Plugin defines the Docker plugin parameters.
@ -62,6 +63,10 @@ func (p Plugin) Exec() error {
cmdArgs = append(cmdArgs, fmt.Sprintf("--skip-tls-verify=true"))
}
if p.Build.SnapshotMode != "" {
cmdArgs = append(cmdArgs, fmt.Sprintf("--snapshotMode=%s", p.Build.SnapshotMode))
}
cmd := exec.Command("/kaniko/executor", cmdArgs...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr