Allow using auto_tag
while supplying additional tags via tags
(#35)
This implements #32, allowing to append tags supplied via `tags` along side auto generated tags. Tags supplied via `tags` are *not* suffixed by the `auto_tag_suffix` Co-authored-by: Gapodo <gapodo@datenclown.at> Reviewed-on: https://codeberg.org/woodpecker-plugins/plugin-docker-buildx/pulls/35 Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: gapodo <gapodo@geekvoid.net> Co-committed-by: gapodo <gapodo@geekvoid.net>
This commit is contained in:
parent
466dfce406
commit
f10f7b4c7f
2
docs.md
2
docs.md
@ -97,7 +97,7 @@ It will automatically generate buildkit configuration to use custom CA certifica
|
|||||||
| `daemon_off` | `false` | disables the startup of the docker daemon
|
| `daemon_off` | `false` | disables the startup of the docker daemon
|
||||||
| `buildkit_config` | *none* | sets content of the docker [buildkit TOML config](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md)
|
| `buildkit_config` | *none* | sets content of the docker [buildkit TOML config](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md)
|
||||||
| `context` | `.` | sets the path of the build context to use
|
| `context` | `.` | sets the path of the build context to use
|
||||||
| `default_tags`/`auto_tag` | `false` | generates tag names automatically based on git branch and git tag
|
| `default_tags`/`auto_tag` | `false` | generates tag names automatically based on git branch and git tag, tags supplied via `tags` are additionally added to the auto_tags without suffix
|
||||||
| `default_suffix"`/`auto_tag_suffix`| *none* | generates tag names with the given suffix
|
| `default_suffix"`/`auto_tag_suffix`| *none* | generates tag names with the given suffix
|
||||||
| `label`/`labels` | *none* | sets labels to use for the image in format `<name>=<value>`
|
| `label`/`labels` | *none* | sets labels to use for the image in format `<name>=<value>`
|
||||||
| `default_labels`/`auto_labels` | `true` | sets docker image labels based on git information
|
| `default_labels`/`auto_labels` | `true` | sets docker image labels based on git information
|
||||||
|
@ -86,7 +86,7 @@ func (l Login) anonymous() bool {
|
|||||||
func (p *Plugin) InitSettings() error {
|
func (p *Plugin) InitSettings() error {
|
||||||
if p.settings.LoginsRaw != "" {
|
if p.settings.LoginsRaw != "" {
|
||||||
if err := json.Unmarshal([]byte(p.settings.LoginsRaw), &p.settings.Logins); err != nil {
|
if err := json.Unmarshal([]byte(p.settings.LoginsRaw), &p.settings.Logins); err != nil {
|
||||||
return fmt.Errorf("Could not unmarshal logins: %v", err)
|
return fmt.Errorf("could not unmarshal logins: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,12 +131,27 @@ func (p *Plugin) Validate() error {
|
|||||||
logrus.Printf("cannot build docker image for %s, invalid semantic version", p.settings.Build.Ref)
|
logrus.Printf("cannot build docker image for %s, invalid semantic version", p.settings.Build.Ref)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// include user supplied tags
|
||||||
|
tag = append(tag, p.sanitizedUserTags()...)
|
||||||
|
|
||||||
p.settings.Build.Tags = *cli.NewStringSlice(tag...)
|
p.settings.Build.Tags = *cli.NewStringSlice(tag...)
|
||||||
} else {
|
} else {
|
||||||
logrus.Printf("skipping automated docker build for %s", p.settings.Build.Ref)
|
logrus.Printf("skipping automated docker build for %s", p.settings.Build.Ref)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
p.settings.Build.Tags = *cli.NewStringSlice(p.sanitizedUserTags()...)
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.settings.Build.LabelsAuto {
|
||||||
|
p.settings.Build.Labels = *cli.NewStringSlice(p.Labels()...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Plugin) sanitizedUserTags() []string {
|
||||||
// ignore empty tags
|
// ignore empty tags
|
||||||
var tags []string
|
var tags []string
|
||||||
for _, t := range p.settings.Build.Tags.Value() {
|
for _, t := range p.settings.Build.Tags.Value() {
|
||||||
@ -145,14 +160,7 @@ func (p *Plugin) Validate() error {
|
|||||||
tags = append(tags, t)
|
tags = append(tags, t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.settings.Build.Tags = *cli.NewStringSlice(tags...)
|
return tags
|
||||||
}
|
|
||||||
|
|
||||||
if p.settings.Build.LabelsAuto {
|
|
||||||
p.settings.Build.Labels = *cli.NewStringSlice(p.Labels()...)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Plugin) writeBuildkitConfig() error {
|
func (p *Plugin) writeBuildkitConfig() error {
|
||||||
|
Loading…
Reference in New Issue
Block a user