Skip to content

Commit

Permalink
Merge pull request #1564 from rawlingsj/filter_rm
Browse files Browse the repository at this point in the history
update config: add version filter prefix and contains to release monitor config block so implementations can perform the same behaviour as git and github configs
  • Loading branch information
rawlingsj authored Oct 15, 2024
2 parents 299f317 + aab5263 commit 0900229
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 11 deletions.
8 changes: 7 additions & 1 deletion docs/UPDATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ update:
identifier: 38 # Mandatory, ID number for release monitor
strip-prefix: v # Optional, if the version obtained from the update service contains a prefix which should be ignored
strip-suffix: ignore_me # Optional, if the version obtained from the update service contains a suffix which should be ignored
version-filter-prefix: v17.2 # Optional, filter to apply when searching versions with a prefix
version-filter-contains: foo # Optional, filter to apply when searching versions with any match
```
## GitHub
Expand All @@ -53,7 +55,9 @@ update:
strip-prefix: v # Optional, if the version obtained from the update service contains a prefix which should be ignored
strip-suffix: ignore_me # Optional, if the version obtained from the update service contains a suffix which should be ignored
use-tag: true # Optional, override the default of using a GitHub release to identify related tag to fetch. Not all projects use GitHub releases but just use tags
tag-filter: foo # Optional, filter to apply when searching tags on a GitHub repository, some repos maintain a mixture of tags for different major versions for example
tag-filter: foo # Deprecated: Use tag-filter-prefix instead
tag-filter-prefix: v17.2 # Optional, filter to apply when searching tags with a prefix on a GitHub repository, some repos maintain a mixture of tags for different major versions for example
tag-filter-contains: foo # Optional, filter to apply when searching tags with any match on a GitHub repository, some repos maintain a mixture of tags for different major versions for example
```
## Git
Expand All @@ -79,6 +83,8 @@ update:
git:
tag-filter-prefix: v17.2
strip-prefix: v
strip-suffix: ignore_me
tag-filter-contains: foo
schedule:
period: daily
reason: upstream project does not support tags or releases
Expand Down
1 change: 1 addition & 0 deletions pkg/build/pipelines/maven/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Run pombump tool to update versions and properties in a Maven POM file
| pom | false | Path to pom.xml | pom.xml |
| properties | false | Properties to update / add the POM file via command line flag | |
| properties-file | false | Properties file to be used for updating the POM file | ./pombump-properties.yaml |
| show-dependency-tree | false | Display a dependency tree for the existing pom.xml file | false |


<!-- end:pipeline-reference-gen -->
44 changes: 34 additions & 10 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,19 @@ type ReleaseMonitor struct {
StripPrefix string `json:"strip-prefix,omitempty" yaml:"strip-prefix,omitempty"`
// If the version in release monitor contains a suffix which should be ignored
StripSuffix string `json:"strip-suffix,omitempty" yaml:"strip-suffix,omitempty"`
// Filter to apply when searching version on a Release Monitoring
VersionFilterContains string `json:"version-filter-contains,omitempty" yaml:"version-filter-contains,omitempty"`
// Filter to apply when searching version Release Monitoring
VersionFilterPrefix string `json:"version-filter-prefix,omitempty" yaml:"version-filter-prefix,omitempty"`
}

// VersionHandler is an interface that defines methods for retrieving version filtering and stripping parameters.
// It is used to provide a common interface for handling version-related operations for different types of version monitors.
type VersionHandler interface {
GetStripPrefix() string
GetStripSuffix() string
GetTagFilterPrefix() string
GetTagFilterContains() string
GetFilterPrefix() string
GetFilterContains() string
}

// GitHubMonitor indicates using the GitHub API
Expand Down Expand Up @@ -571,13 +575,13 @@ func (gm *GitMonitor) GetStripSuffix() string {
return gm.StripSuffix
}

// GetTagFilterPrefix returns the prefix filter to apply when searching tags in GitMonitor.
func (gm *GitMonitor) GetTagFilterPrefix() string {
// GetFilterPrefix returns the prefix filter to apply when searching tags in GitMonitor.
func (gm *GitMonitor) GetFilterPrefix() string {
return gm.TagFilterPrefix
}

// GetTagFilterContains returns the substring filter to apply when searching tags in GitMonitor.
func (gm *GitMonitor) GetTagFilterContains() string {
// GetFilterContains returns the substring filter to apply when searching tags in GitMonitor.
func (gm *GitMonitor) GetFilterContains() string {
return gm.TagFilterContains
}

Expand All @@ -591,16 +595,36 @@ func (ghm *GitHubMonitor) GetStripSuffix() string {
return ghm.StripSuffix
}

// GetTagFilterPrefix returns the prefix filter to apply when searching tags in GitHubMonitor.
func (ghm *GitHubMonitor) GetTagFilterPrefix() string {
// GetFilterPrefix returns the prefix filter to apply when searching tags in GitHubMonitor.
func (ghm *GitHubMonitor) GetFilterPrefix() string {
return ghm.TagFilterPrefix
}

// GetTagFilterContains returns the substring filter to apply when searching tags in GitHubMonitor.
func (ghm *GitHubMonitor) GetTagFilterContains() string {
// GetFilterContains returns the substring filter to apply when searching tags in GitHubMonitor.
func (ghm *GitHubMonitor) GetFilterContains() string {
return ghm.TagFilterContains
}

// GetStripPrefix returns the prefix that should be stripped from the ReleaseMonitor version.
func (rm *ReleaseMonitor) GetStripPrefix() string {
return rm.StripPrefix
}

// GetStripSuffix returns the suffix that should be stripped from the ReleaseMonitor version.
func (rm *ReleaseMonitor) GetStripSuffix() string {
return rm.StripSuffix
}

// GetFilterPrefix returns the prefix filter to apply when searching versions in ReleaseMonitor.
func (rm *ReleaseMonitor) GetFilterPrefix() string {
return rm.VersionFilterPrefix
}

// GetFilterContains returns the substring filter to apply when searching versions in ReleaseMonitor.
func (rm *ReleaseMonitor) GetFilterContains() string {
return rm.VersionFilterContains
}

// VersionTransform allows mapping the package version to an APK version
type VersionTransform struct {
// Required: The regular expression to match against the `package.version` variable
Expand Down
8 changes: 8 additions & 0 deletions pkg/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,14 @@
"strip-suffix": {
"type": "string",
"description": "If the version in release monitor contains a suffix which should be ignored"
},
"version-filter-contains": {
"type": "string",
"description": "Filter to apply when searching version on a Release Monitoring"
},
"version-filter-prefix": {
"type": "string",
"description": "Filter to apply when searching version Release Monitoring"
}
},
"additionalProperties": false,
Expand Down

0 comments on commit 0900229

Please sign in to comment.