mirror of
https://github.com/drone-plugins/drone-docker.git
synced 2026-06-04 18:24:24 +08:00
feat: [CI-20527]: add push-only mode to skip build and push pre-existing images (#500)
* Add push-only support * Include support for PLUGIN_NO_PUSH as well
This commit is contained in:
@@ -17,8 +17,14 @@ import (
|
||||
"github.com/inhies/go-bytesize"
|
||||
)
|
||||
|
||||
// writeCard maintains backward compatibility by using TempTag
|
||||
func (p Plugin) writeCard() error {
|
||||
cmd := exec.Command(dockerExe, "inspect", p.Build.TempTag)
|
||||
return p.writeCardForImage(p.Build.TempTag)
|
||||
}
|
||||
|
||||
// writeCardForImage generates card for any image reference
|
||||
func (p Plugin) writeCardForImage(imageRef string) error {
|
||||
cmd := exec.Command(dockerExe, "inspect", imageRef)
|
||||
data, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -38,7 +44,11 @@ func (p Plugin) writeCard() error {
|
||||
for _, tag := range inspect.RepoTags {
|
||||
sliceTagStruct = append(sliceTagStruct, TagStruct{Tag: tag})
|
||||
}
|
||||
inspect.ParsedRepoTags = sliceTagStruct[1:] // remove the first tag which is always "hash:latest"
|
||||
if len(sliceTagStruct) > 1 {
|
||||
inspect.ParsedRepoTags = sliceTagStruct[1:] // remove the first tag which is always "hash:latest"
|
||||
} else {
|
||||
inspect.ParsedRepoTags = sliceTagStruct
|
||||
}
|
||||
// create the url from repo and registry
|
||||
inspect.URL = mapRegistryToURL(p.Daemon.Registry, p.Build.Repo)
|
||||
cardData, _ := json.Marshal(inspect)
|
||||
|
||||
Reference in New Issue
Block a user