Skip to content

Commit

Permalink
Merge pull request #855 from paketo-buildpacks/tomcat-minor
Browse files Browse the repository at this point in the history
Allow a version filter for Tomcat
  • Loading branch information
dmikusa authored Oct 3, 2022
2 parents 3aefa89 + ffc30fe commit e56dad7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,13 @@ with:
```

### Tomcat Dependency
The Tomcat Dependency watches the [Apache Tomcat Download Page](https://downloads.apache.org/tomcat/tomcat-9/) for new versions.
The Tomcat Dependency watches the [Apache Tomcat Download Page](https://downloads.apache.org/tomcat/tomcat-9/) for new versions. An optional `version_regex` can be specified to filter on a specific minor versions. If set, the regex must include three capture groups. For example, `^v(10)\.(0)\.([\d]+)/$` to match `10.0.*`.

```yaml
uses: docker://ghcr.io/paketo-buildpacks/actions/tomcat-dependency:main
with:
uri: https://downloads.apache.org/tomcat/tomcat-9
version_regex: ^v([\d]+)\.([\d]+)\.([\d]+)/$
```

### Tomee Dependency
Expand Down
8 changes: 7 additions & 1 deletion actions/tomcat-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ func main() {
panic(fmt.Errorf("uri must be specified"))
}

versionRegex, ok := inputs["version_regex"]
if !ok {
fmt.Println(`No version_regex set, using default: ^v([\d]+)\.([\d]+)\.([\d]+)/$`)
versionRegex = `^v([\d]+)\.([\d]+)\.([\d]+)/$`
}

c := colly.NewCollector()

cp := regexp.MustCompile(`^v([\d]+)\.([\d]+)\.([\d]+)/$`)
cp := regexp.MustCompile(versionRegex)
versions := make(actions.Versions)
c.OnHTML("a[href]", func(element *colly.HTMLElement) {
if p := cp.FindStringSubmatch(element.Attr("href")); p != nil {
Expand Down

0 comments on commit e56dad7

Please sign in to comment.