mirror of
https://github.com/fluxcd/flux2.git
synced 2025-11-03 03:12:00 +08:00
Provide option to add appendix to commit messages
Using the `--commit-message-appendix` flag a string can be added to the commit messages made by the bootstrapper process to for example skip CI actions from executing using e.g. `[skip ci]`. Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit is contained in:
@ -65,6 +65,8 @@ type bootstrapFlags struct {
|
||||
|
||||
authorName string
|
||||
authorEmail string
|
||||
|
||||
commitMessageAppendix string
|
||||
}
|
||||
|
||||
const (
|
||||
@ -113,6 +115,8 @@ func init() {
|
||||
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.authorName, "author-name", "Flux", "author name for Git commits")
|
||||
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.authorEmail, "author-email", "", "author email for Git commits")
|
||||
|
||||
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.commitMessageAppendix, "commit-message-appendix", "", "string to add to the commit messages, e.g. '[ci skip]'")
|
||||
|
||||
bootstrapCmd.PersistentFlags().Var(&bootstrapArgs.arch, "arch", bootstrapArgs.arch.Description())
|
||||
bootstrapCmd.PersistentFlags().MarkDeprecated("arch", "multi-arch container image is now available for AMD64, ARMv7 and ARM64")
|
||||
bootstrapCmd.PersistentFlags().MarkHidden("manifests")
|
||||
|
||||
@ -196,6 +196,7 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
|
||||
bootstrap.WithRepositoryURL(gitArgs.url),
|
||||
bootstrap.WithBranch(bootstrapArgs.branch),
|
||||
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
||||
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
|
||||
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
||||
bootstrap.WithPostGenerateSecretFunc(promptPublicKey),
|
||||
bootstrap.WithLogger(logger),
|
||||
|
||||
@ -219,6 +219,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
|
||||
bootstrap.WithBranch(bootstrapArgs.branch),
|
||||
bootstrap.WithBootstrapTransportType("https"),
|
||||
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
||||
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
|
||||
bootstrap.WithProviderTeamPermissions(mapTeamSlice(githubArgs.teams, ghDefaultPermission)),
|
||||
bootstrap.WithReadWriteKeyPermissions(githubArgs.readWriteKey),
|
||||
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
||||
|
||||
@ -228,6 +228,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
|
||||
bootstrap.WithBranch(bootstrapArgs.branch),
|
||||
bootstrap.WithBootstrapTransportType("https"),
|
||||
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
||||
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
|
||||
bootstrap.WithProviderTeamPermissions(mapTeamSlice(gitlabArgs.teams, glDefaultPermission)),
|
||||
bootstrap.WithReadWriteKeyPermissions(gitlabArgs.readWriteKey),
|
||||
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
||||
|
||||
@ -17,6 +17,7 @@ The bootstrap sub-commands bootstrap the toolkit components on the targeted Git
|
||||
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
||||
--ca-file string path to TLS CA file used for validating self-signed certificates
|
||||
--cluster-domain string internal cluster domain (default "cluster.local")
|
||||
--commit-message-appendix string string to add to the commit messages, e.g. '[ci skip]'
|
||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||
-h, --help help for bootstrap
|
||||
|
||||
@ -49,6 +49,7 @@ flux bootstrap git [flags]
|
||||
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
||||
--ca-file string path to TLS CA file used for validating self-signed certificates
|
||||
--cluster-domain string internal cluster domain (default "cluster.local")
|
||||
--commit-message-appendix string string to add to the commit messages, e.g. '[ci skip]'
|
||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||
--context string kubernetes context to use
|
||||
|
||||
@ -68,6 +68,7 @@ flux bootstrap github [flags]
|
||||
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
||||
--ca-file string path to TLS CA file used for validating self-signed certificates
|
||||
--cluster-domain string internal cluster domain (default "cluster.local")
|
||||
--commit-message-appendix string string to add to the commit messages, e.g. '[ci skip]'
|
||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||
--context string kubernetes context to use
|
||||
|
||||
@ -65,6 +65,7 @@ flux bootstrap gitlab [flags]
|
||||
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
||||
--ca-file string path to TLS CA file used for validating self-signed certificates
|
||||
--cluster-domain string internal cluster domain (default "cluster.local")
|
||||
--commit-message-appendix string string to add to the commit messages, e.g. '[ci skip]'
|
||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||
--context string kubernetes context to use
|
||||
|
||||
@ -49,6 +49,7 @@ type PlainGitBootstrapper struct {
|
||||
branch string
|
||||
|
||||
author git.Author
|
||||
commitMessageAppendix string
|
||||
|
||||
kubeconfig string
|
||||
kubecontext string
|
||||
@ -126,9 +127,13 @@ func (b *PlainGitBootstrapper) ReconcileComponents(ctx context.Context, manifest
|
||||
}
|
||||
|
||||
// Git commit generated
|
||||
commitMsg := fmt.Sprintf("Add Flux %s component manifests", options.Version)
|
||||
if b.commitMessageAppendix != "" {
|
||||
commitMsg = commitMsg + "\n\n" + b.commitMessageAppendix
|
||||
}
|
||||
commit, err := b.git.Commit(git.Commit{
|
||||
Author: b.author,
|
||||
Message: fmt.Sprintf("Add Flux %s component manifests", options.Version),
|
||||
Message: commitMsg,
|
||||
})
|
||||
if err != nil && err != git.ErrNoStagedFiles {
|
||||
return fmt.Errorf("failed to commit sync manifests: %w", err)
|
||||
@ -245,9 +250,13 @@ func (b *PlainGitBootstrapper) ReconcileSyncConfig(ctx context.Context, options
|
||||
b.logger.Successf("generated sync manifests")
|
||||
|
||||
// Git commit generated
|
||||
commitMsg := fmt.Sprintf("Add Flux sync manifests")
|
||||
if b.commitMessageAppendix != "" {
|
||||
commitMsg = commitMsg + "\n\n" + b.commitMessageAppendix
|
||||
}
|
||||
commit, err := b.git.Commit(git.Commit{
|
||||
Author: b.author,
|
||||
Message: fmt.Sprintf("Add Flux sync manifests"),
|
||||
Message: commitMsg,
|
||||
})
|
||||
if err != nil && err != git.ErrNoStagedFiles {
|
||||
return fmt.Errorf("failed to commit sync manifests: %w", err)
|
||||
|
||||
@ -62,6 +62,20 @@ func (o authorOption) applyGitProvider(b *GitProviderBootstrapper) {
|
||||
o.applyGit(b.PlainGitBootstrapper)
|
||||
}
|
||||
|
||||
func WithCommitMessageAppendix(appendix string) Option {
|
||||
return commitMessageAppendixOption(appendix)
|
||||
}
|
||||
|
||||
type commitMessageAppendixOption string
|
||||
|
||||
func (o commitMessageAppendixOption) applyGit(b *PlainGitBootstrapper) {
|
||||
b.commitMessageAppendix = string(o)
|
||||
}
|
||||
|
||||
func (o commitMessageAppendixOption) applyGitProvider(b *GitProviderBootstrapper) {
|
||||
o.applyGit(b.PlainGitBootstrapper)
|
||||
}
|
||||
|
||||
func WithKubeconfig(kubeconfig, kubecontext string) Option {
|
||||
return kubeconfigOption{
|
||||
kubeconfig: kubeconfig,
|
||||
|
||||
Reference in New Issue
Block a user