mirror of
https://github.com/fluxcd/flux2.git
synced 2025-11-03 11:21:57 +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
|
authorName string
|
||||||
authorEmail string
|
authorEmail string
|
||||||
|
|
||||||
|
commitMessageAppendix string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -113,6 +115,8 @@ func init() {
|
|||||||
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.authorName, "author-name", "Flux", "author name for Git commits")
|
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.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().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().MarkDeprecated("arch", "multi-arch container image is now available for AMD64, ARMv7 and ARM64")
|
||||||
bootstrapCmd.PersistentFlags().MarkHidden("manifests")
|
bootstrapCmd.PersistentFlags().MarkHidden("manifests")
|
||||||
|
|||||||
@ -196,6 +196,7 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
bootstrap.WithRepositoryURL(gitArgs.url),
|
bootstrap.WithRepositoryURL(gitArgs.url),
|
||||||
bootstrap.WithBranch(bootstrapArgs.branch),
|
bootstrap.WithBranch(bootstrapArgs.branch),
|
||||||
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
||||||
|
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
|
||||||
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
||||||
bootstrap.WithPostGenerateSecretFunc(promptPublicKey),
|
bootstrap.WithPostGenerateSecretFunc(promptPublicKey),
|
||||||
bootstrap.WithLogger(logger),
|
bootstrap.WithLogger(logger),
|
||||||
|
|||||||
@ -219,6 +219,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
bootstrap.WithBranch(bootstrapArgs.branch),
|
bootstrap.WithBranch(bootstrapArgs.branch),
|
||||||
bootstrap.WithBootstrapTransportType("https"),
|
bootstrap.WithBootstrapTransportType("https"),
|
||||||
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
||||||
|
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
|
||||||
bootstrap.WithProviderTeamPermissions(mapTeamSlice(githubArgs.teams, ghDefaultPermission)),
|
bootstrap.WithProviderTeamPermissions(mapTeamSlice(githubArgs.teams, ghDefaultPermission)),
|
||||||
bootstrap.WithReadWriteKeyPermissions(githubArgs.readWriteKey),
|
bootstrap.WithReadWriteKeyPermissions(githubArgs.readWriteKey),
|
||||||
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
||||||
|
|||||||
@ -228,6 +228,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
bootstrap.WithBranch(bootstrapArgs.branch),
|
bootstrap.WithBranch(bootstrapArgs.branch),
|
||||||
bootstrap.WithBootstrapTransportType("https"),
|
bootstrap.WithBootstrapTransportType("https"),
|
||||||
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
||||||
|
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
|
||||||
bootstrap.WithProviderTeamPermissions(mapTeamSlice(gitlabArgs.teams, glDefaultPermission)),
|
bootstrap.WithProviderTeamPermissions(mapTeamSlice(gitlabArgs.teams, glDefaultPermission)),
|
||||||
bootstrap.WithReadWriteKeyPermissions(gitlabArgs.readWriteKey),
|
bootstrap.WithReadWriteKeyPermissions(gitlabArgs.readWriteKey),
|
||||||
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
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")
|
--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
|
--ca-file string path to TLS CA file used for validating self-signed certificates
|
||||||
--cluster-domain string internal cluster domain (default "cluster.local")
|
--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 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
|
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||||
-h, --help help for bootstrap
|
-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")
|
--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
|
--ca-file string path to TLS CA file used for validating self-signed certificates
|
||||||
--cluster-domain string internal cluster domain (default "cluster.local")
|
--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 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
|
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||||
--context string kubernetes context to use
|
--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")
|
--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
|
--ca-file string path to TLS CA file used for validating self-signed certificates
|
||||||
--cluster-domain string internal cluster domain (default "cluster.local")
|
--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 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
|
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||||
--context string kubernetes context to use
|
--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")
|
--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
|
--ca-file string path to TLS CA file used for validating self-signed certificates
|
||||||
--cluster-domain string internal cluster domain (default "cluster.local")
|
--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 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
|
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||||
--context string kubernetes context to use
|
--context string kubernetes context to use
|
||||||
|
|||||||
@ -49,6 +49,7 @@ type PlainGitBootstrapper struct {
|
|||||||
branch string
|
branch string
|
||||||
|
|
||||||
author git.Author
|
author git.Author
|
||||||
|
commitMessageAppendix string
|
||||||
|
|
||||||
kubeconfig string
|
kubeconfig string
|
||||||
kubecontext string
|
kubecontext string
|
||||||
@ -126,9 +127,13 @@ func (b *PlainGitBootstrapper) ReconcileComponents(ctx context.Context, manifest
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Git commit generated
|
// 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{
|
commit, err := b.git.Commit(git.Commit{
|
||||||
Author: b.author,
|
Author: b.author,
|
||||||
Message: fmt.Sprintf("Add Flux %s component manifests", options.Version),
|
Message: commitMsg,
|
||||||
})
|
})
|
||||||
if err != nil && err != git.ErrNoStagedFiles {
|
if err != nil && err != git.ErrNoStagedFiles {
|
||||||
return fmt.Errorf("failed to commit sync manifests: %w", err)
|
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")
|
b.logger.Successf("generated sync manifests")
|
||||||
|
|
||||||
// Git commit generated
|
// 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{
|
commit, err := b.git.Commit(git.Commit{
|
||||||
Author: b.author,
|
Author: b.author,
|
||||||
Message: fmt.Sprintf("Add Flux sync manifests"),
|
Message: commitMsg,
|
||||||
})
|
})
|
||||||
if err != nil && err != git.ErrNoStagedFiles {
|
if err != nil && err != git.ErrNoStagedFiles {
|
||||||
return fmt.Errorf("failed to commit sync manifests: %w", err)
|
return fmt.Errorf("failed to commit sync manifests: %w", err)
|
||||||
|
|||||||
@ -62,6 +62,20 @@ func (o authorOption) applyGitProvider(b *GitProviderBootstrapper) {
|
|||||||
o.applyGit(b.PlainGitBootstrapper)
|
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 {
|
func WithKubeconfig(kubeconfig, kubecontext string) Option {
|
||||||
return kubeconfigOption{
|
return kubeconfigOption{
|
||||||
kubeconfig: kubeconfig,
|
kubeconfig: kubeconfig,
|
||||||
|
|||||||
Reference in New Issue
Block a user