From 58671b883dac0bdda52f029432686bf390850432 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Wed, 6 Dec 2023 11:45:47 -0800 Subject: [PATCH 1/7] Update to latest packages --- go.mod | 34 ++--- go.sum | 131 +++++++++++------- pkg/xray/policies.go | 9 +- pkg/xray/provider.go | 9 +- pkg/xray/reports.go | 7 +- pkg/xray/resource_xray_custom_issue.go | 9 +- pkg/xray/resource_xray_custom_issue_test.go | 7 +- pkg/xray/resource_xray_ignore_rule.go | 7 +- pkg/xray/resource_xray_ignore_rule_test.go | 28 ++-- pkg/xray/resource_xray_license_policy_test.go | 19 +-- ...ource_xray_operational_risk_policy_test.go | 17 +-- pkg/xray/resource_xray_repository_config.go | 9 +- .../resource_xray_repository_config_test.go | 26 ++-- .../resource_xray_security_policy_test.go | 45 +++--- pkg/xray/resource_xray_settings.go | 5 +- pkg/xray/resource_xray_watch_test.go | 53 +++---- pkg/xray/resource_xray_webhook.go | 10 +- pkg/xray/resource_xray_webhook_test.go | 10 +- pkg/xray/resource_xray_workers_count.go | 5 +- pkg/xray/resource_xray_workers_count_test.go | 4 +- pkg/xray/util_test.go | 4 +- pkg/xray/watches.go | 9 +- 22 files changed, 253 insertions(+), 204 deletions(-) diff --git a/go.mod b/go.mod index 6b1c2e99..a00c5528 100644 --- a/go.mod +++ b/go.mod @@ -8,10 +8,10 @@ require ( github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/terraform-plugin-docs v0.13.0 github.com/hashicorp/terraform-plugin-log v0.9.0 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0 - github.com/hashicorp/terraform-plugin-testing v1.4.0 - github.com/jfrog/terraform-provider-shared v1.20.2 - golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 + github.com/hashicorp/terraform-plugin-testing v1.5.1 + github.com/jfrog/terraform-provider-shared v1.21.1 + golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 golang.org/x/text v0.13.0 ) @@ -19,9 +19,9 @@ require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.1.1 // indirect github.com/Masterminds/sprig/v3 v3.2.2 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect github.com/agext/levenshtein v1.2.2 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect github.com/cloudflare/circl v1.3.3 // indirect @@ -36,19 +36,19 @@ require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.4.10 // indirect + github.com/hashicorp/go-plugin v1.5.1 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect - github.com/hashicorp/hc-install v0.5.2 // indirect - github.com/hashicorp/hcl/v2 v2.17.0 // indirect + github.com/hashicorp/hc-install v0.6.0 // indirect + github.com/hashicorp/hcl/v2 v2.18.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.18.1 // indirect + github.com/hashicorp/terraform-exec v0.19.0 // indirect github.com/hashicorp/terraform-json v0.17.1 // indirect - github.com/hashicorp/terraform-plugin-go v0.18.0 // indirect - github.com/hashicorp/terraform-registry-address v0.2.1 // indirect + github.com/hashicorp/terraform-plugin-go v0.19.0 // indirect + github.com/hashicorp/terraform-registry-address v0.2.2 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect github.com/huandu/xstrings v1.3.2 // indirect - github.com/imdario/mergo v0.3.13 // indirect + github.com/imdario/mergo v0.3.15 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mitchellh/cli v1.1.5 // indirect @@ -65,14 +65,14 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.13.2 // indirect + github.com/zclconf/go-cty v1.14.0 // indirect golang.org/x/crypto v0.14.0 // indirect - golang.org/x/mod v0.10.0 // indirect + golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.56.3 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect + google.golang.org/grpc v1.57.1 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect gopkg.in/ldap.v2 v2.5.1 // indirect diff --git a/go.sum b/go.sum index 9ac15dc2..6854650b 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= @@ -5,24 +7,25 @@ github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0 github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= -github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= -github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 h1:KLq8BE0KwCL+mmXnjLWEAOYO+2l2AE4YMmqG1ZpZHBs= +github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= +github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= +github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= +github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -35,16 +38,18 @@ github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= -github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= -github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg= -github.com/go-git/go-git/v5 v5.6.1 h1:q4ZRqQl4pR/ZJHc1L5CFjGA1a10u76aV1iC+nh+bHsk= -github.com/go-git/go-git/v5 v5.6.1/go.mod h1:mvyoL6Unz0PiTQrGQfSfiLFhBH1c1e84ylC2MDs4ee8= +github.com/go-git/go-git/v5 v5.8.1 h1:Zo79E4p7TRk0xoRgMq0RShiTHGKcKI4+DI6BfJc/Q+A= +github.com/go-git/go-git/v5 v5.8.1/go.mod h1:FHFuoD6yGz5OSKEBK+aWN9Oah0q54Jxl0abmj6GnqAo= github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= @@ -75,35 +80,35 @@ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.4.10 h1:xUbmA4jC6Dq163/fWcp8P3JuHilrHHMLNRxzGQJ9hNk= -github.com/hashicorp/go-plugin v1.4.10/go.mod h1:6/1TEzT0eQznvI/gV2CM29DLSkAK/e58mUWKVsPaph0= +github.com/hashicorp/go-plugin v1.5.1 h1:oGm7cWBaYIp3lJpx1RUEfLWophprE2EV/KUeqBYo+6k= +github.com/hashicorp/go-plugin v1.5.1/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.5.2 h1:SfwMFnEXVVirpwkDuSF5kymUOhrUxrTq3udEseZdOD0= -github.com/hashicorp/hc-install v0.5.2/go.mod h1:9QISwe6newMWIfEiXpzuu1k9HAGtQYgnSH8H9T8wmoI= -github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= -github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= +github.com/hashicorp/hc-install v0.6.0 h1:fDHnU7JNFNSQebVKYhHZ0va1bC6SrPQ8fpebsvNr2w4= +github.com/hashicorp/hc-install v0.6.0/go.mod h1:10I912u3nntx9Umo1VAeYPUUuehk0aRQJYpMwbX5wQA= +github.com/hashicorp/hcl/v2 v2.18.0 h1:wYnG7Lt31t2zYkcquwgKo6MWXzRUDIeIVU5naZwHLl8= +github.com/hashicorp/hcl/v2 v2.18.0/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX5H8XZxHlH4= -github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980= +github.com/hashicorp/terraform-exec v0.19.0 h1:FpqZ6n50Tk95mItTSS9BjeOVUb4eg81SpgVtZNNtFSM= +github.com/hashicorp/terraform-exec v0.19.0/go.mod h1:tbxUpe3JKruE9Cuf65mycSIT8KiNPZ0FkuTE3H4urQg= github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA= github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o= github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY= github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ= -github.com/hashicorp/terraform-plugin-go v0.18.0 h1:IwTkOS9cOW1ehLd/rG0y+u/TGLK9y6fGoBjXVUquzpE= -github.com/hashicorp/terraform-plugin-go v0.18.0/go.mod h1:l7VK+2u5Kf2y+A+742GX0ouLut3gttudmvMgN0PA74Y= +github.com/hashicorp/terraform-plugin-go v0.19.0 h1:BuZx/6Cp+lkmiG0cOBk6Zps0Cb2tmqQpDM3iAtnhDQU= +github.com/hashicorp/terraform-plugin-go v0.19.0/go.mod h1:EhRSkEPNoylLQntYsk5KrDHTZJh9HQoumZXbOGOXmec= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0 h1:I8efBnjuDrgPjNF1MEypHy48VgcTIUY4X6rOFunrR3Y= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0/go.mod h1:cUEP4ly/nxlHy5HzD6YRrHydtlheGvGRJDhiWqqVik4= -github.com/hashicorp/terraform-plugin-testing v1.4.0 h1:DVIXxw7VHZvnwWVik4HzhpC2yytaJ5FpiHxz5debKmE= -github.com/hashicorp/terraform-plugin-testing v1.4.0/go.mod h1:b7Bha24iGrbZQjT+ZE8m9crck1YjdVOZ8mfGCQ19OxA= -github.com/hashicorp/terraform-registry-address v0.2.1 h1:QuTf6oJ1+WSflJw6WYOHhLgwUiQ0FrROpHPYFtwTYWM= -github.com/hashicorp/terraform-registry-address v0.2.1/go.mod h1:BSE9fIFzp0qWsJUUyGquo4ldV9k2n+psif6NYkBRS3Y= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 h1:wcOKYwPI9IorAJEBLzgclh3xVolO7ZorYd6U1vnok14= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0/go.mod h1:qH/34G25Ugdj5FcM95cSoXzUgIbgfhVLXCcEcYaMwq8= +github.com/hashicorp/terraform-plugin-testing v1.5.1 h1:T4aQh9JAhmWo4+t1A7x+rnxAJHCDIYW9kXyo4sVO92c= +github.com/hashicorp/terraform-plugin-testing v1.5.1/go.mod h1:dg8clO6K59rZ8w9EshBmDp1CxTIPu3yA4iaDpX1h5u0= +github.com/hashicorp/terraform-registry-address v0.2.2 h1:lPQBg403El8PPicg/qONZJDC6YlgCVbWDtNmmZKtBno= +github.com/hashicorp/terraform-registry-address v0.2.2/go.mod h1:LtwNbCihUoUZ3RYriyS2wF/lGPB6gF9ICLRtuDk7hSo= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= @@ -112,14 +117,14 @@ github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= -github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= +github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= +github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jfrog/terraform-provider-shared v1.20.2 h1:PAHPn0H1CkMWApPaEM5QXYILMOmzgtLuE/clfcQp5Mc= -github.com/jfrog/terraform-provider-shared v1.20.2/go.mod h1:37QaQbp1XSbA/Lnk6HAdh6D2EzUBK+Rk9ZCasQ0BJr4= -github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= -github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= +github.com/jfrog/terraform-provider-shared v1.21.1 h1:hBlk7087fjMVk7fdx2BkpZM3RnLIzS6fGNZEJc5HLYc= +github.com/jfrog/terraform-provider-shared v1.21.1/go.mod h1:Ioq1OBLb2h9uj4t4KzBEfA1piHbUg+Lgvn84Vbzk5uI= +github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -171,8 +176,8 @@ github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/skeema/knownhosts v1.1.0 h1:Wvr9V0MxhjRbl3f9nMnKnFfiWTJmtECJ9Njkea3ysW0= -github.com/skeema/knownhosts v1.1.0/go.mod h1:sKFq3RD6/TKZkSWn8boUbDC7Qkgcv+8XXijpFO6roag= +github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM= +github.com/skeema/knownhosts v1.2.0/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= @@ -192,25 +197,38 @@ github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAh github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= -github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zclconf/go-cty v1.14.0 h1:/Xrd39K7DXbHzlisFP9c4pHao4yyf+/Ug9LEz+Y/yhc= +github.com/zclconf/go-cty v1.14.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= -golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= -golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U= +golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -220,26 +238,44 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= -google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= -google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= +google.golang.org/grpc v1.57.1 h1:upNTNqv0ES+2ZOOqACwVtS3Il8M12/+Hz41RCPzAjQg= +google.golang.org/grpc v1.57.1/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= @@ -256,6 +292,5 @@ gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRN gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/xray/policies.go b/pkg/xray/policies.go index 221fcfa5..a324d56a 100644 --- a/pkg/xray/policies.go +++ b/pkg/xray/policies.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" ) @@ -714,7 +715,7 @@ func resourceXrayPolicyCreate(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, policy.ProjectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, policy.ProjectKey) if err != nil { return diag.FromErr(err) } @@ -732,7 +733,7 @@ func resourceXrayPolicyRead(ctx context.Context, d *schema.ResourceData, m inter policy := Policy{} projectKey := d.Get("project_key").(string) - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, projectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, projectKey) if err != nil { return diag.FromErr(err) } @@ -759,7 +760,7 @@ func resourceXrayPolicyUpdate(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, policy.ProjectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, policy.ProjectKey) if err != nil { return diag.FromErr(err) } @@ -784,7 +785,7 @@ func resourceXrayPolicyDelete(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, policy.ProjectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, policy.ProjectKey) if err != nil { return diag.FromErr(err) } diff --git a/pkg/xray/provider.go b/pkg/xray/provider.go index e2b2fc25..1d7acdb7 100644 --- a/pkg/xray/provider.go +++ b/pkg/xray/provider.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/jfrog/terraform-provider-shared/client" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" ) @@ -105,20 +106,20 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, terraformVer } } - artifactoryVersion, err := sdk.GetArtifactoryVersion(restyBase) + artifactoryVersion, err := util.GetArtifactoryVersion(restyBase) if err != nil { return nil, diag.FromErr(err) } - xrayVersion, err := sdk.GetXrayVersion(restyBase) + xrayVersion, err := util.GetXrayVersion(restyBase) if err != nil { return nil, diag.FromErr(err) } featureUsage := fmt.Sprintf("Terraform/%s", terraformVersion) - sdk.SendUsage(ctx, restyBase, productId, featureUsage) + go util.SendUsage(ctx, restyBase, productId, featureUsage) - return sdk.ProvderMetadata{ + return util.ProvderMetadata{ Client: restyBase, ArtifactoryVersion: artifactoryVersion, XrayVersion: xrayVersion, diff --git a/pkg/xray/reports.go b/pkg/xray/reports.go index 16dd1a75..f5587862 100644 --- a/pkg/xray/reports.go +++ b/pkg/xray/reports.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" "golang.org/x/exp/slices" @@ -628,7 +629,7 @@ func resourceXrayReportRead(ctx context.Context, d *schema.ResourceData, m inter report := Report{} projectKey := d.Get("project_key").(string) - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, projectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, projectKey) if err != nil { return diag.FromErr(err) } @@ -650,7 +651,7 @@ func resourceXrayReportRead(ctx context.Context, d *schema.ResourceData, m inter func resourceXrayReportDelete(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { projectKey := d.Get("project_key").(string) - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, projectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, projectKey) if err != nil { return diag.FromErr(err) } @@ -669,7 +670,7 @@ func resourceXrayReportDelete(_ context.Context, d *schema.ResourceData, m inter func createReport(reportType string, d *schema.ResourceData, m interface{}) diag.Diagnostics { report := unpackReport(d, reportType) - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, report.ProjectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, report.ProjectKey) if err != nil { return diag.FromErr(err) } diff --git a/pkg/xray/resource_xray_custom_issue.go b/pkg/xray/resource_xray_custom_issue.go index 9179f410..28bd8528 100644 --- a/pkg/xray/resource_xray_custom_issue.go +++ b/pkg/xray/resource_xray_custom_issue.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" ) @@ -460,7 +461,7 @@ func resourceXrayCustomIssue() *schema.Resource { var resourceXrayCustomIssueRead = func(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { customIssue := CustomIssue{} - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, "") + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, "") if err != nil { return diag.FromErr(err) } @@ -486,7 +487,7 @@ func resourceXrayCustomIssue() *schema.Resource { return diag.FromErr(err) } - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, "") + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, "") if err != nil { return diag.FromErr(err) } @@ -509,7 +510,7 @@ func resourceXrayCustomIssue() *schema.Resource { return diag.FromErr(err) } - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, "") + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, "") if err != nil { return diag.FromErr(err) } @@ -528,7 +529,7 @@ func resourceXrayCustomIssue() *schema.Resource { } var resourceXrayCustomIssueDelete = func(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, "") + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, "") if err != nil { return diag.FromErr(err) } diff --git a/pkg/xray/resource_xray_custom_issue_test.go b/pkg/xray/resource_xray_custom_issue_test.go index cd58bfc6..86da41e5 100644 --- a/pkg/xray/resource_xray_custom_issue_test.go +++ b/pkg/xray/resource_xray_custom_issue_test.go @@ -7,6 +7,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" ) @@ -92,7 +93,7 @@ func TestAccCustomIssue_full(t *testing.T) { "source_id": "CVE-2017-1000386", } - config := sdk.ExecuteTemplate("TestAccCustomIssue_full", template, testData) + config := util.ExecuteTemplate("TestAccCustomIssue_full", template, testData) updatedTestData := map[string]string{ "name": resourceName, @@ -114,7 +115,7 @@ func TestAccCustomIssue_full(t *testing.T) { "source_name": "CVE-2017-1000386", "source_url": "https://nvd.nist.gov/vuln/detail/CVE-2017-1000386", } - updatedConfig := sdk.ExecuteTemplate("TestAccCustomIssue_full", fullTemplate, updatedTestData) + updatedConfig := util.ExecuteTemplate("TestAccCustomIssue_full", fullTemplate, updatedTestData) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -249,7 +250,7 @@ func TestAccCustomIssue_invalid(t *testing.T) { testCase.extras, ) - config := sdk.ExecuteTemplate("TestAccCustomIssue_invalid", template, testData) + config := util.ExecuteTemplate("TestAccCustomIssue_invalid", template, testData) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/pkg/xray/resource_xray_ignore_rule.go b/pkg/xray/resource_xray_ignore_rule.go index 44038fe4..4aec5fdd 100644 --- a/pkg/xray/resource_xray_ignore_rule.go +++ b/pkg/xray/resource_xray_ignore_rule.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" ) @@ -465,7 +466,7 @@ func resourceXrayIgnoreRule() *schema.Resource { var ignoreRule IgnoreRule projectKey := d.Get("project_key").(string) - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, projectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, projectKey) if err != nil { return diag.FromErr(err) } @@ -491,7 +492,7 @@ func resourceXrayIgnoreRule() *schema.Resource { return diag.FromErr(err) } - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, ignoreRule.ProjectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, ignoreRule.ProjectKey) if err != nil { return diag.FromErr(err) } @@ -530,7 +531,7 @@ func resourceXrayIgnoreRule() *schema.Resource { return diag.FromErr(err) } - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, ignoreRule.ProjectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, ignoreRule.ProjectKey) if err != nil { return diag.FromErr(err) } diff --git a/pkg/xray/resource_xray_ignore_rule_test.go b/pkg/xray/resource_xray_ignore_rule_test.go index 1a2986c9..654cfb4f 100644 --- a/pkg/xray/resource_xray_ignore_rule_test.go +++ b/pkg/xray/resource_xray_ignore_rule_test.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/client" "github.com/jfrog/terraform-provider-shared/testutil" - "github.com/jfrog/terraform-provider-shared/util/sdk" + "github.com/jfrog/terraform-provider-shared/util" ) func TestAccIgnoreRule_objectives(t *testing.T) { @@ -26,7 +26,7 @@ func objectiveTestCase(objective string, t *testing.T) (*testing.T, resource.Tes _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` + config := util.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -67,7 +67,7 @@ func TestAccIgnoreRule_operational_risk(t *testing.T) { _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` + config := util.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -111,7 +111,7 @@ func TestAccIgnoreRule_invalid_operational_risk(t *testing.T) { _, _, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` + config := util.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -142,7 +142,7 @@ func TestAccIgnoreRule_scopes_policies(t *testing.T) { _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` + config := util.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_security_policy" "fake_policy" { name = "fake-policy" description = "Security policy description" @@ -210,7 +210,7 @@ func TestAccIgnoreRule_scopes_watches_policies(t *testing.T) { _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` + config := util.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_security_policy" "security" { name = "fake-policy" description = "Security policy description" @@ -296,7 +296,7 @@ func TestAccIgnoreRule_scopes_watches_policies(t *testing.T) { func TestAccIgnoreRule_scopes_no_expiration_policies(t *testing.T) { _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") - config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` + config := util.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_security_policy" "security" { name = "fake-policy" description = "Security policy description" @@ -356,7 +356,7 @@ func TestAccIgnoreRule_scopes_no_expiration_policies(t *testing.T) { func TestAccIgnoreRule_scopes_no_expiration_watches(t *testing.T) { _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") - config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` + config := util.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_security_policy" "security" { name = "fake-policy" description = "Security policy description" @@ -434,7 +434,7 @@ func TestAccIgnoreRule_docker_layers(t *testing.T) { _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` + config := util.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -481,7 +481,7 @@ func TestAccIgnoreRule_invalid_docker_layers(t *testing.T) { _, _, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` + config := util.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -523,7 +523,7 @@ func sourceTestCase(source string, t *testing.T) (*testing.T, resource.TestCase) _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` + config := util.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -570,7 +570,7 @@ func TestAccIgnoreRule_artifact(t *testing.T) { _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` + config := util.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -619,7 +619,7 @@ func TestAccIgnoreRule_invalid_artifact_path(t *testing.T) { _, _, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` + config := util.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -653,7 +653,7 @@ func TestAccIgnoreRule_with_project_key(t *testing.T) { expirationDate := time.Now().Add(time.Hour * 48) projectKey := fmt.Sprintf("testproj%d", testutil.RandomInt()) - config := sdk.ExecuteTemplate( + config := util.ExecuteTemplate( "TestAccIgnoreRule", `resource "project" "{{ .projectKey }}" { key = "{{ .projectKey }}" diff --git a/pkg/xray/resource_xray_license_policy_test.go b/pkg/xray/resource_xray_license_policy_test.go index 10d013fa..6d4a7951 100644 --- a/pkg/xray/resource_xray_license_policy_test.go +++ b/pkg/xray/resource_xray_license_policy_test.go @@ -8,6 +8,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" ) @@ -75,7 +76,7 @@ func TestAccLicensePolicy_badGracePeriod(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), ExpectError: regexp.MustCompile("Found Invalid Policy"), }, }, @@ -126,11 +127,11 @@ func TestAccLicensePolicy_withProjectKey(t *testing.T) { } }` - config := sdk.ExecuteTemplate(fqrn, template, testData) + config := util.ExecuteTemplate(fqrn, template, testData) updatedTestData := sdk.MergeMaps(testData) updatedTestData["policy_description"] = "New description" - updatedConfig := sdk.ExecuteTemplate(fqrn, template, updatedTestData) + updatedConfig := util.ExecuteTemplate(fqrn, template, updatedTestData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -180,7 +181,7 @@ func TestAccLicensePolicy_createAllowedLic(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), Check: verifyLicensePolicy(fqrn, testData, testData["allowedOrBanned"]), }, { @@ -209,7 +210,7 @@ func TestAccLicensePolicy_createAllowedLicCustom(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), Check: verifyLicensePolicy(fqrn, testData, testData["allowedOrBanned"]), }, { @@ -236,7 +237,7 @@ func TestAccLicensePolicy_createBannedLic(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), Check: verifyLicensePolicy(fqrn, testData, testData["allowedOrBanned"]), }, { @@ -265,7 +266,7 @@ func TestAccLicensePolicy_createBannedLicCustom(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), Check: verifyLicensePolicy(fqrn, testData, testData["allowedOrBanned"]), }, { @@ -293,7 +294,7 @@ func TestAccLicensePolicy_createMultiLicensePermissiveFalse(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), Check: verifyLicensePolicy(fqrn, testData, testData["allowedOrBanned"]), }, { @@ -323,7 +324,7 @@ func TestAccLicensePolicy_createBlockFalse(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), Check: verifyLicensePolicy(fqrn, testData, testData["allowedOrBanned"]), }, { diff --git a/pkg/xray/resource_xray_operational_risk_policy_test.go b/pkg/xray/resource_xray_operational_risk_policy_test.go index 4a8e6b52..9843f62e 100644 --- a/pkg/xray/resource_xray_operational_risk_policy_test.go +++ b/pkg/xray/resource_xray_operational_risk_policy_test.go @@ -8,6 +8,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" ) @@ -63,11 +64,11 @@ func TestAccOperationalRiskPolicy_withProjectKey(t *testing.T) { testData["project_key"] = projectKey testData["op_risk_min_risk"] = "Medium" - config := sdk.ExecuteTemplate(fqrn, template, testData) + config := util.ExecuteTemplate(fqrn, template, testData) updatedTestData := sdk.MergeMaps(testData) updatedTestData["policy_description"] = "New description" - updatedConfig := sdk.ExecuteTemplate(fqrn, template, updatedTestData) + updatedConfig := util.ExecuteTemplate(fqrn, template, updatedTestData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -139,7 +140,7 @@ func TestAccOperationalRiskPolicy_minRiskCriteria(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, opertionalRiskPolicyMinRisk, testData), + Config: util.ExecuteTemplate(fqrn, opertionalRiskPolicyMinRisk, testData), Check: resource.ComposeTestCheckFunc( verifyOpertionalRiskPolicy(fqrn, testData), resource.TestCheckResourceAttr(fqrn, "rule.0.criteria.0.op_risk_min_risk", testData["op_risk_min_risk"]), @@ -237,7 +238,7 @@ func TestAccOperationalRiskPolicy_customCriteria(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, opertionalRiskPolicyCustom, testData), + Config: util.ExecuteTemplate(fqrn, opertionalRiskPolicyCustom, testData), Check: resource.ComposeTestCheckFunc( verifyOpertionalRiskPolicy(fqrn, testData), resource.TestCheckResourceAttr(fqrn, "rule.0.criteria.0.op_risk_custom.0.use_and_condition", testData["op_risk_custom_use_and_condition"]), @@ -251,7 +252,7 @@ func TestAccOperationalRiskPolicy_customCriteria(t *testing.T) { ), }, { - Config: sdk.ExecuteTemplate(fqrn, opertionalRiskPolicyCustomUnset, testData), + Config: util.ExecuteTemplate(fqrn, opertionalRiskPolicyCustomUnset, testData), Check: resource.ComposeTestCheckFunc( verifyOpertionalRiskPolicy(fqrn, testData), resource.TestCheckResourceAttr(fqrn, "rule.0.criteria.0.op_risk_custom.0.use_and_condition", testData["op_risk_custom_use_and_condition"]), @@ -322,7 +323,7 @@ func TestAccOperationalRiskPolicy_customCriteria_migration(t *testing.T) { Source: "registry.terraform.io/jfrog/xray", }, }, - Config: sdk.ExecuteTemplate(fqrn, opertionalRiskPolicyCustom, testData), + Config: util.ExecuteTemplate(fqrn, opertionalRiskPolicyCustom, testData), Check: resource.ComposeTestCheckFunc( verifyOpertionalRiskPolicy(fqrn, testData), resource.TestCheckResourceAttr(fqrn, "rule.0.criteria.0.op_risk_custom.0.use_and_condition", testData["op_risk_custom_use_and_condition"]), @@ -337,7 +338,7 @@ func TestAccOperationalRiskPolicy_customCriteria_migration(t *testing.T) { }, { ProviderFactories: testAccProviders(), - Config: sdk.ExecuteTemplate(fqrn, opertionalRiskPolicyCustom, testData), + Config: util.ExecuteTemplate(fqrn, opertionalRiskPolicyCustom, testData), Check: resource.ComposeTestCheckFunc( verifyOpertionalRiskPolicy(fqrn, testData), resource.TestCheckResourceAttr(fqrn, "rule.0.criteria.0.op_risk_custom.0.use_and_condition", testData["op_risk_custom_use_and_condition"]), @@ -406,7 +407,7 @@ func TestAccOperationalRiskPolicy_criteriaValidation(t *testing.T) { } }` - config := sdk.ExecuteTemplate(fqrn, template, testData) + config := util.ExecuteTemplate(fqrn, template, testData) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/pkg/xray/resource_xray_repository_config.go b/pkg/xray/resource_xray_repository_config.go index 6bbfbfa4..ff3e422f 100644 --- a/pkg/xray/resource_xray_repository_config.go +++ b/pkg/xray/resource_xray_repository_config.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" "golang.org/x/exp/slices" @@ -52,7 +53,7 @@ type RepositoryConfiguration struct { var exposuresPackageTypes = func(xrayVersion string) []string { packageTypes := []string{"docker", "terraformbackend"} - if ok, err := sdk.CheckVersion(xrayVersion, "3.78.9"); err == nil && ok { + if ok, err := util.CheckVersion(xrayVersion, "3.78.9"); err == nil && ok { packageTypes = append(packageTypes, "maven", "npm", "pypi") } @@ -62,7 +63,7 @@ var exposuresPackageTypes = func(xrayVersion string) []string { var vulnContextualAnalysisPackageTypes = func(xrayVersion string) []string { packageTypes := []string{"docker"} - if ok, err := sdk.CheckVersion(xrayVersion, "3.77.4"); err == nil && ok { + if ok, err := util.CheckVersion(xrayVersion, "3.77.4"); err == nil && ok { packageTypes = append(packageTypes, "maven") } @@ -460,7 +461,7 @@ func resourceXrayRepositoryConfig() *schema.Resource { repositoryConfig := RepositoryConfiguration{} repoName := d.Id() - metadata := m.(sdk.ProvderMetadata) + metadata := m.(util.ProvderMetadata) resp, err := metadata.Client.R(). SetResult(&repositoryConfig). @@ -484,7 +485,7 @@ func resourceXrayRepositoryConfig() *schema.Resource { } var resourceXrayRepositoryConfigCreate = func(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - metadata := m.(sdk.ProvderMetadata) + metadata := m.(util.ProvderMetadata) packageType, err := getPackageType(metadata.Client, d.Get("repo_name").(string)) if err != nil { return diag.FromErr(err) diff --git a/pkg/xray/resource_xray_repository_config_test.go b/pkg/xray/resource_xray_repository_config_test.go index b4b84e6c..12d69382 100644 --- a/pkg/xray/resource_xray_repository_config_test.go +++ b/pkg/xray/resource_xray_repository_config_test.go @@ -8,7 +8,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/testutil" - "github.com/jfrog/terraform-provider-shared/util/sdk" + "github.com/jfrog/terraform-provider-shared/util" ) func TestAccRepositoryConfigRepoNoConfig(t *testing.T) { @@ -18,7 +18,7 @@ func TestAccRepositoryConfigRepoNoConfig(t *testing.T) { "repo_name": "repo-config-test-repo", } - config := sdk.ExecuteTemplate( + config := util.ExecuteTemplate( fqrn, `resource "xray_repository_config" "{{ .resource_name }}" { repo_name = "{{ .repo_name }}" @@ -49,7 +49,7 @@ func TestAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t *testing.T {"maven", TestDataRepoConfigMavenTemplate, "3.77.4"}, } - version, err := sdk.GetXrayVersion(GetTestResty(t)) + version, err := util.GetXrayVersion(GetTestResty(t)) if err != nil { t.Fail() return @@ -73,7 +73,7 @@ func testAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t *testing.T "applications_scan": "false", } - valid, _ := sdk.CheckVersion(xrayVersion, validVersion) + valid, _ := util.CheckVersion(xrayVersion, validVersion) if !valid { t.Skipf("xray version %s does not support %s for exposures scanning", xrayVersion, packageType) return @@ -95,7 +95,7 @@ func testAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t *testing.T Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, template, testData), + Config: util.ExecuteTemplate(fqrn, template, testData), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(fqrn, "repo_name", testData["repo_name"]), resource.TestCheckResourceAttr(fqrn, "config.0.retention_in_days", testData["retention_in_days"]), @@ -165,7 +165,7 @@ func TestAccRepositoryConfigRepoConfigCreate_exposure(t *testing.T) { }, } - version, err := sdk.GetXrayVersion(GetTestResty(t)) + version, err := util.GetXrayVersion(GetTestResty(t)) if err != nil { t.Fail() return @@ -187,7 +187,7 @@ func TestAccRepositoryConfigRepoConfigCreate_no_exposure(t *testing.T) { } }` validVersion := "3.75.10" - version, err := sdk.GetXrayVersion(GetTestResty(t)) + version, err := util.GetXrayVersion(GetTestResty(t)) if err != nil { t.Fail() return @@ -220,7 +220,7 @@ func testAccRepositoryConfigRepoConfigCreate(t *testing.T, packageType, template "applications_scan": "true", } - valid, _ := sdk.CheckVersion(xrayVersion, validVersion) + valid, _ := util.CheckVersion(xrayVersion, validVersion) if !valid { t.Skipf("xray version %s does not support %s for exposures scanning", xrayVersion, packageType) return @@ -241,7 +241,7 @@ func testAccRepositoryConfigRepoConfigCreate(t *testing.T, packageType, template ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, template, testData), + Config: util.ExecuteTemplate(fqrn, template, testData), Check: checkFunc(fqrn, testData), }, { @@ -278,7 +278,7 @@ func TestAccRepositoryConfigRepoConfigCreate_InvalidExposures(t *testing.T) { Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, TestDataRepoConfigInvalidExposuresTemplate, testData), + Config: util.ExecuteTemplate(fqrn, TestDataRepoConfigInvalidExposuresTemplate, testData), ExpectNonEmptyPlan: true, }, }, @@ -318,7 +318,7 @@ func TestAccRepositoryConfigRepoPathsCreate(t *testing.T) { Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, TestDataRepoPathsConfigTemplate, testData), + Config: util.ExecuteTemplate(fqrn, TestDataRepoPathsConfigTemplate, testData), Check: resource.ComposeTestCheckFunc(verifyRepositoryConfig(fqrn, testData)), }, { @@ -377,11 +377,11 @@ func TestAccRepositoryConfigRepoPathsUpdate(t *testing.T) { Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, TestDataRepoPathsConfigTemplate, testData), + Config: util.ExecuteTemplate(fqrn, TestDataRepoPathsConfigTemplate, testData), Check: resource.ComposeTestCheckFunc(verifyRepositoryConfig(fqrn, testData)), }, { - Config: sdk.ExecuteTemplate(fqrn, TestDataRepoPathsConfigTemplate, testDataUpdated), + Config: util.ExecuteTemplate(fqrn, TestDataRepoPathsConfigTemplate, testDataUpdated), Check: resource.ComposeTestCheckFunc(verifyRepositoryConfig(fqrn, testDataUpdated)), }, }, diff --git a/pkg/xray/resource_xray_security_policy_test.go b/pkg/xray/resource_xray_security_policy_test.go index ef309b9f..daa4513b 100644 --- a/pkg/xray/resource_xray_security_policy_test.go +++ b/pkg/xray/resource_xray_security_policy_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" ) @@ -53,7 +54,7 @@ func TestAccSecurityPolicy_multipleRules(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyTwoRules, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyTwoRules, testData), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(fqrn, "name", testData["policy_name"]), resource.TestCheckResourceAttr(fqrn, "description", testData["policy_description"]), @@ -119,7 +120,7 @@ func TestAccSecurityPolicy_unknownMinSeveritySecurityPolicy_beforeVersion3602(t Steps: []resource.TestStep{ { SkipFunc: onOrAfterVersion3602, - Config: sdk.ExecuteTemplate(fqrn, securityPolicyMinSeverity, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyMinSeverity, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeSeverity), }, }, @@ -188,7 +189,7 @@ func TestAccSecurityPolicy_badGracePeriod(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), ExpectError: regexp.MustCompile("Found Invalid Policy"), }, }, @@ -235,11 +236,11 @@ func TestAccSecurityPolicy_withProjectKey(t *testing.T) { } }` - config := sdk.ExecuteTemplate(fqrn, template, testData) + config := util.ExecuteTemplate(fqrn, template, testData) updatedTestData := sdk.MergeMaps(testData) updatedTestData["policy_description"] = "New description" - updatedConfig := sdk.ExecuteTemplate(fqrn, template, updatedTestData) + updatedConfig := util.ExecuteTemplate(fqrn, template, updatedTestData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -288,7 +289,7 @@ func TestAccSecurityPolicy_createBlockDownloadTrueCVSS(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeCvss), }, { @@ -317,7 +318,7 @@ func TestAccSecurityPolicy_createBlockDownloadFalseCVSS(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeCvss), }, { @@ -344,7 +345,7 @@ func TestAccSecurityPolicy_createBlockDownloadTrueMinSeverity(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyMinSeverity, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyMinSeverity, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeSeverity), }, { @@ -373,7 +374,7 @@ func TestAccSecurityPolicy_createFixVersionDepMinSeverity(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyFixVersionDep, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyFixVersionDep, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeSeverity), }, { @@ -403,7 +404,7 @@ func TestAccSecurityPolicy_createMaliciousPackage(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyMaliciousPkgFixVersionDep, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyMaliciousPkgFixVersionDep, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeMaliciousPkg), }, { @@ -432,7 +433,7 @@ func TestAccSecurityPolicy_createMaliciousPackageFail(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyMaliciousPkgFixVersionDep, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyMaliciousPkgFixVersionDep, testData), ExpectError: regexp.MustCompile("fix_version_dependant must be set to false if malicious_package is true"), }, }, @@ -455,7 +456,7 @@ func TestAccSecurityPolicy_createMaliciousPackageCvssMinSeverityFail(t *testing. ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSSMinSeverityMaliciousPkg, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyCVSSMinSeverityMaliciousPkg, testData), ExpectError: regexp.MustCompile("malicious_package can't be set together with min_severity and/or cvss_range"), }, }, @@ -478,7 +479,7 @@ func TestAccSecurityPolicy_createCvssMinSeverityFail(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSSMinSeverityMaliciousPkg, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyCVSSMinSeverityMaliciousPkg, testData), ExpectError: regexp.MustCompile("min_severity can't be set together with cvss_range"), }, }, @@ -502,7 +503,7 @@ func TestAccSecurityPolicy_createBlockDownloadFalseMinSeverity(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyMinSeverity, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyMinSeverity, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeSeverity), }, { @@ -531,7 +532,7 @@ func TestAccSecurityPolicy_createCVSSFloat(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeCvss), }, { @@ -560,7 +561,7 @@ func TestAccSecurityPolicy_blockMismatchCVSS(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), ExpectError: regexp.MustCompile("Found Invalid Policy"), }, }, @@ -586,7 +587,7 @@ func TestAccSecurityPolicy_noActions(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyNoActions, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyNoActions, testData), ExpectError: regexp.MustCompile("Insufficient actions blocks"), }, }, @@ -612,7 +613,7 @@ func TestAccSecurityPolicy_vulnerabilityIds(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyVulnIds, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyVulnIds, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeVulnerabilityIds), }, { @@ -644,7 +645,7 @@ func TestAccSecurityPolicy_vulnerabilityIdsIncorrectCVEFails(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyVulnIds, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyVulnIds, testData), ExpectError: regexp.MustCompile("invalid value for vulnerability_ids"), }, }, @@ -684,7 +685,7 @@ func TestAccSecurityPolicy_conflictingAttributesFail(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyVulnIdsConflict, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyVulnIdsConflict, testData), ExpectError: regexp.MustCompile("can't be set together"), }, }, @@ -709,7 +710,7 @@ func TestAccSecurityPolicy_vulnerabilityIdsLimitFail(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyVulnIdsLimit, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyVulnIdsLimit, testData), ExpectError: regexp.MustCompile("Too many list items"), }, }, @@ -735,7 +736,7 @@ func TestAccSecurityPolicy_exposures(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, securityPolicyExposures, testData), + Config: util.ExecuteTemplate(fqrn, securityPolicyExposures, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeExposures), }, { diff --git a/pkg/xray/resource_xray_settings.go b/pkg/xray/resource_xray_settings.go index 523d5706..28c000a4 100644 --- a/pkg/xray/resource_xray_settings.go +++ b/pkg/xray/resource_xray_settings.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" ) @@ -54,7 +55,7 @@ func packDBSyncTime(dbSyncTime DbSyncDailyUpdatesTime, d *schema.ResourceData) d func resourceXrayDbSyncTimeRead(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { dbSyncTime := DbSyncDailyUpdatesTime{} - resp, err := m.(sdk.ProvderMetadata).Client.R().SetResult(&dbSyncTime).Get("xray/api/v1/configuration/dbsync/time") + resp, err := m.(util.ProvderMetadata).Client.R().SetResult(&dbSyncTime).Get("xray/api/v1/configuration/dbsync/time") if err != nil { if resp != nil && resp.StatusCode() != http.StatusOK { log.Printf("Critical error. DB sync settings (%s) not found.", d.Id()) @@ -67,7 +68,7 @@ func resourceXrayDbSyncTimeRead(_ context.Context, d *schema.ResourceData, m int func resourceXrayDbSyncTimeUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { dbSyncTime := unpackDBSyncTime(d) - _, err := m.(sdk.ProvderMetadata).Client.R().SetBody(dbSyncTime).Put("xray/api/v1/configuration/dbsync/time") + _, err := m.(util.ProvderMetadata).Client.R().SetBody(dbSyncTime).Put("xray/api/v1/configuration/dbsync/time") if err != nil { return diag.FromErr(err) } diff --git a/pkg/xray/resource_xray_watch_test.go b/pkg/xray/resource_xray_watch_test.go index c89021c2..b73ca408 100644 --- a/pkg/xray/resource_xray_watch_test.go +++ b/pkg/xray/resource_xray_watch_test.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/client" "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" ) @@ -50,7 +51,7 @@ func TestAccWatch_allReposSinglePolicy(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, allReposSinglePolicyWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, allReposSinglePolicyWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -82,7 +83,7 @@ func TestAccWatch_allReposPathAntFilter(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, allReposPathAntFilterWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, allReposPathAntFilterWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -114,7 +115,7 @@ func TestAccWatch_allReposKvFilter(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, allReposKvFilterWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, allReposKvFilterWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -184,11 +185,11 @@ func TestAccWatch_allReposWithProjectKey(t *testing.T) { watch_recipients = ["{{ .watch_recipient_0 }}", "{{ .watch_recipient_1 }}"] }` - config := sdk.ExecuteTemplate(fqrn, template, testData) + config := util.ExecuteTemplate(fqrn, template, testData) updatedTestData := sdk.MergeMaps(testData) updatedTestData["description"] = "New description" - updatedConfig := sdk.ExecuteTemplate(fqrn, template, updatedTestData) + updatedConfig := util.ExecuteTemplate(fqrn, template, updatedTestData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -246,7 +247,7 @@ func TestAccWatch_allReposMultiplePolicies(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, allReposMultiplePoliciesWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, allReposMultiplePoliciesWatchTemplate, testData), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(fqrn, "name", testData["watch_name"]), resource.TestCheckResourceAttr(fqrn, "description", testData["description"]), @@ -306,7 +307,7 @@ func makeSingleRepositoryTestCase(repoType string, t *testing.T) (*testing.T, re ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, singleRepositoryWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, singleRepositoryWatchTemplate, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckTypeSetElemNestedAttrs(fqrn, "watch_resource.*.filter.*", map[string]string{ @@ -395,7 +396,7 @@ func TestAccWatch_singleRepositoryWithProjectKey(t *testing.T) { watch_recipients = ["{{ .watch_recipient_0 }}", "{{ .watch_recipient_1 }}"] }` - config := sdk.ExecuteTemplate(fqrn, template, testData) + config := util.ExecuteTemplate(fqrn, template, testData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -458,7 +459,7 @@ func TestAccWatch_singleRepoMimeTypeFilter(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, singleRepositoryWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, singleRepositoryWatchTemplate, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckTypeSetElemNestedAttrs(fqrn, "watch_resource.*.filter.*", map[string]string{ @@ -502,7 +503,7 @@ func TestAccWatch_singleRepoKvFilter(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, kvFilters, testData), + Config: util.ExecuteTemplate(fqrn, kvFilters, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckTypeSetElemNestedAttrs(fqrn, "watch_resource.*.kv_filter.*", map[string]string{ @@ -546,7 +547,7 @@ func TestAccWatch_repositoryMissingRepoType(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, singleRepositoryInvalidWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, singleRepositoryInvalidWatchTemplate, testData), ExpectError: regexp.MustCompile(`attribute 'repo_type' not set when 'watch_resource\.type' is set to 'repository'`), }, }, @@ -581,7 +582,7 @@ func TestAccWatch_multipleRepositories(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, multipleRepositoriesWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, multipleRepositoriesWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -628,7 +629,7 @@ func TestAccWatch_multipleRepositoriesPathAntPatterns(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, pathAntPatterns, testData), + Config: util.ExecuteTemplate(fqrn, pathAntPatterns, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckResourceAttr(fqrn, "watch_resource.0.type", testData["watch_type"]), @@ -681,7 +682,7 @@ func TestAccWatch_PathAntPatternsError(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, pathAntPatterns, testData), + Config: util.ExecuteTemplate(fqrn, pathAntPatterns, testData), ExpectError: regexp.MustCompile("attribute 'path_ant_filter' is set when 'watch_resource.type' is not set to 'repository' or 'all-repos'"), }, }, @@ -721,7 +722,7 @@ func TestAccWatch_multipleRepositoriesKvFilter(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, multipleRepositoriesKvFilter, testData), + Config: util.ExecuteTemplate(fqrn, multipleRepositoriesKvFilter, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckResourceAttr(fqrn, "watch_resource.0.type", testData["watch_type"]), @@ -776,7 +777,7 @@ func TestAccWatch_KvFilterError(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, kvFilters, testData), + Config: util.ExecuteTemplate(fqrn, kvFilters, testData), ExpectError: regexp.MustCompile("attribute 'kv_filter' is set when 'watch_resource.type' is not set to 'repository' or 'all-repos'"), }, }, @@ -804,7 +805,7 @@ func TestAccWatch_build(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, buildWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, buildWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -872,7 +873,7 @@ func TestAccWatch_buildWithProjectKey(t *testing.T) { } watch_recipients = ["{{ .watch_recipient_0 }}", "{{ .watch_recipient_1 }}"] }` - config := sdk.ExecuteTemplate(fqrn, template, testData) + config := util.ExecuteTemplate(fqrn, template, testData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -967,11 +968,11 @@ func TestAccWatch_allBuildsWithProjectKey(t *testing.T) { } watch_recipients = ["{{ .watch_recipient_0 }}", "{{ .watch_recipient_1 }}"] }` - config := sdk.ExecuteTemplate(fqrn, template, testData) + config := util.ExecuteTemplate(fqrn, template, testData) updatedTestData := sdk.MergeMaps(testData) updatedTestData["description"] = "New description" - updatedConfig := sdk.ExecuteTemplate(fqrn, template, updatedTestData) + updatedConfig := util.ExecuteTemplate(fqrn, template, updatedTestData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -1027,7 +1028,7 @@ func TestAccWatch_multipleBuilds(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, multipleBuildsWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, multipleBuildsWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -1056,7 +1057,7 @@ func TestAccWatch_allBuilds(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, allBuildsWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, allBuildsWatchTemplate, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckTypeSetElemAttr(fqrn, "watch_resource.*.ant_filter.*.exclude_patterns.*", "a*"), @@ -1092,7 +1093,7 @@ func TestAccWatch_invalidBuildFilter(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, invalidBuildsWatchFilterTemplate, testData), + Config: util.ExecuteTemplate(fqrn, invalidBuildsWatchFilterTemplate, testData), ExpectError: regexp.MustCompile(`attribute 'ant_filter' is set when 'watch_resource\.type' is not set to 'all-builds' or 'all-projects'`), }, }, @@ -1116,7 +1117,7 @@ func TestAccWatch_allProjects(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, allProjectsWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, allProjectsWatchTemplate, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckTypeSetElemAttr(fqrn, "watch_resource.*.ant_filter.*.exclude_patterns.*", "a*"), @@ -1172,7 +1173,7 @@ func TestAccWatch_singleProject(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, singleProjectWatchTemplate, testData), + Config: util.ExecuteTemplate(fqrn, singleProjectWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -1202,7 +1203,7 @@ func TestAccWatch_invalidProjectFilter(t *testing.T) { Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, invalidProjectWatchFilterTemplate, testData), + Config: util.ExecuteTemplate(fqrn, invalidProjectWatchFilterTemplate, testData), ExpectError: regexp.MustCompile(`attribute 'ant_filter' is set when 'watch_resource\.type' is not set to 'all-builds' or 'all-projects'`), }, }, diff --git a/pkg/xray/resource_xray_webhook.go b/pkg/xray/resource_xray_webhook.go index 3525c766..719d089d 100644 --- a/pkg/xray/resource_xray_webhook.go +++ b/pkg/xray/resource_xray_webhook.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/jfrog/terraform-provider-shared/util/sdk" + "github.com/jfrog/terraform-provider-shared/util" ) type Webhook struct { @@ -110,7 +110,7 @@ func resourceXrayWebhook() *schema.Resource { var resourceXrayWebhookRead = func(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { webhook := Webhook{} - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, "") + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, "") if err != nil { return diag.FromErr(err) } @@ -171,7 +171,7 @@ func resourceXrayWebhook() *schema.Resource { return diag.FromErr(err) } - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, "") + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, "") if err != nil { return diag.FromErr(err) } @@ -194,7 +194,7 @@ func resourceXrayWebhook() *schema.Resource { return diag.FromErr(err) } - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, "") + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, "") if err != nil { return diag.FromErr(err) } @@ -217,7 +217,7 @@ func resourceXrayWebhook() *schema.Resource { } var resourceXrayWebhookDelete = func(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, "") + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, "") if err != nil { return diag.FromErr(err) } diff --git a/pkg/xray/resource_xray_webhook_test.go b/pkg/xray/resource_xray_webhook_test.go index 16cbb9b6..49b4f00e 100644 --- a/pkg/xray/resource_xray_webhook_test.go +++ b/pkg/xray/resource_xray_webhook_test.go @@ -8,7 +8,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/testutil" - "github.com/jfrog/terraform-provider-shared/util/sdk" + "github.com/jfrog/terraform-provider-shared/util" ) func TestAccWebhook_full(t *testing.T) { @@ -43,7 +43,7 @@ func TestAccWebhook_full(t *testing.T) { "header2_value": "header2_value", } - config := sdk.ExecuteTemplate("TestAccWebhook_full", template, testData) + config := util.ExecuteTemplate("TestAccWebhook_full", template, testData) const updateTemplate = ` resource "xray_webhook" "{{ .name }}" { @@ -59,7 +59,7 @@ func TestAccWebhook_full(t *testing.T) { "url": url, "use_proxy": "false", } - updatedConfig := sdk.ExecuteTemplate("TestAccWebhook_full", updateTemplate, updatedTestData) + updatedConfig := util.ExecuteTemplate("TestAccWebhook_full", updateTemplate, updatedTestData) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -117,7 +117,7 @@ func TestAccWebhook_invalid_name(t *testing.T) { "url": url, } - config := sdk.ExecuteTemplate("TestAccWebhook_invalid_name", template, testData) + config := util.ExecuteTemplate("TestAccWebhook_invalid_name", template, testData) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -145,7 +145,7 @@ func TestAccWebhook_invalid_url(t *testing.T) { "name": resourceName, } - config := sdk.ExecuteTemplate("TestAccWebhook_invalid_name", template, testData) + config := util.ExecuteTemplate("TestAccWebhook_invalid_name", template, testData) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/pkg/xray/resource_xray_workers_count.go b/pkg/xray/resource_xray_workers_count.go index 84d41c88..baddafe4 100644 --- a/pkg/xray/resource_xray_workers_count.go +++ b/pkg/xray/resource_xray_workers_count.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" ) @@ -219,7 +220,7 @@ func resourceXrayWorkersCount() *schema.Resource { var resourceXrayWorkersCountRead = func(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { workersCount := WorkersCount{} - resp, err := m.(sdk.ProvderMetadata).Client.R(). + resp, err := m.(util.ProvderMetadata).Client.R(). SetResult(&workersCount). Get("xray/api/v1/configuration/workersCount") if err != nil { @@ -234,7 +235,7 @@ func resourceXrayWorkersCount() *schema.Resource { var resourceXrayWorkersCountUpdate = func(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { workersCount := unpackWorkersCount(d) - _, err := m.(sdk.ProvderMetadata).Client.R(). + _, err := m.(util.ProvderMetadata).Client.R(). SetBody(workersCount). Put("xray/api/v1/configuration/workersCount") diff --git a/pkg/xray/resource_xray_workers_count_test.go b/pkg/xray/resource_xray_workers_count_test.go index d8965b1a..584a027c 100644 --- a/pkg/xray/resource_xray_workers_count_test.go +++ b/pkg/xray/resource_xray_workers_count_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/testutil" - "github.com/jfrog/terraform-provider-shared/util/sdk" + "github.com/jfrog/terraform-provider-shared/util" ) func TestAccWorkersCount_create(t *testing.T) { @@ -15,7 +15,7 @@ func TestAccWorkersCount_create(t *testing.T) { params := map[string]interface{}{ "workersCountName": resourceName, } - workersCountConfig := sdk.ExecuteTemplate("TestAccWorkersCount_create", ` + workersCountConfig := util.ExecuteTemplate("TestAccWorkersCount_create", ` resource "xray_workers_count" "{{ .workersCountName }}" { index { new_content = 4 diff --git a/pkg/xray/util_test.go b/pkg/xray/util_test.go index a4e60a58..0099516a 100644 --- a/pkg/xray/util_test.go +++ b/pkg/xray/util_test.go @@ -11,7 +11,7 @@ import ( tf "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/jfrog/terraform-provider-shared/client" "github.com/jfrog/terraform-provider-shared/testutil" - "github.com/jfrog/terraform-provider-shared/util/sdk" + "github.com/jfrog/terraform-provider-shared/util" ) func checkPolicy(id string, request *resty.Request) (*resty.Response, error) { @@ -40,7 +40,7 @@ func verifyDeleted(id string, check CheckFun) func(*tf.State) error { } provider, _ := testAccProviders()["xray"]() provider.Configure(context.Background(), terraform.NewResourceConfigRaw(nil)) - c := provider.Meta().(sdk.ProvderMetadata).Client + c := provider.Meta().(util.ProvderMetadata).Client resp, err := check(rs.Primary.ID, c.R()) if err != nil { if resp != nil { diff --git a/pkg/xray/watches.go b/pkg/xray/watches.go index 7323d94c..829eaa69 100644 --- a/pkg/xray/watches.go +++ b/pkg/xray/watches.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/jfrog/terraform-provider-shared/util" "github.com/jfrog/terraform-provider-shared/util/sdk" "golang.org/x/exp/slices" ) @@ -401,7 +402,7 @@ func packWatch(ctx context.Context, watch Watch, d *schema.ResourceData) diag.Di func resourceXrayWatchCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { watch := unpackWatch(d) - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, watch.ProjectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, watch.ProjectKey) if err != nil { return diag.FromErr(err) } @@ -431,7 +432,7 @@ func resourceXrayWatchRead(ctx context.Context, d *schema.ResourceData, m interf watch := Watch{} projectKey := d.Get("project_key").(string) - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, projectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, projectKey) if err != nil { return diag.FromErr(err) } @@ -456,7 +457,7 @@ func resourceXrayWatchRead(ctx context.Context, d *schema.ResourceData, m interf func resourceXrayWatchUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { watch := unpackWatch(d) - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, watch.ProjectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, watch.ProjectKey) if err != nil { return diag.FromErr(err) } @@ -482,7 +483,7 @@ func resourceXrayWatchUpdate(ctx context.Context, d *schema.ResourceData, m inte func resourceXrayWatchDelete(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { watch := unpackWatch(d) - req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, watch.ProjectKey) + req, err := getRestyRequest(m.(util.ProvderMetadata).Client, watch.ProjectKey) if err != nil { return diag.FromErr(err) } From e72536490fb138e0ec89d991c3b49e6945b0bec3 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Wed, 6 Dec 2023 15:50:59 -0800 Subject: [PATCH 2/7] Add support for release bundle to watch type --- docs/resources/watch.md | 4 +- pkg/xray/resource_xray_watch.go | 22 +++- pkg/xray/resource_xray_watch_test.go | 170 ++++++++++++++++++++++++++- pkg/xray/watches.go | 4 +- 4 files changed, 190 insertions(+), 10 deletions(-) diff --git a/docs/resources/watch.md b/docs/resources/watch.md index 65d39f2c..0133f25d 100644 --- a/docs/resources/watch.md +++ b/docs/resources/watch.md @@ -387,7 +387,7 @@ Required: Required: -- `type` (String) Type of resource to be watched. Options: `all-repos`, `repository`, `all-builds`, `build`, `project`, `all-projects`. +- `type` (String) Type of resource to be watched. Options: repository, all-repos, build, all-builds, project, all-projects, releaseBundle, all-releaseBundles, releaseBundleV2, all-releaseBundlesV2. Optional: @@ -395,7 +395,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`, `package-type` and `mime-type` type. Works for `repository` and `all-repos` watch_resource.type (see [below for nested schema](#nestedblock--watch_resource--filter)) - `kv_filter` (Block Set) Filter for `property` type. Works for `repository` and `all-repos` watch_resource.type. (see [below for nested schema](#nestedblock--watch_resource--kv_filter)) -- `name` (String) The name of the build, repository or project. Xray indexing must be enabled on the repository or build +- `name` (String) The name of the build, repository, project, or release bundle. Xray indexing must be enabled on the repository, build, or release bundle. - `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`. diff --git a/pkg/xray/resource_xray_watch.go b/pkg/xray/resource_xray_watch.go index 8579bd51..f84519d3 100644 --- a/pkg/xray/resource_xray_watch.go +++ b/pkg/xray/resource_xray_watch.go @@ -1,11 +1,27 @@ package xray import ( + "fmt" + "strings" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" ) +var supportedResourceTypes = []string{ + "repository", + "all-repos", + "build", + "all-builds", + "project", + "all-projects", + "releaseBundle", + "all-releaseBundles", + "releaseBundleV2", + "all-releaseBundlesV2", +} + func resourceXrayWatch() *schema.Resource { return &schema.Resource{ CreateContext: resourceXrayWatchCreate, @@ -49,8 +65,8 @@ func resourceXrayWatch() *schema.Resource { "type": { Type: schema.TypeString, Required: true, - Description: "Type of resource to be watched. Options: `all-repos`, `repository`, `all-builds`, `build`, `project`, `all-projects`.", - ValidateDiagFunc: validator.StringInSlice(true, "all-repos", "repository", "all-builds", "build", "project", "all-projects"), + Description: fmt.Sprintf("Type of resource to be watched. Options: %s.", strings.Join(supportedResourceTypes, ", ")), + ValidateDiagFunc: validator.StringInSlice(true, supportedResourceTypes...), }, "bin_mgr_id": { Type: schema.TypeString, @@ -61,7 +77,7 @@ func resourceXrayWatch() *schema.Resource { "name": { Type: schema.TypeString, Optional: true, - Description: "The name of the build, repository or project. Xray indexing must be enabled on the repository or build", + Description: "The name of the build, repository, project, or release bundle. Xray indexing must be enabled on the repository, build, or release bundle.", }, "repo_type": { Type: schema.TypeString, diff --git a/pkg/xray/resource_xray_watch_test.go b/pkg/xray/resource_xray_watch_test.go index b73ca408..b69d9313 100644 --- a/pkg/xray/resource_xray_watch_test.go +++ b/pkg/xray/resource_xray_watch_test.go @@ -1094,7 +1094,7 @@ func TestAccWatch_invalidBuildFilter(t *testing.T) { Steps: []resource.TestStep{ { Config: util.ExecuteTemplate(fqrn, invalidBuildsWatchFilterTemplate, testData), - ExpectError: regexp.MustCompile(`attribute 'ant_filter' is set when 'watch_resource\.type' is not set to 'all-builds' or 'all-projects'`), + ExpectError: regexp.MustCompile(`attribute 'ant_filter' is set when 'watch_resource.type' is not set to 'all-builds', 'all-projects', 'all-releaseBundles', or 'all-releaseBundlesV2'`), }, }, }) @@ -1134,7 +1134,6 @@ func TestAccWatch_allProjects(t *testing.T) { }) } -//goland:noinspection GoErrorStringFormat func TestAccWatch_singleProject(t *testing.T) { _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") testData := sdk.MergeMaps(testDataWatch) @@ -1204,7 +1203,79 @@ func TestAccWatch_invalidProjectFilter(t *testing.T) { { Config: util.ExecuteTemplate(fqrn, invalidProjectWatchFilterTemplate, testData), - ExpectError: regexp.MustCompile(`attribute 'ant_filter' is set when 'watch_resource\.type' is not set to 'all-builds' or 'all-projects'`), + ExpectError: regexp.MustCompile(`attribute 'ant_filter' is set when 'watch_resource.type' is not set to 'all-builds', 'all-projects', 'all-releaseBundles', or 'all-releaseBundlesV2'`), + }, + }, + }) +} + +func TestAccWatch_allReleaseBundle(t *testing.T) { + for _, watchType := range []string{"all-releaseBundles", "all-releaseBundlesV2"} { + t.Run(watchType, func(t *testing.T) { + resource.Test(allReleaseBundleTestCase(watchType, t)) + }) + } +} + +func allReleaseBundleTestCase(watchType string, t *testing.T) (*testing.T, resource.TestCase) { + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) + + testData["resource_name"] = resourceName + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) + testData["watch_type"] = watchType + + return t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + CheckDestroy: verifyDeleted(fqrn, testCheckWatch), + ProviderFactories: testAccProviders(), + Steps: []resource.TestStep{ + { + Config: util.ExecuteTemplate(fqrn, allReleaseBundlesWatchTemplate, testData), + Check: resource.ComposeTestCheckFunc( + verifyXrayWatch(fqrn, testData), + resource.TestCheckTypeSetElemAttr(fqrn, "watch_resource.*.ant_filter.*.exclude_patterns.*", "a*"), + resource.TestCheckTypeSetElemAttr(fqrn, "watch_resource.*.ant_filter.*.exclude_patterns.*", "b*"), + resource.TestCheckTypeSetElemAttr(fqrn, "watch_resource.*.ant_filter.*.include_patterns.*", "ab*"), + ), + }, + { + ResourceName: fqrn, + ImportState: true, + ImportStateVerify: true, + }, + }, + } +} + +func TestAccWatch_singleReleaseBundle(t *testing.T) { + // NOTE: can't test release bundle V2 due to no API to add release bundle to Xray scan index, + // which is required before a watch with release bundle v2 can be created. + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) + + testData["resource_name"] = resourceName + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["watch_type"] = "releaseBundle" + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) + testData["release_bundle_name"] = fmt.Sprintf("test-release-bundle-%d", testutil.RandomInt()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + CheckDestroy: verifyDeleted(fqrn, testCheckWatch), + ProviderFactories: testAccProviders(), + Steps: []resource.TestStep{ + { + Config: util.ExecuteTemplate(fqrn, singleReleaseBundleWatchTemplate, testData), + Check: verifyXrayWatch(fqrn, testData), + }, + { + ResourceName: fqrn, + ImportState: true, + ImportStateVerify: true, }, }, }) @@ -2162,6 +2233,99 @@ resource "xray_watch" "{{ .resource_name }}" { watch_recipients = ["{{ .watch_recipient_0 }}", "{{ .watch_recipient_1 }}"] }` +const allReleaseBundlesWatchTemplate = `resource "xray_security_policy" "security" { + name = "{{ .policy_name_0 }}" + description = "Security policy description" + type = "security" + rule { + name = "rule-name-severity" + priority = 1 + criteria { + min_severity = "High" + } + actions { + webhooks = [] + mails = ["test@email.com"] + block_download { + unscanned = true + active = true + } + block_release_bundle_distribution = true + fail_build = true + notify_watch_recipients = true + notify_deployer = true + create_ticket_enabled = false + build_failure_grace_period_in_days = 5 + } + } +} + +resource "xray_watch" "{{ .resource_name }}" { + name = "{{ .watch_name }}" + description = "{{ .description }}" + active = {{ .active }} + + watch_resource { + type = "{{ .watch_type }}" + bin_mgr_id = "default" + ant_filter { + exclude_patterns = ["a*", "b*"] + include_patterns = ["ab*"] + } + } + assigned_policy { + name = xray_security_policy.security.name + type = "security" + } + watch_recipients = ["{{ .watch_recipient_0 }}", "{{ .watch_recipient_1 }}"] +}` + +const singleReleaseBundleWatchTemplate = `resource "xray_security_policy" "security" { + name = "{{ .policy_name_0 }}" + description = "Security policy description" + type = "security" + rule { + name = "rule-name-severity" + priority = 1 + criteria { + min_severity = "High" + } + actions { + webhooks = [] + mails = ["test@email.com"] + block_download { + unscanned = true + active = true + } + block_release_bundle_distribution = true + fail_build = true + notify_watch_recipients = true + notify_deployer = true + create_ticket_enabled = false + build_failure_grace_period_in_days = 5 + } + } +} + +resource "xray_watch" "{{ .resource_name }}" { + name = "{{ .watch_name }}" + description = "{{ .description }}" + active = {{ .active }} + + watch_resource { + type = "releaseBundle" + bin_mgr_id = "default" + name = "{{ .release_bundle_name }}" + } + + assigned_policy { + name = xray_security_policy.security.name + type = "security" + } + + watch_recipients = ["{{ .watch_recipient_0 }}", "{{ .watch_recipient_1 }}"] +}` + func verifyXrayWatch(fqrn string, testData map[string]string) resource.TestCheckFunc { return resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(fqrn, "name", testData["watch_name"]), diff --git a/pkg/xray/watches.go b/pkg/xray/watches.go index 829eaa69..906174ba 100644 --- a/pkg/xray/watches.go +++ b/pkg/xray/watches.go @@ -517,9 +517,9 @@ func watchResourceDiff(_ context.Context, diff *schema.ResourceDiff, v interface // validate type with filter and ant_filter antFilters := r["ant_filter"].(*schema.Set).List() - antPatternsResourceTypes := []string{"all-builds", "all-projects"} + antPatternsResourceTypes := []string{"all-builds", "all-projects", "all-releaseBundles", "all-releaseBundlesV2"} if !slices.Contains(antPatternsResourceTypes, resourceType) && len(antFilters) > 0 { - return fmt.Errorf("attribute 'ant_filter' is set when 'watch_resource.type' is not set to 'all-builds' or 'all-projects'") + return fmt.Errorf("attribute 'ant_filter' is set when 'watch_resource.type' is not set to 'all-builds', 'all-projects', 'all-releaseBundles', or 'all-releaseBundlesV2'") } repositoryResourceTypes := []string{"repository", "all-repos"} From 05deba8b6cd2254e641c5e47b8ae316a2bb4e769 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Wed, 6 Dec 2023 15:51:09 -0800 Subject: [PATCH 3/7] Update policy docs --- docs/resources/license_policy.md | 2 +- docs/resources/operational_risk_policy.md | 2 +- docs/resources/security_policy.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/resources/license_policy.md b/docs/resources/license_policy.md index 23def5e5..f5f157e8 100644 --- a/docs/resources/license_policy.md +++ b/docs/resources/license_policy.md @@ -95,7 +95,7 @@ resource "xray_license_policy" "banned_licenses" { ### Required - `name` (String) Name of the policy (must be unique) -- `rule` (Block List, Min: 1) A list of user-defined rules allowing you to trigger violations for specific vulnerability or license breaches by setting a license or security criteria, with a corresponding set of automatic actions according to your needs. Rules are processed according to the ascending order in which they are placed in the Rules list on the Policy. If a rule is met, the subsequent rules in the list will not be applied. (see [below for nested schema](#nestedblock--rule)) +- `rule` (Block Set, Min: 1) A list of user-defined rules allowing you to trigger violations for specific vulnerability or license breaches by setting a license or security criteria, with a corresponding set of automatic actions according to your needs. Rules are processed according to the ascending order in which they are placed in the Rules list on the Policy. If a rule is met, the subsequent rules in the list will not be applied. (see [below for nested schema](#nestedblock--rule)) - `type` (String) Type of the policy ### Optional diff --git a/docs/resources/operational_risk_policy.md b/docs/resources/operational_risk_policy.md index 2872fbdb..25f4b0bf 100644 --- a/docs/resources/operational_risk_policy.md +++ b/docs/resources/operational_risk_policy.md @@ -91,7 +91,7 @@ resource "xray_operational_risk_policy" "custom_criteria" { ### Required - `name` (String) Name of the policy (must be unique) -- `rule` (Block List, Min: 1) A list of user-defined rules allowing you to trigger violations for specific vulnerability or license breaches by setting a license or security criteria, with a corresponding set of automatic actions according to your needs. Rules are processed according to the ascending order in which they are placed in the Rules list on the Policy. If a rule is met, the subsequent rules in the list will not be applied. (see [below for nested schema](#nestedblock--rule)) +- `rule` (Block Set, Min: 1) A list of user-defined rules allowing you to trigger violations for specific vulnerability or license breaches by setting a license or security criteria, with a corresponding set of automatic actions according to your needs. Rules are processed according to the ascending order in which they are placed in the Rules list on the Policy. If a rule is met, the subsequent rules in the list will not be applied. (see [below for nested schema](#nestedblock--rule)) - `type` (String) Type of the policy ### Optional diff --git a/docs/resources/security_policy.md b/docs/resources/security_policy.md index 7b4e0ecb..cde950ef 100644 --- a/docs/resources/security_policy.md +++ b/docs/resources/security_policy.md @@ -125,7 +125,7 @@ resource "xray_security_policy" "malicious_package" { ### Required - `name` (String) Name of the policy (must be unique) -- `rule` (Block List, Min: 1) A list of user-defined rules allowing you to trigger violations for specific vulnerability or license breaches by setting a license or security criteria, with a corresponding set of automatic actions according to your needs. Rules are processed according to the ascending order in which they are placed in the Rules list on the Policy. If a rule is met, the subsequent rules in the list will not be applied. (see [below for nested schema](#nestedblock--rule)) +- `rule` (Block Set, Min: 1) A list of user-defined rules allowing you to trigger violations for specific vulnerability or license breaches by setting a license or security criteria, with a corresponding set of automatic actions according to your needs. Rules are processed according to the ascending order in which they are placed in the Rules list on the Policy. If a rule is met, the subsequent rules in the list will not be applied. (see [below for nested schema](#nestedblock--rule)) - `type` (String) Type of the policy ### Optional From 3a7ecd283aa73b32786b7d36bfebda23df8f6538 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Wed, 6 Dec 2023 15:51:19 -0800 Subject: [PATCH 4/7] Update GitHub templates --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index afb53fb3..92fc0b33 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -3,7 +3,7 @@ name: Bug report about: Create a report to help us improve title: '' labels: bug -assignees: danielmkn +assignees: alexhung --- diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7d..ab97ab2a 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -3,7 +3,7 @@ name: Feature request about: Suggest an idea for this project title: '' labels: '' -assignees: '' +assignees: alexhung --- From efecd319227c7b5007c687f2021646ed712020bb Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Wed, 6 Dec 2023 15:52:27 -0800 Subject: [PATCH 5/7] Update CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab4df783..ab4bb345 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.1.0 (December 7, 2023) + +IMPROVEMENTS: + +* resource/xray_watch: add support for watch type `releaseBundle`, `all-releaseBundles`, `releaseBundleV2`, and `all-releaseBundlesV2`. PR: [#153](https://github.com/jfrog/terraform-provider-xray/pull/153) Issue: [#150](https://github.com/jfrog/terraform-provider-xray/issues/159) + ## 2.0.5 (November 30, 2023). Tested on Artifactory 7.71.5 and Xray 3.86.3 BUG FIXES: From 6ec0042702ae853354ffef5980c1707897e14a54 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Thu, 7 Dec 2023 09:42:45 -0800 Subject: [PATCH 6/7] Fix broken test due to package upgrade --- pkg/xray/resource_xray_ignore_rule_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/xray/resource_xray_ignore_rule_test.go b/pkg/xray/resource_xray_ignore_rule_test.go index 654cfb4f..98586104 100644 --- a/pkg/xray/resource_xray_ignore_rule_test.go +++ b/pkg/xray/resource_xray_ignore_rule_test.go @@ -132,7 +132,7 @@ func TestAccIgnoreRule_invalid_operational_risk(t *testing.T) { Steps: []resource.TestStep{ { Config: config, - ExpectError: regexp.MustCompile(`expected operational_risk to be one of \[any\], got invalid-risk`), + ExpectError: regexp.MustCompile(`expected operational_risk to be one of \["any"\], got invalid-risk`), }, }, }) From 06386926c984fe5abe2451dd32cf28a7af128937 Mon Sep 17 00:00:00 2001 From: JFrog CI Date: Thu, 7 Dec 2023 18:24:49 +0000 Subject: [PATCH 7/7] JFrog Pipelines - Add Artifactory and Xray versions to CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab4bb345..e771922d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 2.1.0 (December 7, 2023) +## 2.1.0 (December 7, 2023). Tested on Artifactory 7.71.5 and Xray 3.86.4 IMPROVEMENTS: