diff --git a/docs.md b/docs.md index f1ad96c..0782580 100644 --- a/docs.md +++ b/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 | `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 -| `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 | `label`/`labels` | *none* | sets labels to use for the image in format `=` | `default_labels`/`auto_labels` | `true` | sets docker image labels based on git information diff --git a/plugin/impl.go b/plugin/impl.go index 0213368..fda375c 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -86,7 +86,7 @@ func (l Login) anonymous() bool { func (p *Plugin) InitSettings() error { if p.settings.LoginsRaw != "" { 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,21 +131,17 @@ func (p *Plugin) Validate() error { logrus.Printf("cannot build docker image for %s, invalid semantic version", p.settings.Build.Ref) return err } + + // include user supplied tags + tag = append(tag, p.sanitizedUserTags()...) + p.settings.Build.Tags = *cli.NewStringSlice(tag...) } else { logrus.Printf("skipping automated docker build for %s", p.settings.Build.Ref) return nil } } else { - // ignore empty tags - var tags []string - for _, t := range p.settings.Build.Tags.Value() { - t = strings.TrimSpace(t) - if t != "" { - tags = append(tags, t) - } - } - p.settings.Build.Tags = *cli.NewStringSlice(tags...) + p.settings.Build.Tags = *cli.NewStringSlice(p.sanitizedUserTags()...) } if p.settings.Build.LabelsAuto { @@ -155,6 +151,18 @@ func (p *Plugin) Validate() error { return nil } +func (p *Plugin) sanitizedUserTags() []string { + // ignore empty tags + var tags []string + for _, t := range p.settings.Build.Tags.Value() { + t = strings.TrimSpace(t) + if t != "" { + tags = append(tags, t) + } + } + return tags +} + func (p *Plugin) writeBuildkitConfig() error { // no buildkit config, automatically generate buildkit configuration to use a custom CA certificate for each registry if p.settings.Daemon.BuildkitConfig == "" && p.settings.Daemon.Registry != "" {