1
0
mirror of synced 2026-03-18 00:46:56 +00:00

Add bootstrap option to set a prefix for the commit messages

Signed-off-by: Dries Verachtert <dries.verachtert@dries.eu>
This commit is contained in:
Dries Verachtert
2021-04-26 14:03:12 +02:00
parent bd34870334
commit 9cebd601fb
9 changed files with 29 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ type PlainGitBootstrapper struct {
branch string
author git.Author
commitMessagePrefix string
commitMessageAppendix string
kubeconfig string
@@ -133,6 +134,9 @@ func (b *PlainGitBootstrapper) ReconcileComponents(ctx context.Context, manifest
// Git commit generated
commitMsg := fmt.Sprintf("Add Flux %s component manifests", options.Version)
if b.commitMessagePrefix != "" {
commitMsg = b.commitMessagePrefix + commitMsg
}
if b.commitMessageAppendix != "" {
commitMsg = commitMsg + "\n\n" + b.commitMessageAppendix
}
@@ -297,6 +301,9 @@ func (b *PlainGitBootstrapper) ReconcileSyncConfig(ctx context.Context, options
// Git commit generated
commitMsg := fmt.Sprintf("Add Flux sync manifests")
if b.commitMessagePrefix != "" {
commitMsg = b.commitMessagePrefix + commitMsg
}
if b.commitMessageAppendix != "" {
commitMsg = commitMsg + "\n\n" + b.commitMessageAppendix
}

View File

@@ -62,6 +62,20 @@ func (o authorOption) applyGitProvider(b *GitProviderBootstrapper) {
o.applyGit(b.PlainGitBootstrapper)
}
func WithCommitMessagePrefix(prefix string) Option {
return commitMessagePrefixOption(prefix)
}
type commitMessagePrefixOption string
func (o commitMessagePrefixOption) applyGit(b *PlainGitBootstrapper) {
b.commitMessagePrefix = string(o)
}
func (o commitMessagePrefixOption) applyGitProvider(b *GitProviderBootstrapper) {
o.applyGit(b.PlainGitBootstrapper)
}
func WithCommitMessageAppendix(appendix string) Option {
return commitMessageAppendixOption(appendix)
}