mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-21 07:01:47 +00:00
Merge pull request #714 from fluxcd/tag-filter
This commit is contained in:
commit
6a7f1e7d48
4 changed files with 20 additions and 7 deletions
|
|
@ -38,8 +38,9 @@ the status of the object.`,
|
||||||
RunE: createImagePolicyRun}
|
RunE: createImagePolicyRun}
|
||||||
|
|
||||||
type imagePolicyFlags struct {
|
type imagePolicyFlags struct {
|
||||||
imageRef string
|
imageRef string
|
||||||
semver string
|
semver string
|
||||||
|
filterRegex string
|
||||||
}
|
}
|
||||||
|
|
||||||
var imagePolicyArgs = imagePolicyFlags{}
|
var imagePolicyArgs = imagePolicyFlags{}
|
||||||
|
|
@ -48,6 +49,7 @@ func init() {
|
||||||
flags := createImagePolicyCmd.Flags()
|
flags := createImagePolicyCmd.Flags()
|
||||||
flags.StringVar(&imagePolicyArgs.imageRef, "image-ref", "", "the name of an image repository object")
|
flags.StringVar(&imagePolicyArgs.imageRef, "image-ref", "", "the name of an image repository object")
|
||||||
flags.StringVar(&imagePolicyArgs.semver, "semver", "", "a semver range to apply to tags; e.g., '1.x'")
|
flags.StringVar(&imagePolicyArgs.semver, "semver", "", "a semver range to apply to tags; e.g., '1.x'")
|
||||||
|
flags.StringVar(&imagePolicyArgs.filterRegex, "filter-regex", "", " regular expression pattern used to filter the image tags")
|
||||||
|
|
||||||
createImageCmd.AddCommand(createImagePolicyCmd)
|
createImageCmd.AddCommand(createImagePolicyCmd)
|
||||||
}
|
}
|
||||||
|
|
@ -95,6 +97,12 @@ func createImagePolicyRun(cmd *cobra.Command, args []string) error {
|
||||||
return fmt.Errorf("a policy must be provided with --semver")
|
return fmt.Errorf("a policy must be provided with --semver")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if imagePolicyArgs.filterRegex != "" {
|
||||||
|
policy.Spec.FilterTags = &imagev1.TagFilter{
|
||||||
|
Pattern: imagePolicyArgs.filterRegex,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if export {
|
if export {
|
||||||
return printExport(exportImagePolicy(&policy))
|
return printExport(exportImagePolicy(&policy))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ var imageUpdateArgs = imageUpdateFlags{}
|
||||||
func init() {
|
func init() {
|
||||||
flags := createImageUpdateCmd.Flags()
|
flags := createImageUpdateCmd.Flags()
|
||||||
flags.StringVar(&imageUpdateArgs.gitRepoRef, "git-repo-ref", "", "the name of a GitRepository resource with details of the upstream git repository")
|
flags.StringVar(&imageUpdateArgs.gitRepoRef, "git-repo-ref", "", "the name of a GitRepository resource with details of the upstream git repository")
|
||||||
flags.StringVar(&imageUpdateArgs.branch, "branch", "", "the branch to push commits to")
|
flags.StringVar(&imageUpdateArgs.branch, "branch", "", "the branch to checkout and push commits to")
|
||||||
flags.StringVar(&imageUpdateArgs.commitTemplate, "commit-template", "", "a template for commit messages")
|
flags.StringVar(&imageUpdateArgs.commitTemplate, "commit-template", "", "a template for commit messages")
|
||||||
flags.StringVar(&imageUpdateArgs.authorName, "author-name", "", "the name to use for commit author")
|
flags.StringVar(&imageUpdateArgs.authorName, "author-name", "", "the name to use for commit author")
|
||||||
flags.StringVar(&imageUpdateArgs.authorEmail, "author-email", "", "the email to use for commit author")
|
flags.StringVar(&imageUpdateArgs.authorEmail, "author-email", "", "the email to use for commit author")
|
||||||
|
|
@ -68,6 +68,10 @@ func createImageUpdateRun(cmd *cobra.Command, args []string) error {
|
||||||
return fmt.Errorf("a reference to a GitRepository is required (--git-repo-ref)")
|
return fmt.Errorf("a reference to a GitRepository is required (--git-repo-ref)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if imageUpdateArgs.branch == "" {
|
||||||
|
return fmt.Errorf("the Git repoistory branch is required (--branch)")
|
||||||
|
}
|
||||||
|
|
||||||
labels, err := parseLabels()
|
labels, err := parseLabels()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,10 @@ flux create image policy <name> [flags]
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
-h, --help help for policy
|
--filter-regex string regular expression pattern used to filter the image tags
|
||||||
--image-ref string the name of an image repository object
|
-h, --help help for policy
|
||||||
--semver string a semver range to apply to tags; e.g., '1.x'
|
--image-ref string the name of an image repository object
|
||||||
|
--semver string a semver range to apply to tags; e.g., '1.x'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ flux create image update <name> [flags]
|
||||||
```
|
```
|
||||||
--author-email string the email to use for commit author
|
--author-email string the email to use for commit author
|
||||||
--author-name string the name to use for commit author
|
--author-name string the name to use for commit author
|
||||||
--branch string the branch to push commits to
|
--branch string the branch to checkout and push commits to
|
||||||
--commit-template string a template for commit messages
|
--commit-template string a template for commit messages
|
||||||
--git-repo-ref string the name of a GitRepository resource with details of the upstream git repository
|
--git-repo-ref string the name of a GitRepository resource with details of the upstream git repository
|
||||||
-h, --help help for update
|
-h, --help help for update
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue