Skip to content

Commit

Permalink
Merge pull request #82 from jfrog/PTRENG-4573-watch-config
Browse files Browse the repository at this point in the history
PTRENG-4573, add path_ant_patterns to the repo watch
  • Loading branch information
danielmkn authored Oct 19, 2022
2 parents 39702d2 + 3899c0d commit 0967360
Show file tree
Hide file tree
Showing 6 changed files with 378 additions and 12 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.8.0 (October 18, 2022). Tested on Artifactory 7.46.6 and Xray 3.59.4

IMPROVEMENTS:

* resource/xray_watch: add functionality to apply `path_ant_filter` for `repository` and `all-repos` `watch_resource.type`.
PR [#82](https://github.com/jfrog/terraform-provider-xray/pull/82)

## 1.7.0 (October 6, 2022). Tested on Artifactory 7.41.13 and Xray 3.57.6

NEW FEATURE:
Expand Down
55 changes: 54 additions & 1 deletion docs/resources/watch.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,49 @@ resource "xray_watch" "repository" {
watch_recipients = ["[email protected]", "[email protected]"]
}
resource "xray_watch" "repository-ant-filter" {
name = "repository-watch"
description = "Watch a single repo or a list of repositories, using ant pattern"
active = true
project_key = "testproj"
watch_resource {
type = "repository"
bin_mgr_id = "default"
name = "your-repository-name"
repo_type = "local"
path_ant_filter {
exclude_patterns = ["**/*.md"]
include_patterns = ["**/*.js"]
}
}
watch_resource {
type = "repository"
bin_mgr_id = "default"
name = "your-other-repository-name"
repo_type = "remote"
filter {
type = "regex"
value = ".*"
}
}
assigned_policy {
name = xray_security_policy.min_severity.name
type = "security"
}
assigned_policy {
name = xray_license_policy.cvss_range.name
type = "license"
}
watch_recipients = ["[email protected]", "[email protected]"]
}
resource "xray_watch" "all-builds-with-filters" {
name = "build-watch"
description = "Watch all builds with Ant patterns filter"
Expand Down Expand Up @@ -269,6 +312,7 @@ Optional:
- `bin_mgr_id` (String) The ID number of a binary manager resource. Default value is `default`. To check the list of available binary managers, use the API call `${JFROG_URL}/xray/api/v1/binMgr` as an admin user, use `binMgrId` value. More info [here](https://www.jfrog.com/confluence/display/JFROG/Xray+REST+API#XrayRESTAPI-GetBinaryManager)
- `filter` (Block Set) Filter for `regex` and `package-type` type. Works only with `all-repos` watch_resource.type. (see [below for nested schema](#nestedblock--watch_resource--filter))
- `name` (String) The name of the build, repository or project. Xray indexing must be enabled on the repository or build
- `path_ant_filter` (Block Set) `path-ant-patterns` filter for `repository` and `all-repos` watch_resource.type (see [below for nested schema](#nestedblock--watch_resource--path_ant_filter))
- `repo_type` (String) Type of repository. Only applicable when `type` is `repository`. Options: `local` or `remote`.

<a id="nestedblock--watch_resource--ant_filter"></a>
Expand All @@ -286,4 +330,13 @@ Required:
Required:

- `type` (String) The type of filter, such as `regex` or `package-type`
- `value` (String) The value of the filter, such as the text of the regex or name of the package type.
- `value` (String) The value of the filter, such as the text of the regex or name of the package type.


<a id="nestedblock--watch_resource--path_ant_filter"></a>
### Nested Schema for `watch_resource.path_ant_filter`

Required:

- `exclude_patterns` (List of String) List of Ant patterns.
- `include_patterns` (List of String) List of Ant patterns.
43 changes: 43 additions & 0 deletions examples/resources/xray_watch/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,49 @@ resource "xray_watch" "repository" {
watch_recipients = ["[email protected]", "[email protected]"]
}

resource "xray_watch" "repository-ant-filter" {
name = "repository-watch"
description = "Watch a single repo or a list of repositories, using ant pattern"
active = true
project_key = "testproj"

watch_resource {
type = "repository"
bin_mgr_id = "default"
name = "your-repository-name"
repo_type = "local"

path_ant_filter {
exclude_patterns = ["**/*.md"]
include_patterns = ["**/*.js"]
}
}

watch_resource {
type = "repository"
bin_mgr_id = "default"
name = "your-other-repository-name"
repo_type = "remote"

filter {
type = "regex"
value = ".*"
}
}

assigned_policy {
name = xray_security_policy.min_severity.name
type = "security"
}

assigned_policy {
name = xray_license_policy.cvss_range.name
type = "license"
}

watch_recipients = ["[email protected]", "[email protected]"]
}

resource "xray_watch" "all-builds-with-filters" {
name = "build-watch"
description = "Watch all builds with Ant patterns filter"
Expand Down
28 changes: 28 additions & 0 deletions pkg/xray/resource_xray_watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,34 @@ func resourceXrayWatch() *schema.Resource {
},
},
},
"path_ant_filter": {
Type: schema.TypeSet,
Optional: true,
MinItems: 1,
Description: "`path-ant-patterns` filter for `repository` and `all-repos` watch_resource.type",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"include_patterns": {
Type: schema.TypeList,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Required: true,
MinItems: 1,
Description: "List of Ant patterns.",
},
"exclude_patterns": {
Type: schema.TypeList,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Required: true,
MinItems: 1,
Description: "List of Ant patterns.",
},
},
},
},
},
},
},
Expand Down
Loading

0 comments on commit 0967360

Please sign in to comment.