From ea469e1ec925f3651b8aa4b2c8658bc943e3393d Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Mon, 11 Mar 2024 14:33:01 -0700 Subject: [PATCH 1/7] Update to use latest shared lib --- go.mod | 68 +++--- go.sum | 213 ++++++++++++------ pkg/project/membership.go | 9 +- pkg/project/membership_test.go | 14 +- pkg/project/repo.go | 7 +- pkg/project/repo_test.go | 16 +- .../resource_project_environment_test.go | 8 +- pkg/project/resource_project_group.go | 5 +- pkg/project/resource_project_group_test.go | 6 +- pkg/project/resource_project_role.go | 5 +- pkg/project/resource_project_role_test.go | 8 +- pkg/project/resource_project_test.go | 67 +++--- pkg/project/resource_project_user.go | 5 +- pkg/project/resource_project_user_test.go | 10 +- pkg/project/role.go | 9 +- pkg/project/role_test.go | 8 +- pkg/project/util.go | 4 +- 17 files changed, 268 insertions(+), 194 deletions(-) diff --git a/go.mod b/go.mod index 323ceb20..fe26c964 100644 --- a/go.mod +++ b/go.mod @@ -4,51 +4,52 @@ module github.com/jfrog/terraform-provider-project // replace github.com/jfrog/terraform-provider-shared => ../terraform-provider-shared require ( - github.com/go-resty/resty/v2 v2.7.0 + github.com/go-resty/resty/v2 v2.11.0 github.com/hashicorp/terraform-plugin-docs v0.16.0 github.com/hashicorp/terraform-plugin-log v0.9.0 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.28.0 - github.com/jfrog/terraform-provider-shared v1.14.0 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 + github.com/jfrog/terraform-provider-shared v1.22.0 golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 ) 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/Masterminds/semver/v3 v3.2.0 // indirect + github.com/Masterminds/sprig/v3 v3.2.3 // indirect + github.com/ProtonMail/go-crypto v1.1.0-alpha.0 // indirect github.com/agext/levenshtein v1.2.3 // 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.7 // indirect - github.com/fatih/color v1.15.0 // indirect + github.com/fatih/color v1.16.0 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/go-cmp v0.5.9 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect 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-hclog v1.6.2 // 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.6.0 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.6.0 // 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.3 // indirect + github.com/hashicorp/hcl/v2 v2.20.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.18.1 // 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-exec v0.20.0 // indirect + github.com/hashicorp/terraform-json v0.21.0 // indirect + github.com/hashicorp/terraform-plugin-go v0.22.1 // indirect + github.com/hashicorp/terraform-plugin-testing v1.7.0 // indirect + github.com/hashicorp/terraform-registry-address v0.2.3 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect - github.com/huandu/xstrings v1.3.2 // indirect - github.com/imdario/mergo v0.3.13 // indirect + github.com/huandu/xstrings v1.3.3 // indirect + github.com/imdario/mergo v0.3.15 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/cli v1.1.5 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect @@ -62,21 +63,24 @@ require ( github.com/spf13/cast v1.5.0 // indirect github.com/stretchr/testify v1.8.1 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect - github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect + github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.13.2 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.15.0 // indirect + github.com/zclconf/go-cty v1.14.3 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/mod v0.15.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.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/protobuf v1.31.0 // indirect + golang.org/x/tools v0.13.0 // indirect + google.golang.org/appengine v1.6.8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect + google.golang.org/grpc v1.62.1 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ldap.v2 v2.5.1 // indirect ) -go 1.18 +go 1.21 + +toolchain go1.21.5 diff --git a/go.sum b/go.sum index ac73f697..c8f7a857 100644 --- a/go.sum +++ b/go.sum @@ -1,56 +1,69 @@ +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= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= +github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= 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/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/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= +github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= +github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= +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 v1.1.0-alpha.0 h1:nHGfwXmFvJrSR9xu8qL7BkO4DqTHXE9N5vPhgY2I+j0= +github.com/ProtonMail/go-crypto v1.1.0-alpha.0/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/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/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= -github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= -github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= -github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= -github.com/go-git/go-git/v5 v5.6.1 h1:q4ZRqQl4pR/ZJHc1L5CFjGA1a10u76aV1iC+nh+bHsk= -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/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= +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.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= +github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= +github.com/go-resty/resty/v2 v2.11.0 h1:i7jMfNOJYMp69lq7qozJP+bjgzfAzeOhuGlyDrqxT/8= +github.com/go-resty/resty/v2 v2.11.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A= 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= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 h1:f0n1xnMSmBLzVfsMMvriDyA75NB/oBgILX2GcHXIQzY= github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75/go.mod h1:g2644b03hfBX9Ov0ZBDgXXens4rxSxmqFBbhvKv2yVA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -63,60 +76,69 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= -github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-hclog v1.6.2 h1:NOtoftovWkDheyUM/8JW3QMiXyxJK3uHRK7wV04nD2I= +github.com/hashicorp/go-hclog v1.6.2/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= 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.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= +github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= 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.3 h1:yE/r1yJvWbtrJ0STwScgEnCanb0U9v7zp0Gbkmcoxqs= +github.com/hashicorp/hc-install v0.6.3/go.mod h1:KamGdbodYzlufbWh4r9NRo8y6GLHWZP2GBtdnms1Ln0= +github.com/hashicorp/hcl/v2 v2.20.0 h1:l++cRs/5jQOiKVvqXZm/P1ZEfVXJmvLS9WSVxkaeTb4= +github.com/hashicorp/hcl/v2 v2.20.0/go.mod h1:WmcD/Ym72MDOOx5F62Ly+leloeu6H7m0pG7VBiU6pQk= 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-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA= -github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o= +github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8JyYF3vpnuEo= +github.com/hashicorp/terraform-exec v0.20.0/go.mod h1:ckKGkJWbsNqFKV1itgMnE0hY9IYf1HoiekpuN0eWoDw= +github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRyRNd+zTI05U= +github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk= github.com/hashicorp/terraform-plugin-docs v0.16.0 h1:UmxFr3AScl6Wged84jndJIfFccGyBZn52KtMNsS12dI= github.com/hashicorp/terraform-plugin-docs v0.16.0/go.mod h1:M3ZrlKBJAbPMtNOPwHicGi1c+hZUh7/g0ifT/z7TVfA= -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.22.1 h1:iTS7WHNVrn7uhe3cojtvWWn83cm2Z6ryIUDTRO0EV7w= +github.com/hashicorp/terraform-plugin-go v0.22.1/go.mod h1:qrjnqRghvQ6KnDbB12XeZ4FluclYwptntoWCr9QaXTI= 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.28.0 h1:gY4SG34ANc6ZSeWEKC9hDTChY0ZiN+Myon17fSA0Xgc= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.28.0/go.mod h1:deXEw/iJXtJxNV9d1c/OVJrvL7Zh0a++v7rzokW6wVY= -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.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A= +github.com/hashicorp/terraform-plugin-testing v1.7.0 h1:I6aeCyZ30z4NiI3tzyDoO6fS7YxP5xSL1ceOon3gTe8= +github.com/hashicorp/terraform-plugin-testing v1.7.0/go.mod h1:sbAreCleJNOCz+y5vVHV8EJkIWZKi/t4ndKiUjM9vao= +github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= +github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= 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.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -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/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4= +github.com/huandu/xstrings v1.3.3/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/jfrog/terraform-provider-shared v1.14.0 h1:C9EGwZKLAtzts543zpXANjYYwM3/pX64H7oMbhimA8g= -github.com/jfrog/terraform-provider-shared v1.14.0/go.mod h1:n6855hIUDhypnXsJl8UrstVFkcnL2uW4FLLr3cKGXjU= -github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= +github.com/jfrog/terraform-provider-shared v1.22.0 h1:6nmAltCTz/dvPDprK4iYFB9huwiJDiTHWOkOoVqQTgg= +github.com/jfrog/terraform-provider-shared v1.22.0/go.mod h1:rIiQMiefaHAlsh+vSCX+7W4tilJcqgQZLGwlHRqLMSg= +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= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= @@ -126,8 +148,8 @@ github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng= github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= @@ -145,19 +167,23 @@ github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= +github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 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.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= +github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= 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= @@ -176,65 +202,102 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= -github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= +github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= 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/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/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zclconf/go-cty v1.14.3 h1:1JXy1XroaGrzZuG6X9dt7HL6s9AwbY+l4UNL8o5B6ho= +github.com/zclconf/go-cty v1.14.3/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.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ= golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +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.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= 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.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +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.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= 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/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 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= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.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.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 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.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= 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.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +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.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 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/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +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/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= +google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= +google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= 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= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d h1:TxyelI5cVkbREznMhfzycHdkp5cLA7DpE+GKjSslYhM= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -244,9 +307,9 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/ldap.v2 v2.5.1 h1:wiu0okdNfjlBzg6UWvd1Hn8Y+Ux17/u/4nlk4CQr6tU= gopkg.in/ldap.v2 v2.5.1/go.mod h1:oI0cpe/D7HRtBQl8aTg+ZmzFUAvu4lsv3eLXMLGFxWk= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= 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/project/membership.go b/pkg/project/membership.go index 323e29c6..c4ee60ee 100644 --- a/pkg/project/membership.go +++ b/pkg/project/membership.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) const projectMembershipsUrl = projectUrl + "/{membershipType}" @@ -34,7 +35,7 @@ type Membership struct { Members []Member } -func getMembers(d *util.ResourceData, membershipKey string) []Member { +func getMembers(d *sdk.ResourceData, membershipKey string) []Member { var members []Member if v, ok := d.GetOk(membershipKey); ok { @@ -48,7 +49,7 @@ func getMembers(d *util.ResourceData, membershipKey string) []Member { member := Member{ Name: id["name"].(string), - Roles: util.CastToStringArr(id["roles"].(*schema.Set).List()), + Roles: sdk.CastToStringArr(id["roles"].(*schema.Set).List()), } members = append(members, member) } @@ -58,7 +59,7 @@ func getMembers(d *util.ResourceData, membershipKey string) []Member { } var unpackMembers = func(data *schema.ResourceData, membershipKey string) Membership { - d := &util.ResourceData{ResourceData: data} + d := &sdk.ResourceData{ResourceData: data} membership := Membership{ Members: getMembers(d, membershipKey), } @@ -69,7 +70,7 @@ var unpackMembers = func(data *schema.ResourceData, membershipKey string) Member var packMembers = func(ctx context.Context, d *schema.ResourceData, membershipKey string, members []Member) []error { tflog.Debug(ctx, "packMembership") - setValue := util.MkLens(d) + setValue := sdk.MkLens(d) var projectMembers []interface{} diff --git a/pkg/project/membership_test.go b/pkg/project/membership_test.go index bc564858..758060a0 100644 --- a/pkg/project/membership_test.go +++ b/pkg/project/membership_test.go @@ -7,7 +7,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" + "github.com/jfrog/terraform-provider-shared/util" ) func TestAccProject_membership(t *testing.T) { @@ -31,7 +31,7 @@ func TestAccProject_membership(t *testing.T) { "contributorRole": contributorRole, } - initialConfig := test.ExecuteTemplate("TestAccProjectMember", ` + initialConfig := util.ExecuteTemplate("TestAccProjectMember", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -51,7 +51,7 @@ func TestAccProject_membership(t *testing.T) { } `, params) - addMembersConfig := test.ExecuteTemplate("TestAccProjectMember", ` + addMembersConfig := util.ExecuteTemplate("TestAccProjectMember", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -76,7 +76,7 @@ func TestAccProject_membership(t *testing.T) { } `, params) - noMemberConfig := test.ExecuteTemplate("TestAccProjectMember", ` + noMemberConfig := util.ExecuteTemplate("TestAccProjectMember", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -172,7 +172,7 @@ func TestAccProject_group(t *testing.T) { "contributorRole": contributorRole, } - initialConfig := test.ExecuteTemplate("TestAccProjectGroup", ` + initialConfig := util.ExecuteTemplate("TestAccProjectGroup", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -192,7 +192,7 @@ func TestAccProject_group(t *testing.T) { } `, params) - addGroupConfig := test.ExecuteTemplate("TestAccProjectGroup", ` + addGroupConfig := util.ExecuteTemplate("TestAccProjectGroup", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -217,7 +217,7 @@ func TestAccProject_group(t *testing.T) { } `, params) - noGroupConfig := test.ExecuteTemplate("TestAccProjectGroup", ` + noGroupConfig := util.ExecuteTemplate("TestAccProjectGroup", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" diff --git a/pkg/project/repo.go b/pkg/project/repo.go index b0011a9e..c758d5f8 100644 --- a/pkg/project/repo.go +++ b/pkg/project/repo.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) type RepoKey string @@ -22,12 +23,12 @@ func (r RepoKey) Equals(other Equatable) bool { } var unpackRepos = func(data *schema.ResourceData) []RepoKey { - d := &util.ResourceData{ResourceData: data} + d := &sdk.ResourceData{ResourceData: data} var repoKeys []RepoKey if v, ok := d.GetOk("repos"); ok { - for _, key := range util.CastToStringArr(v.(*schema.Set).List()) { + for _, key := range sdk.CastToStringArr(v.(*schema.Set).List()) { repoKeys = append(repoKeys, RepoKey(key)) } } @@ -39,7 +40,7 @@ var packRepos = func(ctx context.Context, d *schema.ResourceData, repoKeys []Rep tflog.Debug(ctx, "packRepos") tflog.Trace(ctx, fmt.Sprintf("repos: %+v\n", repoKeys)) - setValue := util.MkLens(d) + setValue := sdk.MkLens(d) errors := setValue("repos", repoKeys) diff --git a/pkg/project/repo_test.go b/pkg/project/repo_test.go index 36e64b41..e0fa84a6 100644 --- a/pkg/project/repo_test.go +++ b/pkg/project/repo_test.go @@ -8,7 +8,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" + "github.com/jfrog/terraform-provider-shared/util" ) func TestAccProject_repo(t *testing.T) { @@ -26,7 +26,7 @@ func TestAccProject_repo(t *testing.T) { "repo2": repo2, } - initialConfig := test.ExecuteTemplate("TestAccProjectRepo", ` + initialConfig := util.ExecuteTemplate("TestAccProjectRepo", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -41,7 +41,7 @@ func TestAccProject_repo(t *testing.T) { } `, params) - addRepoConfig := test.ExecuteTemplate("TestAccProjectRepo", ` + addRepoConfig := util.ExecuteTemplate("TestAccProjectRepo", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -56,7 +56,7 @@ func TestAccProject_repo(t *testing.T) { } `, params) - noReposConfig := test.ExecuteTemplate("TestAccProjectRepo", ` + noReposConfig := util.ExecuteTemplate("TestAccProjectRepo", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -160,7 +160,7 @@ func TestAccProject_repoAssignMultipleRepos(t *testing.T) { "repos": randomRepoNames, } - initialConfig := test.ExecuteTemplate("TestAccProjectRepo", ` + initialConfig := util.ExecuteTemplate("TestAccProjectRepo", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -173,7 +173,7 @@ func TestAccProject_repoAssignMultipleRepos(t *testing.T) { } `, params) - addRepoConfig := test.ExecuteTemplate("TestAccProjectRepo", ` + addRepoConfig := util.ExecuteTemplate("TestAccProjectRepo", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -187,7 +187,7 @@ func TestAccProject_repoAssignMultipleRepos(t *testing.T) { } `, params) - noReposConfig := test.ExecuteTemplate("TestAccProjectRepo", ` + noReposConfig := util.ExecuteTemplate("TestAccProjectRepo", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -261,7 +261,7 @@ func TestAccProject_repoUnassignNonexistantRepo(t *testing.T) { "repo": repo, } - initialConfig := test.ExecuteTemplate("TestAccProjectRepoUnassignNonexistantRepo", ` + initialConfig := util.ExecuteTemplate("TestAccProjectRepoUnassignNonexistantRepo", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" diff --git a/pkg/project/resource_project_environment_test.go b/pkg/project/resource_project_environment_test.go index 9178ce46..f8f91423 100644 --- a/pkg/project/resource_project_environment_test.go +++ b/pkg/project/resource_project_environment_test.go @@ -8,7 +8,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" + "github.com/jfrog/terraform-provider-shared/util" "golang.org/x/exp/slices" ) @@ -40,7 +40,7 @@ func TestAccProjectEnvironment(t *testing.T) { } ` - enviroment := test.ExecuteTemplate("TestAccProjectEnvironment", template, params) + enviroment := util.ExecuteTemplate("TestAccProjectEnvironment", template, params) updateParams := map[string]any{ "env_id": name, @@ -48,7 +48,7 @@ func TestAccProjectEnvironment(t *testing.T) { "project_key": projectKey, } - enviromentUpdated := test.ExecuteTemplate("TestAccProjectEnvironment", template, updateParams) + enviromentUpdated := util.ExecuteTemplate("TestAccProjectEnvironment", template, updateParams) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -109,7 +109,7 @@ func TestAccProjectEnvironment_invalid_length(t *testing.T) { } ` - enviroment := test.ExecuteTemplate("TestAccProjectEnvironment", template, params) + enviroment := util.ExecuteTemplate("TestAccProjectEnvironment", template, params) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/pkg/project/resource_project_group.go b/pkg/project/resource_project_group.go index 3cd11277..ec625bff 100644 --- a/pkg/project/resource_project_group.go +++ b/pkg/project/resource_project_group.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/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" ) @@ -52,12 +53,12 @@ func projectGroupResource() *schema.Resource { return ProjectGroup{ ProjectKey: d.Get("project_key").(string), Name: d.Get("name").(string), - Roles: util.CastToStringArr(d.Get("roles").(*schema.Set).List()), + Roles: sdk.CastToStringArr(d.Get("roles").(*schema.Set).List()), } } var packProjectGroup = func(_ context.Context, data *schema.ResourceData, m ProjectGroup) diag.Diagnostics { - setValue := util.MkLens(data) + setValue := sdk.MkLens(data) setValue("name", m.Name) setValue("project_key", m.ProjectKey) diff --git a/pkg/project/resource_project_group_test.go b/pkg/project/resource_project_group_test.go index 81b594cf..2187e3a8 100644 --- a/pkg/project/resource_project_group_test.go +++ b/pkg/project/resource_project_group_test.go @@ -7,7 +7,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" + "github.com/jfrog/terraform-provider-shared/util" ) func TestAccProjectGroup(t *testing.T) { @@ -53,7 +53,7 @@ func TestAccProjectGroup(t *testing.T) { } ` - config := test.ExecuteTemplate("TestAccProjectGroup", template, params) + config := util.ExecuteTemplate("TestAccProjectGroup", template, params) updateParams := map[string]interface{}{ "project_name": params["project_name"], @@ -62,7 +62,7 @@ func TestAccProjectGroup(t *testing.T) { "roles": `["Developer"]`, } - configUpdated := test.ExecuteTemplate("TestAccProjectGroup", template, updateParams) + configUpdated := util.ExecuteTemplate("TestAccProjectGroup", template, updateParams) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/pkg/project/resource_project_role.go b/pkg/project/resource_project_role.go index 892c939c..c8106345 100644 --- a/pkg/project/resource_project_role.go +++ b/pkg/project/resource_project_role.go @@ -10,6 +10,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/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" ) @@ -112,7 +113,7 @@ func projectRoleResource() *schema.Resource { } var packRole = func(_ context.Context, data *schema.ResourceData, role Role, projectKey string) diag.Diagnostics { - setValue := util.MkLens(data) + setValue := sdk.MkLens(data) setValue("name", role.Name) setValue("type", role.Type) @@ -147,7 +148,7 @@ func projectRoleResource() *schema.Resource { } var unpackRole = func(data *schema.ResourceData) Role { - d := &util.ResourceData{ResourceData: data} + d := &sdk.ResourceData{ResourceData: data} return Role{ Name: d.GetString("name", false), diff --git a/pkg/project/resource_project_role_test.go b/pkg/project/resource_project_role_test.go index 193303ce..4138faa7 100644 --- a/pkg/project/resource_project_role_test.go +++ b/pkg/project/resource_project_role_test.go @@ -7,7 +7,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" + "github.com/jfrog/terraform-provider-shared/util" ) func TestAccProjectRole_full(t *testing.T) { @@ -54,8 +54,8 @@ func TestAccProjectRole_full(t *testing.T) { "action": "ANNOTATE_REPOSITORY", } - config := test.ExecuteTemplate("TestAccProjectRole", template, testData) - updatedConfig := test.ExecuteTemplate("TestAccProjectRole", template, testUpdatedData) + config := util.ExecuteTemplate("TestAccProjectRole", template, testData) + updatedConfig := util.ExecuteTemplate("TestAccProjectRole", template, testUpdatedData) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -129,7 +129,7 @@ func TestAccProjectRole_conflict_with_project(t *testing.T) { "action": "READ_REPOSITORY", } - config := test.ExecuteTemplate("TestAccProjectRole", template, testData) + config := util.ExecuteTemplate("TestAccProjectRole", template, testData) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/pkg/project/resource_project_test.go b/pkg/project/resource_project_test.go index 55f319fe..ac3e6cde 100644 --- a/pkg/project/resource_project_test.go +++ b/pkg/project/resource_project_test.go @@ -9,7 +9,8 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" + "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util" ) func verifyProject(id string, request *resty.Request) (*resty.Response, error) { @@ -31,15 +32,15 @@ func makeInvalidProjectKeyTestCase(invalidProjectKey string, t *testing.T) (*tes params := map[string]interface{}{ "max_storage_in_gibibytes": getRandomMaxStorageSize(), - "block_deployments_on_limit": test.RandBool(), - "email_notification": test.RandBool(), - "manage_members": test.RandBool(), - "manage_resources": test.RandBool(), - "index_resources": test.RandBool(), + "block_deployments_on_limit": testutil.RandBool(), + "email_notification": testutil.RandBool(), + "manage_members": testutil.RandBool(), + "manage_resources": testutil.RandBool(), + "index_resources": testutil.RandBool(), "name": name, "project_key": invalidProjectKey, //strings.ToLower(randSeq(20)), } - project := test.ExecuteTemplate("TestAccProjects", ` + project := util.ExecuteTemplate("TestAccProjects", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -99,15 +100,15 @@ func TestAccProjectInvalidProjectKey(t *testing.T) { func testProjectConfig(name, key string) string { params := map[string]interface{}{ "max_storage_in_gibibytes": getRandomMaxStorageSize(), - "block_deployments_on_limit": test.RandBool(), - "email_notification": test.RandBool(), - "manage_members": test.RandBool(), - "manage_resources": test.RandBool(), - "index_resources": test.RandBool(), + "block_deployments_on_limit": testutil.RandBool(), + "email_notification": testutil.RandBool(), + "manage_members": testutil.RandBool(), + "manage_resources": testutil.RandBool(), + "index_resources": testutil.RandBool(), "name": name, "project_key": key, } - return test.ExecuteTemplate("TestAccProjects", ` + return util.ExecuteTemplate("TestAccProjects", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -160,15 +161,15 @@ func makeInvalidMaxStorageTestCase(invalidMaxStorage int64, errorRegex string, t params := map[string]interface{}{ "max_storage_in_gibibytes": invalidMaxStorage, - "block_deployments_on_limit": test.RandBool(), - "email_notification": test.RandBool(), - "manage_members": test.RandBool(), - "manage_resources": test.RandBool(), - "index_resources": test.RandBool(), + "block_deployments_on_limit": testutil.RandBool(), + "email_notification": testutil.RandBool(), + "manage_members": testutil.RandBool(), + "manage_resources": testutil.RandBool(), + "index_resources": testutil.RandBool(), "name": name, "project_key": strings.ToLower(randSeq(20)), } - project := test.ExecuteTemplate("TestAccProjects", ` + project := util.ExecuteTemplate("TestAccProjects", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -262,11 +263,11 @@ func TestAccProject_full(t *testing.T) { params := map[string]interface{}{ "max_storage_in_gibibytes": getRandomMaxStorageSize(), - "block_deployments_on_limit": test.RandBool(), - "email_notification": test.RandBool(), - "manage_members": test.RandBool(), - "manage_resources": test.RandBool(), - "index_resources": test.RandBool(), + "block_deployments_on_limit": testutil.RandBool(), + "email_notification": testutil.RandBool(), + "manage_members": testutil.RandBool(), + "manage_resources": testutil.RandBool(), + "index_resources": testutil.RandBool(), "name": name, "project_key": strings.ToLower(randSeq(6)), "username1": username1, @@ -378,7 +379,7 @@ func TestAccProject_full(t *testing.T) { } ` - project := test.ExecuteTemplate("TestAccProjects", template, params) + project := util.ExecuteTemplate("TestAccProjects", template, params) updateParams := map[string]interface{}{ "max_storage_in_gibibytes": params["max_storage_in_gibibytes"], @@ -398,7 +399,7 @@ func TestAccProject_full(t *testing.T) { "repo1": params["repo1"], "repo2": params["repo2"], } - projectUpdated := test.ExecuteTemplate("TestAccProjects", template, updateParams) + projectUpdated := util.ExecuteTemplate("TestAccProjects", template, updateParams) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -475,11 +476,11 @@ func TestAccProject_migrate_schema(t *testing.T) { params := map[string]interface{}{ "max_storage_in_gibibytes": getRandomMaxStorageSize(), - "block_deployments_on_limit": test.RandBool(), - "email_notification": test.RandBool(), - "manage_members": test.RandBool(), - "manage_resources": test.RandBool(), - "index_resources": test.RandBool(), + "block_deployments_on_limit": testutil.RandBool(), + "email_notification": testutil.RandBool(), + "manage_members": testutil.RandBool(), + "manage_resources": testutil.RandBool(), + "index_resources": testutil.RandBool(), "name": name, "project_key": strings.ToLower(randSeq(6)), } @@ -516,7 +517,7 @@ func TestAccProject_migrate_schema(t *testing.T) { } ` - config := test.ExecuteTemplate("TestAccProject", template, params) + config := util.ExecuteTemplate("TestAccProject", template, params) updatedTemplate := ` resource "project" "{{ .name }}" { @@ -544,7 +545,7 @@ func TestAccProject_migrate_schema(t *testing.T) { "name": params["name"], "project_key": params["project_key"], } - updatedConfig := test.ExecuteTemplate("TestAccProject", updatedTemplate, updateParams) + updatedConfig := util.ExecuteTemplate("TestAccProject", updatedTemplate, updateParams) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/pkg/project/resource_project_user.go b/pkg/project/resource_project_user.go index 76c70550..9ab3d187 100644 --- a/pkg/project/resource_project_user.go +++ b/pkg/project/resource_project_user.go @@ -10,6 +10,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/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" ) @@ -57,7 +58,7 @@ func projectUserResource() *schema.Resource { } var packProjectUser = func(_ context.Context, data *schema.ResourceData, m ProjectUser) diag.Diagnostics { - setValue := util.MkLens(data) + setValue := sdk.MkLens(data) setValue("name", m.Name) setValue("project_key", m.ProjectKey) @@ -75,7 +76,7 @@ func projectUserResource() *schema.Resource { return ProjectUser{ ProjectKey: d.Get("project_key").(string), Name: d.Get("name").(string), - Roles: util.CastToStringArr(d.Get("roles").(*schema.Set).List()), + Roles: sdk.CastToStringArr(d.Get("roles").(*schema.Set).List()), IgnoreMissingUser: d.Get("ignore_missing_user").(bool), } } diff --git a/pkg/project/resource_project_user_test.go b/pkg/project/resource_project_user_test.go index 9abd65c4..c4b5e77f 100644 --- a/pkg/project/resource_project_user_test.go +++ b/pkg/project/resource_project_user_test.go @@ -8,7 +8,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" + "github.com/jfrog/terraform-provider-shared/util" ) func TestAccProjectUser(t *testing.T) { @@ -59,7 +59,7 @@ func TestAccProjectUser(t *testing.T) { } ` - config := test.ExecuteTemplate("TestAccProjectUser", template, params) + config := util.ExecuteTemplate("TestAccProjectUser", template, params) updateParams := map[string]interface{}{ "project_name": params["project_name"], @@ -69,7 +69,7 @@ func TestAccProjectUser(t *testing.T) { "roles": `["Developer"]`, } - configUpdated := test.ExecuteTemplate("TestAccProjectUser", template, updateParams) + configUpdated := util.ExecuteTemplate("TestAccProjectUser", template, updateParams) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -154,7 +154,7 @@ func TestAccProjectUser_missing_user_fails(t *testing.T) { } ` - config := test.ExecuteTemplate("TestAccProjectUser", template, params) + config := util.ExecuteTemplate("TestAccProjectUser", template, params) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, ProviderFactories: testAccProviders(), @@ -209,7 +209,7 @@ func TestAccProjectMember_missing_user_ignored(t *testing.T) { } ` - config := test.ExecuteTemplate("TestAccProjectUser", template, params) + config := util.ExecuteTemplate("TestAccProjectUser", template, params) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, CheckDestroy: verifyDeleted(resourceName, func(id string, request *resty.Request) (*resty.Response, error) { diff --git a/pkg/project/role.go b/pkg/project/role.go index 1fc69c1c..5c91b98f 100644 --- a/pkg/project/role.go +++ b/pkg/project/role.go @@ -7,10 +7,11 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) var unpackRoles = func(data *schema.ResourceData) []Role { - d := &util.ResourceData{ResourceData: data} + d := &sdk.ResourceData{ResourceData: data} var roles []Role @@ -27,8 +28,8 @@ var unpackRoles = func(data *schema.ResourceData) []Role { Name: id["name"].(string), Description: id["description"].(string), Type: id["type"].(string), - Environments: util.CastToStringArr(id["environments"].(*schema.Set).List()), - Actions: util.CastToStringArr(id["actions"].(*schema.Set).List()), + Environments: sdk.CastToStringArr(id["environments"].(*schema.Set).List()), + Actions: sdk.CastToStringArr(id["actions"].(*schema.Set).List()), } roles = append(roles, role) } @@ -40,7 +41,7 @@ var unpackRoles = func(data *schema.ResourceData) []Role { var packRoles = func(ctx context.Context, d *schema.ResourceData, roles []Role) []error { tflog.Debug(ctx, "packRoles") - setValue := util.MkLens(d) + setValue := sdk.MkLens(d) var projectRoles []interface{} diff --git a/pkg/project/role_test.go b/pkg/project/role_test.go index ed398598..e76032b4 100644 --- a/pkg/project/role_test.go +++ b/pkg/project/role_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" + "github.com/jfrog/terraform-provider-shared/util" ) func TestAccProject_role(t *testing.T) { @@ -26,7 +26,7 @@ func TestAccProject_role(t *testing.T) { "role3": role3, } - initialConfig := test.ExecuteTemplate("TestAccProjectRole", ` + initialConfig := util.ExecuteTemplate("TestAccProjectRole", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -57,7 +57,7 @@ func TestAccProject_role(t *testing.T) { } `, params) - addRoleConfig := test.ExecuteTemplate("TestAccProjectRole", ` + addRoleConfig := util.ExecuteTemplate("TestAccProjectRole", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" @@ -96,7 +96,7 @@ func TestAccProject_role(t *testing.T) { } `, params) - noUserConfig := test.ExecuteTemplate("TestAccProjectRole", ` + noUserConfig := util.ExecuteTemplate("TestAccProjectRole", ` resource "project" "{{ .name }}" { key = "{{ .project_key }}" display_name = "{{ .name }}" diff --git a/pkg/project/util.go b/pkg/project/util.go index 711f0b14..2a83eff8 100644 --- a/pkg/project/util.go +++ b/pkg/project/util.go @@ -5,7 +5,7 @@ import ( "regexp" "github.com/go-resty/resty/v2" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) func BytesToGibibytes(bytes int64) int { @@ -25,7 +25,7 @@ func GibibytesToBytes(bytes int) int64 { } type Equatable interface { - util.Identifiable + sdk.Identifiable Equals(other Equatable) bool } From 2bb7239bcb144dbd8b0bd4765a489b92f139df07 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Mon, 11 Mar 2024 15:38:02 -0700 Subject: [PATCH 2/7] Migrate to new terraform testing package And newer style of testing setup. Similar to artifactory provider SDKv2 --- pkg/project/membership_test.go | 6 +-- pkg/project/provider.go | 8 ++-- pkg/project/provider_test.go | 13 +------ pkg/project/repo_test.go | 8 ++-- .../resource_project_environment_test.go | 6 +-- pkg/project/resource_project_group_test.go | 4 +- pkg/project/resource_project_role_test.go | 6 +-- pkg/project/resource_project_test.go | 16 ++++---- pkg/project/resource_project_user_test.go | 8 ++-- pkg/project/role_test.go | 4 +- pkg/project/util_test.go | 39 ++++++++++++++----- 11 files changed, 65 insertions(+), 53 deletions(-) diff --git a/pkg/project/membership_test.go b/pkg/project/membership_test.go index 758060a0..1467262d 100644 --- a/pkg/project/membership_test.go +++ b/pkg/project/membership_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/util" ) @@ -104,7 +104,7 @@ func TestAccProject_membership(t *testing.T) { return resp, err }), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: initialConfig, @@ -245,7 +245,7 @@ func TestAccProject_group(t *testing.T) { return resp, err }), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: initialConfig, diff --git a/pkg/project/provider.go b/pkg/project/provider.go index c82478e0..62a67f1c 100644 --- a/pkg/project/provider.go +++ b/pkg/project/provider.go @@ -10,6 +10,7 @@ import ( "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" ) var Version = "0.0.1" @@ -45,7 +46,7 @@ func Provider() *schema.Provider { }, }, - ResourcesMap: util.AddTelemetry( + ResourcesMap: sdk.AddTelemetry( productId, map[string]*schema.Resource{ "project": projectResource(), @@ -53,6 +54,7 @@ func Provider() *schema.Provider { "project_role": projectRoleResource(), "project_user": projectUserResource(), "project_group": projectGroupResource(), + "project_repository": projectRepositoryResource(), }, ), } @@ -80,8 +82,8 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, terraformVer if err != nil { return nil, diag.FromErr(err) } - accessToken := d.Get("access_token").(string) + accessToken := d.Get("access_token").(string) restyBase, err = client.AddAuth(restyBase, "", accessToken) if err != nil { return nil, diag.FromErr(err) @@ -89,7 +91,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, terraformVer checkLicense := d.Get("check_license").(bool) if checkLicense { - licenseErr := util.CheckArtifactoryLicense(restyBase, "Enterprise", "Commercial", "Edge") + licenseErr := sdk.CheckArtifactoryLicense(restyBase, "Enterprise", "Commercial", "Edge") if licenseErr != nil { return nil, licenseErr } diff --git a/pkg/project/provider_test.go b/pkg/project/provider_test.go index d0541618..7470ab7b 100644 --- a/pkg/project/provider_test.go +++ b/pkg/project/provider_test.go @@ -1,16 +1,14 @@ package project import ( - "context" "os" "testing" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/jfrog/terraform-provider-shared/client" ) -func TestProvider(t *testing.T) { +func TestProvider_validate(t *testing.T) { if err := Provider().InternalValidate(); err != nil { t.Fatalf("err: %s", err) } @@ -46,12 +44,3 @@ func getTestResty(t *testing.T) *resty.Client { return restyClient } - -func testAccPreCheck(t *testing.T) { - ctx := context.Background() - provider, _ := testAccProviders()["project"]() - err := provider.Configure(ctx, terraform.NewResourceConfigRaw(nil)) - if err != nil { - t.Fatal(err) - } -} diff --git a/pkg/project/repo_test.go b/pkg/project/repo_test.go index e0fa84a6..fbf5e0df 100644 --- a/pkg/project/repo_test.go +++ b/pkg/project/repo_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/util" ) @@ -82,7 +82,7 @@ func TestAccProject_repo(t *testing.T) { return resp, err }), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: initialConfig, @@ -209,7 +209,7 @@ func TestAccProject_repoAssignMultipleRepos(t *testing.T) { resp, err := verifyProject(id, request) return resp, err }), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: initialConfig, @@ -282,7 +282,7 @@ func TestAccProject_repoUnassignNonexistantRepo(t *testing.T) { createTestRepo(t, repo) }, CheckDestroy: verifyDeleted(resourceName, verifyProject), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: initialConfig, diff --git a/pkg/project/resource_project_environment_test.go b/pkg/project/resource_project_environment_test.go index f8f91423..c255451b 100644 --- a/pkg/project/resource_project_environment_test.go +++ b/pkg/project/resource_project_environment_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/util" "golang.org/x/exp/slices" ) @@ -56,7 +56,7 @@ func TestAccProjectEnvironment(t *testing.T) { resp, err := verifyEnvironment(projectKey, id, request) return resp, err }), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: enviroment, @@ -117,7 +117,7 @@ func TestAccProjectEnvironment_invalid_length(t *testing.T) { resp, err := verifyEnvironment(projectKey, id, request) return resp, err }), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: enviroment, diff --git a/pkg/project/resource_project_group_test.go b/pkg/project/resource_project_group_test.go index 2187e3a8..8934db04 100644 --- a/pkg/project/resource_project_group_test.go +++ b/pkg/project/resource_project_group_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/util" ) @@ -69,7 +69,7 @@ func TestAccProjectGroup(t *testing.T) { CheckDestroy: verifyDeleted(resourceName, func(id string, request *resty.Request) (*resty.Response, error) { return verifyProjectGroup(group, projectKey, request) }), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, ExternalProviders: map[string]resource.ExternalProvider{ "artifactory": { Source: "jfrog/artifactory", diff --git a/pkg/project/resource_project_role_test.go b/pkg/project/resource_project_role_test.go index 4138faa7..503e49fc 100644 --- a/pkg/project/resource_project_role_test.go +++ b/pkg/project/resource_project_role_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/util" ) @@ -62,7 +62,7 @@ func TestAccProjectRole_full(t *testing.T) { CheckDestroy: verifyDeleted(resourceName, func(id string, request *resty.Request) (*resty.Response, error) { return verifyRole(id, projectKey, request) }), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: config, @@ -136,7 +136,7 @@ func TestAccProjectRole_conflict_with_project(t *testing.T) { CheckDestroy: verifyDeleted(resourceName, func(id string, request *resty.Request) (*resty.Response, error) { return verifyRole(id, projectKey, request) }), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: config, diff --git a/pkg/project/resource_project_test.go b/pkg/project/resource_project_test.go index ac3e6cde..cf128e35 100644 --- a/pkg/project/resource_project_test.go +++ b/pkg/project/resource_project_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/testutil" "github.com/jfrog/terraform-provider-shared/util" ) @@ -59,7 +59,7 @@ func makeInvalidProjectKeyTestCase(invalidProjectKey string, t *testing.T) (*tes return t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, CheckDestroy: verifyDeleted(resourceName, verifyProject), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: project, @@ -188,7 +188,7 @@ func makeInvalidMaxStorageTestCase(invalidMaxStorage int64, errorRegex string, t return t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, CheckDestroy: verifyDeleted(resourceName, verifyProject), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: project, @@ -206,7 +206,7 @@ func TestAccProjectInvalidDisplayName(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, CheckDestroy: verifyDeleted(resourceName, verifyProject), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: project, @@ -228,7 +228,7 @@ func TestAccProjectUpdateKey(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, CheckDestroy: verifyDeleted(resourceName, verifyProject), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: config, @@ -404,7 +404,7 @@ func TestAccProject_full(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, CheckDestroy: verifyDeleted(resourceName, verifyProject), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, ExternalProviders: map[string]resource.ExternalProvider{ "artifactory": { Source: "jfrog/artifactory", @@ -574,7 +574,7 @@ func TestAccProject_migrate_schema(t *testing.T) { ), }, { - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Config: config, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "key", params["project_key"].(string)), @@ -590,7 +590,7 @@ func TestAccProject_migrate_schema(t *testing.T) { ), }, { - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Config: updatedConfig, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "key", params["project_key"].(string)), diff --git a/pkg/project/resource_project_user_test.go b/pkg/project/resource_project_user_test.go index c4b5e77f..c87b72f8 100644 --- a/pkg/project/resource_project_user_test.go +++ b/pkg/project/resource_project_user_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/util" ) @@ -76,7 +76,7 @@ func TestAccProjectUser(t *testing.T) { CheckDestroy: verifyDeleted(resourceName, func(id string, request *resty.Request) (*resty.Response, error) { return verifyProjectUser(username, projectKey, request) }), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, ExternalProviders: map[string]resource.ExternalProvider{ "artifactory": { Source: "jfrog/artifactory", @@ -157,7 +157,7 @@ func TestAccProjectUser_missing_user_fails(t *testing.T) { config := util.ExecuteTemplate("TestAccProjectUser", template, params) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: config, @@ -215,7 +215,7 @@ func TestAccProjectMember_missing_user_ignored(t *testing.T) { CheckDestroy: verifyDeleted(resourceName, func(id string, request *resty.Request) (*resty.Response, error) { return verifyProjectUser(username, projectKey, request) }), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: config, diff --git a/pkg/project/role_test.go b/pkg/project/role_test.go index e76032b4..16d5c79c 100644 --- a/pkg/project/role_test.go +++ b/pkg/project/role_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/util" ) @@ -116,7 +116,7 @@ func TestAccProject_role(t *testing.T) { testAccPreCheck(t) }, CheckDestroy: verifyDeleted(resourceName, verifyProject), - ProviderFactories: testAccProviders(), + ProviderFactories: ProviderFactories, Steps: []resource.TestStep{ { Config: initialConfig, diff --git a/pkg/project/util_test.go b/pkg/project/util_test.go index 63e3343c..bab95e42 100644 --- a/pkg/project/util_test.go +++ b/pkg/project/util_test.go @@ -5,22 +5,45 @@ import ( "fmt" "math/rand" "net/http" + "sync" "testing" "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + terraform2 "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/jfrog/terraform-provider-shared/util" ) -func testAccProviders() map[string]func() (*schema.Provider, error) { - return map[string]func() (*schema.Provider, error){ - "project": func() (*schema.Provider, error) { - return Provider(), nil - }, +// Provider PreCheck(t) must be called before using this provider instance. +var TestProvider *schema.Provider + +var ProviderFactories map[string]func() (*schema.Provider, error) + +// testAccProviderConfigure ensures Provider is only configured once +// +// The PreCheck(t) function is invoked for every test and this prevents +// extraneous reconfiguration to the same values each time. However, this does +// not prevent reconfiguration that may happen should the address of +// Provider be errantly reused in ProviderFactories. +var testAccProviderConfigure sync.Once + +func init() { + TestProvider = Provider() + ProviderFactories = map[string]func() (*schema.Provider, error){ + "project": func() (*schema.Provider, error) { return TestProvider, nil }, } } +func testAccPreCheck(t *testing.T) { + testAccProviderConfigure.Do(func() { + err := TestProvider.Configure(context.Background(), terraform2.NewResourceConfigRaw(nil)) + if err != nil && err.HasError() { + t.Fatal(err) + } + }) +} + type CheckFun func(id string, request *resty.Request) (*resty.Response, error) func verifyDeleted(id string, check CheckFun) func(*terraform.State) error { @@ -31,9 +54,7 @@ func verifyDeleted(id string, check CheckFun) func(*terraform.State) error { if !ok { return fmt.Errorf("error: Resource id [%s] not found", id) } - provider, _ := testAccProviders()["project"]() - provider.Configure(context.Background(), terraform.NewResourceConfigRaw(nil)) - client := provider.Meta().(util.ProvderMetadata).Client + client := TestProvider.Meta().(util.ProvderMetadata).Client resp, err := check(rs.Primary.ID, client.R()) if err != nil { if resp != nil { From 24995d7bb19f2e5c81cdd5a360306943c800b94d Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Mon, 11 Mar 2024 15:39:40 -0700 Subject: [PATCH 3/7] Add project_repository resource To allow management of repository-project relationship independent from project resource --- docs/resources/project.md | 1 + docs/resources/repository.md | 40 +++++ .../resources/project_repository/import.sh | 1 + .../resources/project_repository/resource.tf | 4 + pkg/project/resource_project.go | 69 +++++++-- pkg/project/resource_project_repository.go | 139 ++++++++++++++++++ .../resource_project_repository_test.go | 112 ++++++++++++++ 7 files changed, 351 insertions(+), 15 deletions(-) create mode 100644 docs/resources/repository.md create mode 100644 examples/resources/project_repository/import.sh create mode 100644 examples/resources/project_repository/resource.tf create mode 100644 pkg/project/resource_project_repository.go create mode 100644 pkg/project/resource_project_repository_test.go diff --git a/docs/resources/project.md b/docs/resources/project.md index 2f1085b8..feee1d66 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -115,6 +115,7 @@ lifecycle { ``` - `role` (Block Set, Deprecated) Project role. Element has one to one mapping with the [JFrog Project Roles API](https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-AddaNewRole) (see [below for nested schema](#nestedblock--role)) - `use_project_group_resource` (Boolean) When set to true, this resource will ignore the `group` attributes and allow users to be managed by `project_group` resource instead. Default to `true`. +- `use_project_repository_resource` (Boolean) When set to true, this resource will ignore the `repos` attributes and allow repository to be managed by `project_repository` resource instead. Default to `true`. - `use_project_role_resource` (Boolean) When set to true, this resource will ignore the `roles` attributes and allow roles to be managed by `project_role` resource instead. Default to `true`. - `use_project_user_resource` (Boolean) When set to true, this resource will ignore the `member` attributes and allow users to be managed by `project_user` resource instead. Default to `true`. diff --git a/docs/resources/repository.md b/docs/resources/repository.md new file mode 100644 index 00000000..61752b33 --- /dev/null +++ b/docs/resources/repository.md @@ -0,0 +1,40 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "project_repository Resource - terraform-provider-project" +subcategory: "" +description: |- + Assign a repository to a project. Requires a user assigned with the 'Administer the Platform' role or Project Admin permissions if admin_privileges.manage_resoures is enabled. +--- + +# project_repository (Resource) + +Assign a repository to a project. Requires a user assigned with the 'Administer the Platform' role or Project Admin permissions if `admin_privileges.manage_resoures` is enabled. + +## Example Usage + +```terraform +resource "project_repository" "myprojectrepo" { + project_key = "myproj" + key = "my-generic-local" +} +``` + + +## Schema + +### Required + +- `key` (String) The key of the repository. +- `project_key` (String) The key of the project to which the repository should be assigned to. + +### Read-Only + +- `id` (String) The ID of this resource. + +## Import + +Import is supported using the following syntax: + +```shell +terraform import project_repository.myprojectrepo project_key:repository_key +``` diff --git a/examples/resources/project_repository/import.sh b/examples/resources/project_repository/import.sh new file mode 100644 index 00000000..6ae5de3f --- /dev/null +++ b/examples/resources/project_repository/import.sh @@ -0,0 +1 @@ +terraform import project_repository.myprojectrepo project_key:repository_key \ No newline at end of file diff --git a/examples/resources/project_repository/resource.tf b/examples/resources/project_repository/resource.tf new file mode 100644 index 00000000..bd10b18c --- /dev/null +++ b/examples/resources/project_repository/resource.tf @@ -0,0 +1,4 @@ +resource "project_repository" "myprojectrepo" { + project_key = "myproj" + key = "my-generic-local" +} \ No newline at end of file diff --git a/pkg/project/resource_project.go b/pkg/project/resource_project.go index d697a36d..ccd4d795 100644 --- a/pkg/project/resource_project.go +++ b/pkg/project/resource_project.go @@ -14,6 +14,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/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" ) @@ -220,7 +221,7 @@ func projectResource() *schema.Resource { }, } - var projectSchemaV2 = util.MergeMaps( + var projectSchemaV2 = sdk.MergeMaps( projectSchema, map[string]*schema.Schema{ "role": { @@ -272,7 +273,7 @@ func projectResource() *schema.Resource { }, ) - var projectSchemaV3 = util.MergeMaps( + var projectSchemaV3 = sdk.MergeMaps( projectSchemaV2, map[string]*schema.Schema{ "member": { @@ -334,8 +335,20 @@ func projectResource() *schema.Resource { }, ) + var projectSchemaV4 = sdk.MergeMaps( + projectSchemaV3, + map[string]*schema.Schema{ + "use_project_repository_resource": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "When set to true, this resource will ignore the `repos` attributes and allow repository to be managed by `project_repository` resource instead. Default to `true`.", + }, + }, + ) + var unpackProject = func(data *schema.ResourceData) (Project, Membership, Membership, []Role, []RepoKey, error) { - d := &util.ResourceData{ResourceData: data} + d := &sdk.ResourceData{ResourceData: data} project := Project{ Key: d.GetString("key", false), @@ -372,7 +385,7 @@ func projectResource() *schema.Resource { var packProject = func(ctx context.Context, d *schema.ResourceData, project Project, users []Member, groups []Member, roles []Role, repos []RepoKey) diag.Diagnostics { var errors []error - setValue := util.MkLens(d) + setValue := sdk.MkLens(d) setValue("key", project.Key) setValue("display_name", project.DisplayName) @@ -449,9 +462,13 @@ func projectResource() *schema.Resource { } } - repos, err := readRepos(ctx, data.Id(), m) - if err != nil { - return diag.FromErr(err) + repos := []RepoKey{} + useProjectRepositoryResource := data.Get("use_project_repository_resource").(bool) + if !useProjectRepositoryResource { + repos, err = readRepos(ctx, data.Id(), m) + if err != nil { + return diag.FromErr(err) + } } return packProject(ctx, data, project, users, groups, roles, repos) @@ -500,9 +517,12 @@ func projectResource() *schema.Resource { } } - _, err = updateRepos(ctx, data.Id(), repos, m) - if err != nil { - return diag.FromErr(err) + useProjectRepositoryResource := data.Get("use_project_repository_resource").(bool) + if !useProjectRepositoryResource { + _, err = updateRepos(ctx, data.Id(), repos, m) + if err != nil { + return diag.FromErr(err) + } } return readProject(ctx, data, m) @@ -552,9 +572,12 @@ func projectResource() *schema.Resource { } } - _, err = updateRepos(ctx, data.Id(), repos, m) - if err != nil { - return diag.FromErr(err) + useProjectRepositoryResource := data.Get("use_project_repository_resource").(bool) + if !useProjectRepositoryResource { + _, err = updateRepos(ctx, data.Id(), repos, m) + if err != nil { + return diag.FromErr(err) + } } return readProject(ctx, data, m) @@ -608,6 +631,12 @@ func projectResource() *schema.Resource { } } + var resourceV3 = func() *schema.Resource { + return &schema.Resource{ + Schema: projectSchemaV3, + } + } + var resourceStateUpgradeV1 = func(ctx context.Context, rawState map[string]any, meta any) (map[string]any, error) { // set use_project_role_resource to false for existing state so the resource will continue // using `roles` attribute until explicitly set to true @@ -622,6 +651,11 @@ func projectResource() *schema.Resource { return rawState, nil } + var resourceStateUpgradeV3 = func(ctx context.Context, rawState map[string]any, meta any) (map[string]any, error) { + rawState["use_project_repository_resource"] = false + return rawState, nil + } + return &schema.Resource{ CreateContext: createProject, ReadContext: readProject, @@ -632,8 +666,8 @@ func projectResource() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: projectSchemaV3, - SchemaVersion: 3, + Schema: projectSchemaV4, + SchemaVersion: 4, StateUpgraders: []schema.StateUpgrader{ { Type: resourceV1().CoreConfigSchema().ImpliedType(), @@ -645,6 +679,11 @@ func projectResource() *schema.Resource { Upgrade: resourceStateUpgradeV2, Version: 2, }, + { + Type: resourceV3().CoreConfigSchema().ImpliedType(), + Upgrade: resourceStateUpgradeV3, + Version: 3, + }, }, Description: "Provides an Artifactory project resource. This can be used to create and manage Artifactory project, maintain users/groups/roles/repos.\n\n## Repository Configuration\n\nAfter the project configuration is applied, the repository's attributes `project_key` and `project_environments` would be updated with the project's data. This will generate a state drift in the next Terraform plan/apply for the repository resource. To avoid this, apply `lifecycle.ignore_changes`:\n```hcl\nresource \"artifactory_local_maven_repository\" \"my_maven_releases\" {\n\tkey = \"my-maven-releases\"\n\t...\n\n\tlifecycle {\n\t\tignore_changes = [\n\t\t\tproject_environments,\n\t\t\tproject_key\n\t\t]\n\t}\n}\n```\n~>We strongly recommend using the 'repos' attribute to manage the list of repositories. See below for additional details.", } diff --git a/pkg/project/resource_project_repository.go b/pkg/project/resource_project_repository.go new file mode 100644 index 00000000..f4a8d732 --- /dev/null +++ b/pkg/project/resource_project_repository.go @@ -0,0 +1,139 @@ +package project + +import ( + "context" + "fmt" + "net/http" + "strings" + + "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" +) + +type Repository struct { + Key string `json:"key"` + ProjectKey string `json:"projectKey"` +} + +func projectRepositoryResource() *schema.Resource { + var projectRepositorySchema = map[string]*schema.Schema{ + "project_key": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateDiagFunc: validator.ProjectKey, + Description: "The key of the project to which the repository should be assigned to.", + }, + "key": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateDiagFunc: validator.RepoKey, + Description: "The key of the repository.", + }, + } + + var readProjectRepository = func(ctx context.Context, data *schema.ResourceData, m interface{}) diag.Diagnostics { + repoKey := data.Get("key").(string) + + var repo Repository + + resp, err := m.(util.ProvderMetadata).Client.R(). + SetResult(&repo). + SetPathParam("key", repoKey). + Get("/artifactory/api/repositories/{key}") + + if err != nil { + if resp != nil && (resp.StatusCode() == http.StatusBadRequest || resp.StatusCode() == http.StatusNotFound) { + data.SetId("") + return nil + } + return diag.FromErr(err) + } + + if repo.ProjectKey == "" { + tflog.Info(ctx, "no project_key for repo", map[string]any{"repoKey": repoKey}) + data.SetId("") + return nil + } + + setValue := sdk.MkLens(data) + + setValue("project_key", repo.ProjectKey) + errors := setValue("key", repo.Key) + + if len(errors) > 0 { + return diag.Errorf("failed to pack project repository %q", errors) + } + + return nil + } + + var createProjectRepository = func(ctx context.Context, data *schema.ResourceData, m interface{}) diag.Diagnostics { + projectKey := data.Get("project_key").(string) + repoKey := data.Get("key").(string) + + _, err := m.(util.ProvderMetadata).Client.R(). + SetPathParams(map[string]string{ + "projectKey": projectKey, + "repoKey": repoKey, + }). + Put("/access/api/v1/projects/_/attach/repositories/{repoKey}/{projectKey}?force=true") + + if err != nil { + return diag.FromErr(err) + } + + data.SetId(fmt.Sprintf("%s-%s", projectKey, repoKey)) + + return readProjectRepository(ctx, data, m) + } + + var deleteProjectRepository = func(ctx context.Context, data *schema.ResourceData, m interface{}) diag.Diagnostics { + repoKey := data.Get("key").(string) + + _, err := m.(util.ProvderMetadata).Client.R(). + SetPathParam("repoKey", repoKey). + Delete("/access/api/v1/projects/_/attach/repositories/{repoKey}") + + if err != nil { + return diag.FromErr(err) + } + + data.SetId("") + + return nil + } + + var importForProjectKeyRepositoryKey = func(d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) { + parts := strings.SplitN(d.Id(), ":", 2) + if len(parts) != 2 || parts[0] == "" || parts[1] == "" { + return nil, fmt.Errorf("unexpected format of ID (%s), expected project_key:repository_key", d.Id()) + } + + d.Set("project_key", parts[0]) + d.Set("key", parts[1]) + d.SetId(fmt.Sprintf("%s-%s", parts[0], parts[1])) + + return []*schema.ResourceData{d}, nil + } + + return &schema.Resource{ + CreateContext: createProjectRepository, + ReadContext: readProjectRepository, + DeleteContext: deleteProjectRepository, + + Importer: &schema.ResourceImporter{ + State: importForProjectKeyRepositoryKey, + }, + + Schema: projectRepositorySchema, + SchemaVersion: 1, + + Description: "Assign a repository to a project. Requires a user assigned with the 'Administer the Platform' role or Project Admin permissions if `admin_privileges.manage_resoures` is enabled.", + } +} diff --git a/pkg/project/resource_project_repository_test.go b/pkg/project/resource_project_repository_test.go new file mode 100644 index 00000000..9b4589db --- /dev/null +++ b/pkg/project/resource_project_repository_test.go @@ -0,0 +1,112 @@ +package project + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util" +) + +func TestAccProjectRepository(t *testing.T) { + projectKey := strings.ToLower(randSeq(10)) + projectName := fmt.Sprintf("tftestprojects%s", projectKey) + + repoKey1 := fmt.Sprintf("repo%d", testutil.RandomInt()) + repoKey2 := fmt.Sprintf("repo%d", testutil.RandomInt()) + + resourceName1 := fmt.Sprintf("project_repository.%s-%s", projectKey, repoKey1) + resourceName2 := fmt.Sprintf("project_repository.%s-%s", projectKey, repoKey2) + + params := map[string]interface{}{ + "project_name": projectName, + "project_key": projectKey, + "repo_key": repoKey1, + "repo_key_1": repoKey1, + "repo_key_2": repoKey2, + } + + template := ` + resource "artifactory_local_generic_repository" "{{ .repo_key_1 }}" { + key = "{{ .repo_key_1 }}" + + lifecycle { + ignore_changes = ["project_key"] + } + } + + resource "artifactory_local_generic_repository" "{{ .repo_key_2 }}" { + key = "{{ .repo_key_2 }}" + + lifecycle { + ignore_changes = ["project_key"] + } + } + + resource "project" "{{ .project_name }}" { + key = "{{ .project_key }}" + display_name = "{{ .project_name }}" + description = "test description" + admin_privileges { + manage_members = true + manage_resources = true + index_resources = true + } + max_storage_in_gibibytes = 1 + block_deployments_on_limit = true + email_notification = false + } + + resource "project_repository" "{{ .project_key }}-{{ .repo_key }}" { + project_key = project.{{ .project_name }}.key + key = artifactory_local_generic_repository.{{ .repo_key }}.key + } + ` + + config := util.ExecuteTemplate("TestAccProjectRepository", template, params) + + updateParams := map[string]interface{}{ + "project_name": params["project_name"], + "project_key": params["project_key"], + "repo_key": params["repo_key_2"], + "repo_key_1": params["repo_key_1"], + "repo_key_2": params["repo_key_2"], + } + + configUpdated := util.ExecuteTemplate("TestAccProjectRepository", template, updateParams) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: ProviderFactories, + ExternalProviders: map[string]resource.ExternalProvider{ + "artifactory": { + Source: "jfrog/artifactory", + VersionConstraint: "10.1.4", + }, + }, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(resourceName1, "project_key", params["project_key"].(string)), + resource.TestCheckResourceAttr(resourceName1, "key", params["repo_key"].(string)), + ), + }, + { + Config: configUpdated, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(resourceName2, "project_key", updateParams["project_key"].(string)), + resource.TestCheckResourceAttr(resourceName2, "key", updateParams["repo_key"].(string)), + ), + }, + { + ResourceName: resourceName2, + ImportStateId: fmt.Sprintf("%s:%s", projectKey, updateParams["repo_key"]), + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} From affe5c20dbc69e910c4aa5c8e2f113f7922900d3 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Tue, 12 Mar 2024 10:14:49 -0700 Subject: [PATCH 4/7] Fix tests --- pkg/project/membership_test.go | 26 +++++++++---- pkg/project/repo.go | 4 +- pkg/project/repo_test.go | 39 +++++++++++++++---- pkg/project/resource_project.go | 10 +++++ .../resource_project_environment_test.go | 4 +- pkg/project/resource_project_test.go | 18 ++++++--- pkg/project/role.go | 4 +- pkg/project/role_test.go | 13 +++++-- pkg/project/util_test.go | 19 ++++----- 9 files changed, 95 insertions(+), 42 deletions(-) diff --git a/pkg/project/membership_test.go b/pkg/project/membership_test.go index 1467262d..2ce1032a 100644 --- a/pkg/project/membership_test.go +++ b/pkg/project/membership_test.go @@ -135,10 +135,15 @@ func TestAccProject_membership(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"use_project_role_resource", "use_project_user_resource", "use_project_group_resource"}, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "use_project_role_resource", + "use_project_user_resource", + "use_project_group_resource", + "use_project_repository_resource", + }, }, { Config: noMemberConfig, @@ -276,10 +281,15 @@ func TestAccProject_group(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"use_project_role_resource", "use_project_user_resource", "use_project_group_resource"}, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "use_project_role_resource", + "use_project_user_resource", + "use_project_group_resource", + "use_project_repository_resource", + }, }, { Config: noGroupConfig, diff --git a/pkg/project/repo.go b/pkg/project/repo.go index c758d5f8..cfba0e4f 100644 --- a/pkg/project/repo.go +++ b/pkg/project/repo.go @@ -23,11 +23,9 @@ func (r RepoKey) Equals(other Equatable) bool { } var unpackRepos = func(data *schema.ResourceData) []RepoKey { - d := &sdk.ResourceData{ResourceData: data} - var repoKeys []RepoKey - if v, ok := d.GetOk("repos"); ok { + if v, ok := data.GetOk("repos"); ok { for _, key := range sdk.CastToStringArr(v.(*schema.Set).List()) { repoKeys = append(repoKeys, RepoKey(key)) } diff --git a/pkg/project/repo_test.go b/pkg/project/repo_test.go index fbf5e0df..87922470 100644 --- a/pkg/project/repo_test.go +++ b/pkg/project/repo_test.go @@ -37,6 +37,8 @@ func TestAccProject_repo(t *testing.T) { index_resources = true } + use_project_repository_resource = false + repos = ["{{ .repo1 }}"] } `, params) @@ -52,6 +54,8 @@ func TestAccProject_repo(t *testing.T) { index_resources = true } + use_project_repository_resource = false + repos = ["{{ .repo1 }}", "{{ .repo2 }}"] } `, params) @@ -66,6 +70,8 @@ func TestAccProject_repo(t *testing.T) { manage_resources = true index_resources = true } + + use_project_repository_resource = false } `, params) @@ -105,10 +111,15 @@ func TestAccProject_repo(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"use_project_role_resource", "use_project_user_resource", "use_project_group_resource"}, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "use_project_role_resource", + "use_project_user_resource", + "use_project_group_resource", + "use_project_repository_resource", + }, }, { Config: noReposConfig, @@ -183,6 +194,9 @@ func TestAccProject_repoAssignMultipleRepos(t *testing.T) { manage_resources = true index_resources = true } + + use_project_repository_resource = false + repos = [{{range $idx, $elem := .repos}}{{if $idx}},{{end}}"{{ $elem }}"{{end}}] } `, params) @@ -197,6 +211,8 @@ func TestAccProject_repoAssignMultipleRepos(t *testing.T) { manage_resources = true index_resources = true } + + use_project_repository_resource = false } `, params) @@ -230,10 +246,15 @@ func TestAccProject_repoAssignMultipleRepos(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"use_project_role_resource", "use_project_user_resource", "use_project_group_resource"}, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "use_project_role_resource", + "use_project_user_resource", + "use_project_group_resource", + "use_project_repository_resource", + }, }, { Config: noReposConfig, @@ -272,6 +293,8 @@ func TestAccProject_repoUnassignNonexistantRepo(t *testing.T) { index_resources = true } + use_project_repository_resource = false + repos = ["{{ .repo }}"] } `, params) diff --git a/pkg/project/resource_project.go b/pkg/project/resource_project.go index ccd4d795..c5a588ee 100644 --- a/pkg/project/resource_project.go +++ b/pkg/project/resource_project.go @@ -338,6 +338,16 @@ func projectResource() *schema.Resource { var projectSchemaV4 = sdk.MergeMaps( projectSchemaV3, map[string]*schema.Schema{ + "repos": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + MinItems: 0, + Description: "(Optional) List of existing repo keys to be assigned to the project. **Note** We *strongly* recommend using this attribute to manage the list of repositories. If you wish to use the alternate method of setting `project_key` attribute in each `artifactory_*_repository` resource in the `artifactory` provider, you will need to use `lifecycle.ignore_changes` in the `project` resource to avoid state drift.\n\n```hcl\nlifecycle {\n\tignore_changes = [\n\t\trepos\n\t]\n}\n```", + Deprecated: "Replaced by `project_repository` resource. This should not be used in combination with `project_repository` resource. Use `use_project_repository_resource` attribute to control which resource manages project repositories.", + }, "use_project_repository_resource": { Type: schema.TypeBool, Optional: true, diff --git a/pkg/project/resource_project_environment_test.go b/pkg/project/resource_project_environment_test.go index c255451b..67659f76 100644 --- a/pkg/project/resource_project_environment_test.go +++ b/pkg/project/resource_project_environment_test.go @@ -142,8 +142,8 @@ func verifyEnvironment(projectKey, id string, request *resty.Request) (*resty.Re return e.Name == fmt.Sprintf("%s-%s", projectKey, id) }) - if !envExists { - return resp, fmt.Errorf("environment %s does not exist", id) + if envExists { + return resp, fmt.Errorf("environment %s still exist", id) } return resp, nil diff --git a/pkg/project/resource_project_test.go b/pkg/project/resource_project_test.go index cf128e35..7632707f 100644 --- a/pkg/project/resource_project_test.go +++ b/pkg/project/resource_project_test.go @@ -14,7 +14,9 @@ import ( ) func verifyProject(id string, request *resty.Request) (*resty.Response, error) { - return request.Head(projectsUrl + id) + return request. + SetPathParam("projectKey", id). + Head(projectUrl) } func getRandomMaxStorageSize() int { @@ -335,6 +337,7 @@ func TestAccProject_full(t *testing.T) { use_project_group_resource = false use_project_user_resource = false use_project_role_resource = false + use_project_repository_resource = false member { name = artifactory_managed_user.{{ .username1 }}.name @@ -461,10 +464,15 @@ func TestAccProject_full(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"use_project_role_resource", "use_project_user_resource", "use_project_group_resource"}, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "use_project_role_resource", + "use_project_user_resource", + "use_project_group_resource", + "use_project_repository_resource", + }, }, }, }) diff --git a/pkg/project/role.go b/pkg/project/role.go index 5c91b98f..e88fccc3 100644 --- a/pkg/project/role.go +++ b/pkg/project/role.go @@ -11,11 +11,9 @@ import ( ) var unpackRoles = func(data *schema.ResourceData) []Role { - d := &sdk.ResourceData{ResourceData: data} - var roles []Role - if v, ok := d.GetOkExists("role"); ok { + if v, ok := data.GetOk("role"); ok { projectRoles := v.(*schema.Set).List() if len(projectRoles) == 0 { return roles diff --git a/pkg/project/role_test.go b/pkg/project/role_test.go index 16d5c79c..fbf968ea 100644 --- a/pkg/project/role_test.go +++ b/pkg/project/role_test.go @@ -165,10 +165,15 @@ func TestAccProject_role(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"use_project_role_resource", "use_project_user_resource", "use_project_group_resource"}, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "use_project_role_resource", + "use_project_user_resource", + "use_project_group_resource", + "use_project_repository_resource", + }, }, { Config: noUserConfig, diff --git a/pkg/project/util_test.go b/pkg/project/util_test.go index bab95e42..55983462 100644 --- a/pkg/project/util_test.go +++ b/pkg/project/util_test.go @@ -48,24 +48,25 @@ type CheckFun func(id string, request *resty.Request) (*resty.Response, error) func verifyDeleted(id string, check CheckFun) func(*terraform.State) error { return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[id] - if !ok { return fmt.Errorf("error: Resource id [%s] not found", id) } + client := TestProvider.Meta().(util.ProvderMetadata).Client resp, err := check(rs.Primary.ID, client.R()) if err != nil { - if resp != nil { - switch resp.StatusCode() { - case http.StatusNotFound, http.StatusBadRequest: - return nil - } - } return err } - return fmt.Errorf("error: %s still exists", rs.Primary.ID) + + if resp != nil { + switch resp.StatusCode() { + case http.StatusNotFound, http.StatusBadRequest: + return nil + } + } + + return fmt.Errorf("error: %s still exists: %d", rs.Primary.ID, resp.StatusCode()) } } From 810348f2a113037f0cd01f9209cca418b4eda928 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Tue, 12 Mar 2024 10:17:00 -0700 Subject: [PATCH 5/7] Update doc with latest sample.tf and full.tf --- docs/index.md | 90 ++++++++++++++------------ docs/resources/project.md | 25 +------ examples/full.tf | 90 ++++++++++++++------------ examples/resources/project/resource.tf | 23 ------- sample.tf | 75 +++++++++++---------- 5 files changed, 141 insertions(+), 162 deletions(-) diff --git a/docs/index.md b/docs/index.md index 6d015d58..e65978a3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -37,11 +37,11 @@ terraform { required_providers { artifactory = { source = "registry.terraform.io/jfrog/artifactory" - version = "2.20.0" + version = "10.3.0" } project = { source = "registry.terraform.io/jfrog/project" - version = "1.0.3" + version = "1.5.0" } } } @@ -124,53 +124,61 @@ resource "project" "myproject" { max_storage_in_gibibytes = 10 block_deployments_on_limit = false email_notification = true +} - member { - name = "user1" - roles = ["Developer", "Project Admin"] - } +resource "project_user" "user1" { + project_key = project.myproject.key + name = "user1" + roles = ["developer","project admin"] +} - member { - name = "user2" - roles = ["Developer"] - } +resource "project_user" "user2" { + project_key = project.myproject.key + name = "user2" + roles = ["developer"] +} - group { - name = "qa" - roles = ["qa"] - } +resource "project_group" "qa" { + project_key = project.myproject.key + name = "qa" + roles = ["qa"] +} - group { - name = "release" - roles = ["Release Manager"] - } +resource "project_group" "release" { + project_key = project.myproject.key + name = "release" + roles = ["release manager"] +} - role { - name = "qa" - description = "QA role" - type = "CUSTOM" - environments = ["DEV"] - actions = var.qa_roles - } +resource "project_role" "qa" { + project_key = project.myproject.key + name = "qa" + type = "CUSTOM" + environments = ["DEV"] + actions = var.qa_roles +} - role { - name = "devop" - description = "DevOp role" - type = "CUSTOM" - environments = ["DEV", "PROD"] - actions = var.devop_roles - } +resource "project_role" "devop" { + project_key = project.myproject.key + name = "devop" + type = "CUSTOM" + environments = ["DEV", "PROD"] + actions = var.devop_roles +} + +resource "project_repository" "docker-local" { + project_key = project.myproject.key + key = "docker-local" +} - repos = ["docker-local", "npm-remote"] +resource "project_repository" "npm-local" { + project_key = project.myproject.key + key = "npm-local" +} - depends_on = [ - artifactory_user.user1, - artifactory_user.user2, - artifactory_group.qa-group, - artifactory_group.release-group, - artifactory_local_docker_v2_repository.docker-local, - artifactory_remote_npm_repository.npm-remote, - ] +resource "project_environment" "myenv" { + project_key = project.myproj.key + name = "myenv" } ``` diff --git a/docs/resources/project.md b/docs/resources/project.md index feee1d66..da2a7da0 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -59,29 +59,6 @@ resource "project" "myproject" { max_storage_in_gibibytes = 10 block_deployments_on_limit = false email_notification = true - use_project_role_resource = true - - member { - name = "user1" - roles = ["developer","project admin"] - } - - member { - name = "user2" - roles = ["developer"] - } - - group { - name = "dev-group" - roles = ["developer"] - } - - group { - name = "release-group" - roles = ["release manager"] - } - - repos = ["docker-local", "rpm-local"] } ``` @@ -104,7 +81,7 @@ resource "project" "myproject" { - `group` (Block Set, Deprecated) Project group. Element has one to one mapping with the [JFrog Project Groups API](https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-UpdateGroupinProject) (see [below for nested schema](#nestedblock--group)) - `max_storage_in_gibibytes` (Number) Storage quota in GiB. Must be 1 or larger. Set to -1 for unlimited storage. This is translated to binary bytes for Artifactory API. So for a 1TB quota, this should be set to 1024 (vs 1000) which will translate to 1099511627776 bytes for the API. - `member` (Block Set, Deprecated) Member of the project. Element has one to one mapping with the [JFrog Project Users API](https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-UpdateUserinProject). (see [below for nested schema](#nestedblock--member)) -- `repos` (Set of String) (Optional) List of existing repo keys to be assigned to the project. **Note** We *strongly* recommend using this attribute to manage the list of repositories. If you wish to use the alternate method of setting `project_key` attribute in each `artifactory_*_repository` resource in the `artifactory` provider, you will need to use `lifecycle.ignore_changes` in the `project` resource to avoid state drift. +- `repos` (Set of String, Deprecated) (Optional) List of existing repo keys to be assigned to the project. **Note** We *strongly* recommend using this attribute to manage the list of repositories. If you wish to use the alternate method of setting `project_key` attribute in each `artifactory_*_repository` resource in the `artifactory` provider, you will need to use `lifecycle.ignore_changes` in the `project` resource to avoid state drift. ```hcl lifecycle { diff --git a/examples/full.tf b/examples/full.tf index 41c24f90..eab560d5 100644 --- a/examples/full.tf +++ b/examples/full.tf @@ -3,11 +3,11 @@ terraform { required_providers { artifactory = { source = "registry.terraform.io/jfrog/artifactory" - version = "2.20.0" + version = "10.3.0" } project = { source = "registry.terraform.io/jfrog/project" - version = "1.0.3" + version = "1.5.0" } } } @@ -90,51 +90,59 @@ resource "project" "myproject" { max_storage_in_gibibytes = 10 block_deployments_on_limit = false email_notification = true +} - member { - name = "user1" - roles = ["Developer", "Project Admin"] - } +resource "project_user" "user1" { + project_key = project.myproject.key + name = "user1" + roles = ["developer","project admin"] +} - member { - name = "user2" - roles = ["Developer"] - } +resource "project_user" "user2" { + project_key = project.myproject.key + name = "user2" + roles = ["developer"] +} - group { - name = "qa" - roles = ["qa"] - } +resource "project_group" "qa" { + project_key = project.myproject.key + name = "qa" + roles = ["qa"] +} - group { - name = "release" - roles = ["Release Manager"] - } +resource "project_group" "release" { + project_key = project.myproject.key + name = "release" + roles = ["release manager"] +} - role { - name = "qa" - description = "QA role" - type = "CUSTOM" - environments = ["DEV"] - actions = var.qa_roles - } +resource "project_role" "qa" { + project_key = project.myproject.key + name = "qa" + type = "CUSTOM" + environments = ["DEV"] + actions = var.qa_roles +} - role { - name = "devop" - description = "DevOp role" - type = "CUSTOM" - environments = ["DEV", "PROD"] - actions = var.devop_roles - } +resource "project_role" "devop" { + project_key = project.myproject.key + name = "devop" + type = "CUSTOM" + environments = ["DEV", "PROD"] + actions = var.devop_roles +} + +resource "project_repository" "docker-local" { + project_key = project.myproject.key + key = "docker-local" +} - repos = ["docker-local", "npm-remote"] +resource "project_repository" "npm-local" { + project_key = project.myproject.key + key = "npm-local" +} - depends_on = [ - artifactory_user.user1, - artifactory_user.user2, - artifactory_group.qa-group, - artifactory_group.release-group, - artifactory_local_docker_v2_repository.docker-local, - artifactory_remote_npm_repository.npm-remote, - ] +resource "project_environment" "myenv" { + project_key = project.myproj.key + name = "myenv" } diff --git a/examples/resources/project/resource.tf b/examples/resources/project/resource.tf index f8f1e2d0..17c789ec 100644 --- a/examples/resources/project/resource.tf +++ b/examples/resources/project/resource.tf @@ -10,27 +10,4 @@ resource "project" "myproject" { max_storage_in_gibibytes = 10 block_deployments_on_limit = false email_notification = true - use_project_role_resource = true - - member { - name = "user1" - roles = ["developer","project admin"] - } - - member { - name = "user2" - roles = ["developer"] - } - - group { - name = "dev-group" - roles = ["developer"] - } - - group { - name = "release-group" - roles = ["release manager"] - } - - repos = ["docker-local", "rpm-local"] } diff --git a/sample.tf b/sample.tf index bb5bd63d..86509e80 100644 --- a/sample.tf +++ b/sample.tf @@ -3,7 +3,7 @@ terraform { required_providers { project = { source = "registry.terraform.io/jfrog/project" - version = "1.3.6" + version = "1.5.0" } } } @@ -19,7 +19,7 @@ variable "devop_roles" { } resource "project" "myproject" { - key = "myproj" + key = "myproj" display_name = "My Project" description = "My Project" admin_privileges { @@ -30,50 +30,59 @@ resource "project" "myproject" { max_storage_in_gibibytes = 10 block_deployments_on_limit = false email_notification = true - use_project_role_resource = true +} - member { - name = "user1" // Must exist already in Artifactory - roles = ["Developer", "Project Admin"] - } +resource "project_user" "user1" { + project_key = project.myproject.key + name = "user1" + roles = ["developer","project admin"] +} - member { - name = "user2" // Must exist already in Artifactory - roles = ["Developer"] - } +resource "project_user" "user2" { + project_key = project.myproject.key + name = "user2" + roles = ["developer"] +} - group { - name = "qa" - roles = ["qa"] - } +resource "project_group" "dev-group" { + project_key = project.myproject.key + name = "dev-group" + roles = ["developer"] +} - group { - name = "release" - roles = ["Release Manager"] - } +resource "project_group" "release-group" { + project_key = project.myproject.key + name = "release-group" + roles = ["release manager"] +} + +resource "project_repository" "docker-local" { + project_key = project.myproject.key + key = "docker-local" +} - repos = ["docker-local", "npm-remote"] // Must exist already in Artifactory +resource "project_repository" "rpm-local" { + project_key = project.myproject.key + key = "rpm-local" } resource "project_environment" "myenv" { - name = "myenv" project_key = project.myproj.key + name = "myenv" } resource "project_role" "qa" { - name = "qa" - type = "CUSTOM" - project_key = project.myproject.key - - environments = ["DEV"] - actions = var.qa_roles + project_key = project.myproject.key + name = "qa" + type = "CUSTOM" + environments = ["DEV"] + actions = var.qa_roles } resource "project_role" "devop" { - name = "devop" - type = "CUSTOM" - project_key = project.myproject.key - - environments = ["DEV", "PROD"] - actions = var.devop_roles + project_key = project.myproject.key + name = "devop" + type = "CUSTOM" + environments = ["DEV", "PROD"] + actions = var.devop_roles } From c3bc1c21da1600c4ad3b460430e7516bb8cb6c33 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Tue, 12 Mar 2024 10:22:51 -0700 Subject: [PATCH 6/7] Fix project_key documentation to match latest validation --- docs/resources/environment.md | 2 +- docs/resources/project.md | 2 +- docs/resources/role.md | 2 +- go.mod | 2 +- pkg/project/resource_project.go | 2 +- pkg/project/resource_project_environment.go | 2 +- pkg/project/resource_project_role.go | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/resources/environment.md b/docs/resources/environment.md index 4b24191b..0f0d9ea1 100644 --- a/docs/resources/environment.md +++ b/docs/resources/environment.md @@ -28,7 +28,7 @@ resource "project_environment" "myenv" { ### Required - `name` (String) Environment name. Must start with a letter and can contain letters, digits and `-` character. -- `project_key` (String) Project key for this environment. This field supports only 2 - 20 lowercase alphanumeric and hyphen characters. Must begin with a letter. +- `project_key` (String) Project key for this environment. This field supports only 2 - 32 lowercase alphanumeric and hyphen characters. Must begin with a letter. ### Read-Only diff --git a/docs/resources/project.md b/docs/resources/project.md index da2a7da0..7d3d3be5 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -69,7 +69,7 @@ resource "project" "myproject" { - `admin_privileges` (Block Set, Min: 1) (see [below for nested schema](#nestedblock--admin_privileges)) - `display_name` (String) Also known as project name on the UI -- `key` (String) The Project Key is added as a prefix to resources created within a Project. This field is mandatory and supports only 2 - 20 lowercase alphanumeric and hyphen characters. Must begin with a letter. For example: `us1a-test`. +- `key` (String) The Project Key is added as a prefix to resources created within a Project. This field is mandatory and supports only 2 - 32 lowercase alphanumeric and hyphen characters. Must begin with a letter. For example: `us1a-test`. ### Optional diff --git a/docs/resources/role.md b/docs/resources/role.md index 346ab517..e93af917 100644 --- a/docs/resources/role.md +++ b/docs/resources/role.md @@ -31,7 +31,7 @@ resource "project_role" "myrole" { - `actions` (Set of String) List of pre-defined actions (READ_REPOSITORY, ANNOTATE_REPOSITORY, DEPLOY_CACHE_REPOSITORY, DELETE_OVERWRITE_REPOSITORY, MANAGE_XRAY_MD_REPOSITORY, READ_RELEASE_BUNDLE, ANNOTATE_RELEASE_BUNDLE, CREATE_RELEASE_BUNDLE, DISTRIBUTE_RELEASE_BUNDLE, DELETE_RELEASE_BUNDLE, MANAGE_XRAY_MD_RELEASE_BUNDLE, READ_BUILD, ANNOTATE_BUILD, DEPLOY_BUILD, DELETE_BUILD, MANAGE_XRAY_MD_BUILD, READ_SOURCES_PIPELINE, TRIGGER_PIPELINE, READ_INTEGRATIONS_PIPELINE, READ_POOLS_PIPELINE, MANAGE_INTEGRATIONS_PIPELINE, MANAGE_SOURCES_PIPELINE, MANAGE_POOLS_PIPELINE, TRIGGER_SECURITY, ISSUES_SECURITY, LICENCES_SECURITY, REPORTS_SECURITY, WATCHES_SECURITY, POLICIES_SECURITY, RULES_SECURITY, MANAGE_MEMBERS, MANAGE_RESOURCES) - `environments` (Set of String) A repository can be available in different environments. Members with roles defined in the set environment will have access to the repository. List of pre-defined environments (DEV, PROD) - `name` (String) -- `project_key` (String) Project key for this environment. This field supports only 2 - 20 lowercase alphanumeric and hyphen characters. Must begin with a letter. +- `project_key` (String) Project key for this environment. This field supports only 2 - 32 lowercase alphanumeric and hyphen characters. Must begin with a letter. - `type` (String) Type of role. Only "CUSTOM" is supported ### Read-Only diff --git a/go.mod b/go.mod index fe26c964..bcf2763e 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/hashicorp/terraform-plugin-docs v0.16.0 github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 + github.com/hashicorp/terraform-plugin-testing v1.7.0 github.com/jfrog/terraform-provider-shared v1.22.0 golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 ) @@ -42,7 +43,6 @@ require ( github.com/hashicorp/terraform-exec v0.20.0 // indirect github.com/hashicorp/terraform-json v0.21.0 // indirect github.com/hashicorp/terraform-plugin-go v0.22.1 // indirect - github.com/hashicorp/terraform-plugin-testing v1.7.0 // indirect github.com/hashicorp/terraform-registry-address v0.2.3 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect diff --git a/pkg/project/resource_project.go b/pkg/project/resource_project.go index c5a588ee..4cf563d8 100644 --- a/pkg/project/resource_project.go +++ b/pkg/project/resource_project.go @@ -53,7 +53,7 @@ func projectResource() *schema.Resource { Required: true, ForceNew: true, ValidateDiagFunc: validator.ProjectKey, - Description: "The Project Key is added as a prefix to resources created within a Project. This field is mandatory and supports only 2 - 20 lowercase alphanumeric and hyphen characters. Must begin with a letter. For example: `us1a-test`.", + Description: "The Project Key is added as a prefix to resources created within a Project. This field is mandatory and supports only 2 - 32 lowercase alphanumeric and hyphen characters. Must begin with a letter. For example: `us1a-test`.", }, "display_name": { Required: true, diff --git a/pkg/project/resource_project_environment.go b/pkg/project/resource_project_environment.go index e138d4cc..96858b31 100644 --- a/pkg/project/resource_project_environment.go +++ b/pkg/project/resource_project_environment.go @@ -49,7 +49,7 @@ func projectEnvironmentResource() *schema.Resource { Required: true, ForceNew: true, ValidateDiagFunc: validator.ProjectKey, - Description: "Project key for this environment. This field supports only 2 - 20 lowercase alphanumeric and hyphen characters. Must begin with a letter.", + Description: "Project key for this environment. This field supports only 2 - 32 lowercase alphanumeric and hyphen characters. Must begin with a letter.", }, } diff --git a/pkg/project/resource_project_role.go b/pkg/project/resource_project_role.go index c8106345..c95bdac0 100644 --- a/pkg/project/resource_project_role.go +++ b/pkg/project/resource_project_role.go @@ -96,7 +96,7 @@ func projectRoleResource() *schema.Resource { Required: true, ForceNew: true, ValidateDiagFunc: validator.ProjectKey, - Description: "Project key for this environment. This field supports only 2 - 20 lowercase alphanumeric and hyphen characters. Must begin with a letter.", + Description: "Project key for this environment. This field supports only 2 - 32 lowercase alphanumeric and hyphen characters. Must begin with a letter.", }, "environments": { Type: schema.TypeSet, From 9f4e7d23d6a6bd5d19227ac84e7aebd59857e56d Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Tue, 12 Mar 2024 10:27:59 -0700 Subject: [PATCH 7/7] Update CHANGELOG --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f773a22b..47e6e119 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## 1.5.0 (March 13, 2024) + +FEATURES: + +* **New Resource:** `project_repository` - Separate resource to manage project repositories. +* resource/project: Add `use_project_repository_resource` attribute to toggle if `project` resource should use its `repos` attribute or not to manage project repositories. Should be set to `false` to continue using existing `repos` attribute. + +IMPROVEMENTS: + +* resource/project, resource/project_environment, resource/project_role: Fix documentation for `project_key` attribute to match validation. Issue: [#103](https://github.com/jfrog/terraform-provider-project/issues/103) + +PR: [#105](https://github.com/jfrog/terraform-provider-project/pull/105) + ## 1.4.0 (March 4, 2024) FEATURES: