diff --git a/go.mod b/go.mod index 109b957ed..22c19bd2a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,8 @@ module github.com/OctopusDeploy/terraform-provider-octopusdeploy go 1.20 require ( - github.com/OctopusDeploy/go-octopusdeploy/v2 v2.30.1 + github.com/OctopusDeploy/go-octopusdeploy/v2 v2.33.3 + github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20230705105638-f5ef7c07973b github.com/google/uuid v1.3.0 github.com/gruntwork-io/terratest v0.41.11 github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637 @@ -28,7 +29,6 @@ require ( github.com/Masterminds/semver/v3 v3.2.0 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/Microsoft/go-winio v0.6.0 // indirect - github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20230705105638-f5ef7c07973b // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-cidr v1.1.0 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect @@ -44,13 +44,11 @@ require ( github.com/cpuguy83/dockercfg v0.3.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dghubble/sling v1.4.1 // indirect - github.com/dnephin/pflag v1.0.7 // indirect github.com/docker/distribution v2.8.2+incompatible // indirect github.com/docker/docker v23.0.5+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/fatih/color v1.13.0 // indirect - github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.11.2 // indirect @@ -59,7 +57,6 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-querystring v1.1.0 // indirect - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.7.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -129,9 +126,7 @@ require ( golang.org/x/mod v0.9.0 // indirect golang.org/x/net v0.8.0 // indirect golang.org/x/oauth2 v0.5.0 // indirect - golang.org/x/sync v0.1.0 // indirect golang.org/x/sys v0.8.0 // indirect - golang.org/x/term v0.6.0 // indirect golang.org/x/tools v0.6.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.110.0 // indirect @@ -140,5 +135,5 @@ require ( google.golang.org/grpc v1.53.0 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - gotest.tools/gotestsum v1.10.0 // indirect + gotest.tools/v3 v3.3.0 // indirect ) diff --git a/go.sum b/go.sum index 6c27040de..77bf4619c 100644 --- a/go.sum +++ b/go.sum @@ -63,22 +63,8 @@ github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugX github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/Microsoft/hcsshim v0.9.7 h1:mKNHW/Xvv1aFH87Jb6ERDzXTJTLPlmzfZ28VBFD/bfg= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.24.0 h1:b6kyJL3SDbbViCSjkvrO1cb8KOJMFNYfqA8B1SkL5g4= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.24.0/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.27.0 h1:LwevbGRiVZxDUG1YJ/Wnc70LqHMUihFK6ii93iwFhtE= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.27.0/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.29.0 h1:hkFszgjRnXTv54bmgeHLzIoTP1o52QUy57JtHFFfu/Y= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.29.0/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.30.0 h1:croG1e9O533Uv1RWsbpkRv+kPb05T/msbL2NuBFhp6o= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.30.0/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.30.1-0.20230810215021-dcb9081b542c h1:z7p6BtvmFwgBJEo0wHZTVCsNpSA07JzIx5FtOMbsYTw= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.30.1-0.20230810215021-dcb9081b542c/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.30.1 h1:LcZF70bvzCaTCEKZnVq1L6cc22Nfell3qAG4adcuEzk= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.30.1/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E= -github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20230605032624-2acff93f126c h1:nJXjt8UFkyZ4iB/2Ba9aNSRgbnv3dQwO9UvTWnor2yk= -github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20230605032624-2acff93f126c/go.mod h1:ltRYzU6Dw2WB09wDGB/zofUkB8Un13Qx30eqsw77SFw= -github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20230605033112-566bb7c786fc h1:FJh2axO8HInjLrBZCfkBtNKzFy/BouERvouyaHH034o= -github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20230605033112-566bb7c786fc/go.mod h1:ltRYzU6Dw2WB09wDGB/zofUkB8Un13Qx30eqsw77SFw= +github.com/OctopusDeploy/go-octopusdeploy/v2 v2.33.3 h1:5+ChMTskACIVLKj8YX45XAQfAjVnfm6ftL+n6Kc7dTY= +github.com/OctopusDeploy/go-octopusdeploy/v2 v2.33.3/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E= github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20230705105638-f5ef7c07973b h1:XOBPcVHeDUYIpcag0yI8IYKiBL+5LLL8suysvlavQwI= github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20230705105638-f5ef7c07973b/go.mod h1:E0hYVpZd61fXhzTozkxjiWEy+/yTRxAnr2SIE7k8ZSM= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= @@ -147,14 +133,8 @@ 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/dghubble/sling v1.4.1 h1:AxjTubpVyozMvbBCtXcsWEyGGgUZutC5YGrfxPNVOcQ= github.com/dghubble/sling v1.4.1/go.mod h1:QoMB1KL3GAo+7HsD8Itd6S+6tW91who8BGZzuLvpOyc= -github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= -github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= -github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= -github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v23.0.1+incompatible h1:vjgvJZxprTTE1A37nm+CLNAdwu6xZekyoiVlUZEINcY= -github.com/docker/docker v23.0.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v23.0.5+incompatible h1:DaxtlTJjFSnLOXVNUBU1+6kXGz2lpDoEAH6QoxaSg8k= github.com/docker/docker v23.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -175,8 +155,6 @@ github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYF github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= -github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= -github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= @@ -252,7 +230,6 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 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-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= @@ -269,8 +246,6 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= 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= @@ -364,8 +339,6 @@ github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.12/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= @@ -427,15 +400,12 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 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 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-zglob v0.0.4 h1:LQi2iOm0/fGgu80AioIJ/1j9w9Oh+9DZ39J4VAGzHQM= github.com/mattn/go-zglob v0.0.4/go.mod h1:MxxjyoXXnMxfIpxTK2GAkw1w8glPsQILx3N5wrKakiY= -github.com/mcasperson/OctopusTerraformTestFramework v0.0.0-20230417081345-fe8c660438ba h1:CjSH2yShxxjQkoQnAjn4klOFi1tKiNqStEf1ERUFn4I= -github.com/mcasperson/OctopusTerraformTestFramework v0.0.0-20230417081345-fe8c660438ba/go.mod h1:Pb4ZsesTQ3Zih6I9nLVahLP7zEIg9tJn2+C5o6hHA5g= github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4= github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng= github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= @@ -467,8 +437,6 @@ github.com/moby/patternmatcher v0.5.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YO github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU= github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo= -github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= -github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= @@ -482,8 +450,6 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= -github.com/opencontainers/runc v1.1.4 h1:nRCz/8sKg6K6jgYAFLDlXzPeITBZJyX28DBVhWD+5dg= -github.com/opencontainers/runc v1.1.4/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs= github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= @@ -539,15 +505,10 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/testcontainers/testcontainers-go v0.18.0 h1:8RXrcIQv5xX/uBOSmZd297gzvA7F0yuRA37/918o7Yg= -github.com/testcontainers/testcontainers-go v0.18.0/go.mod h1:rLC7hR2SWRjJZZNrUYiTKvUXCziNxzZiYtz9icTWYNQ= -github.com/testcontainers/testcontainers-go v0.20.1 h1:mK15UPJ8c5P+NsQKmkqzs/jMdJt6JMs5vlw2y4j92c0= -github.com/testcontainers/testcontainers-go v0.20.1/go.mod h1:zb+NOlCQBkZ7RQp4QI+YMIHyO2CQ/qsXzNF5eLJ24SY= github.com/testcontainers/testcontainers-go v0.21.0 h1:syePAxdeTzfkap+RrJaQZpJQ/s/fsUgn11xIvHrOE9U= github.com/testcontainers/testcontainers-go v0.21.0/go.mod h1:c1ez3WVRHq7T/Aj+X3TIipFBwkBaNT5iNCY8+1b83Ng= github.com/tmccombs/hcl2json v0.3.6 h1:QVZ1FKXXk9LBpaWTUvJXgdhsllpDmWnfr4/4FP+vBRQ= @@ -574,7 +535,6 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= @@ -620,8 +580,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230304125523-9ff063c70017 h1:3Ea9SZLCB0aRIhSEjM+iaGIlzzeDJdpi579El/YIhEE= -golang.org/x/exp v0.0.0-20230304125523-9ff063c70017/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4= golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= @@ -683,7 +641,6 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= @@ -708,11 +665,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/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 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -760,10 +714,8 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/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-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/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-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -773,20 +725,15 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -848,7 +795,6 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= @@ -969,12 +915,9 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/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= -gotest.tools/gotestsum v1.10.0 h1:lVO4uQJoxdsJb7jgmr1fg8QW7zGQ/tuqvsq5fHKyoHQ= -gotest.tools/gotestsum v1.10.0/go.mod h1:6JHCiN6TEjA7Kaz23q1bH0e2Dc3YJjDUZ0DmctFZf+w= -gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= +gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/main.go b/main.go index 31b6fc294..63a681dc9 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,8 @@ func main() { flag.Parse() opts := &plugin.ServeOpts{ - ProviderFunc: octopusdeploy.Provider} + ProviderFunc: octopusdeploy.Provider, + } if debugMode { opts.Debug = true diff --git a/octopusdeploy/config.go b/octopusdeploy/config.go index 3eaa4e3d4..e084da8eb 100644 --- a/octopusdeploy/config.go +++ b/octopusdeploy/config.go @@ -4,6 +4,7 @@ import ( "net/url" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" ) @@ -27,7 +28,7 @@ func (c *Config) Client() (*client.Client, diag.Diagnostics) { } if len(c.SpaceID) > 0 { - space, err := octopus.Spaces.GetByID(c.SpaceID) + space, err := spaces.GetByID(octopus, c.SpaceID) if err != nil { return nil, diag.FromErr(err) } diff --git a/octopusdeploy/data_source_accounts.go b/octopusdeploy/data_source_accounts.go index 778a42efc..52acb1abb 100644 --- a/octopusdeploy/data_source_accounts.go +++ b/octopusdeploy/data_source_accounts.go @@ -27,9 +27,10 @@ func dataSourceAccountsRead(ctx context.Context, d *schema.ResourceData, m inter Skip: d.Get("skip").(int), Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - existingAccounts, err := client.Accounts.Get(query) + existingAccounts, err := accounts.Get(client, spaceID, &query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_azure_cloud_service_deployment_targets.go b/octopusdeploy/data_source_azure_cloud_service_deployment_targets.go index 123ebcd46..b33c6fff4 100644 --- a/octopusdeploy/data_source_azure_cloud_service_deployment_targets.go +++ b/octopusdeploy/data_source_azure_cloud_service_deployment_targets.go @@ -37,7 +37,7 @@ func dataSourceAzureCloudServiceDeploymentTargetsRead(ctx context.Context, d *sc } client := m.(*client.Client) - existingDeploymentTargets, err := client.Machines.Get(query) + existingDeploymentTargets, err := machines.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_azure_service_fabric_cluster_deployment_targets.go b/octopusdeploy/data_source_azure_service_fabric_cluster_deployment_targets.go index 0fa0fc58c..c75788663 100644 --- a/octopusdeploy/data_source_azure_service_fabric_cluster_deployment_targets.go +++ b/octopusdeploy/data_source_azure_service_fabric_cluster_deployment_targets.go @@ -38,7 +38,7 @@ func dataSourceAzureServiceFabricClusterDeploymentTargetsRead(ctx context.Contex } client := m.(*client.Client) - existingDeploymentTargets, err := client.Machines.Get(query) + existingDeploymentTargets, err := machines.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_azure_web_app_deployment_targets.go b/octopusdeploy/data_source_azure_web_app_deployment_targets.go index 2bc996289..0772f0490 100644 --- a/octopusdeploy/data_source_azure_web_app_deployment_targets.go +++ b/octopusdeploy/data_source_azure_web_app_deployment_targets.go @@ -38,7 +38,7 @@ func dataSourceAzureWebAppDeploymentTargetsRead(ctx context.Context, d *schema.R } client := m.(*client.Client) - existingDeploymentTargets, err := client.Machines.Get(query) + existingDeploymentTargets, err := machines.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_certificates.go b/octopusdeploy/data_source_certificates.go index b81b843f9..c907858f0 100644 --- a/octopusdeploy/data_source_certificates.go +++ b/octopusdeploy/data_source_certificates.go @@ -31,8 +31,9 @@ func dataSourceCertificatesRead(ctx context.Context, d *schema.ResourceData, m i Tenant: d.Get("tenant").(string), } + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - existingCertificates, err := client.Certificates.Get(query) + existingCertificates, err := certificates.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_channels.go b/octopusdeploy/data_source_channels.go index 72bc93e41..cfa228483 100644 --- a/octopusdeploy/data_source_channels.go +++ b/octopusdeploy/data_source_channels.go @@ -25,9 +25,10 @@ func dataSourceChannelsRead(ctx context.Context, d *schema.ResourceData, m inter Skip: d.Get("skip").(int), Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - existingChannels, err := client.Channels.Get(query) + existingChannels, err := channels.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_cloud_region_deployment_targets.go b/octopusdeploy/data_source_cloud_region_deployment_targets.go index b7631d430..894371290 100644 --- a/octopusdeploy/data_source_cloud_region_deployment_targets.go +++ b/octopusdeploy/data_source_cloud_region_deployment_targets.go @@ -38,7 +38,7 @@ func dataSourceCloudRegionDeploymentTargetsRead(ctx context.Context, d *schema.R } client := m.(*client.Client) - existingDeploymentTargets, err := client.Machines.Get(query) + existingDeploymentTargets, err := machines.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_environments.go b/octopusdeploy/data_source_environments.go index 4300fd927..460474c83 100644 --- a/octopusdeploy/data_source_environments.go +++ b/octopusdeploy/data_source_environments.go @@ -28,7 +28,7 @@ func dataSourceEnvironmentsRead(ctx context.Context, d *schema.ResourceData, m i } client := m.(*client.Client) - existingEnvironments, err := client.Environments.Get(query) + existingEnvironments, err := environments.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_feeds.go b/octopusdeploy/data_source_feeds.go index 9245d397c..0368e1c30 100644 --- a/octopusdeploy/data_source_feeds.go +++ b/octopusdeploy/data_source_feeds.go @@ -26,9 +26,10 @@ func dataSourceFeedsRead(ctx context.Context, d *schema.ResourceData, m interfac Skip: d.Get("skip").(int), Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - existingFeeds, err := client.Feeds.Get(query) + existingFeeds, err := feeds.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_git_credentials.go b/octopusdeploy/data_source_git_credentials.go index d8317dc86..eb7e0451f 100644 --- a/octopusdeploy/data_source_git_credentials.go +++ b/octopusdeploy/data_source_git_credentials.go @@ -24,9 +24,10 @@ func dataSourceGitCredentialsRead(ctx context.Context, d *schema.ResourceData, m Skip: d.Get("skip").(int), Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - existingGitCredentials, err := client.GitCredentials.Get(query) + existingGitCredentials, err := credentials.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_kubernetes_cluster_deployment_targets.go b/octopusdeploy/data_source_kubernetes_cluster_deployment_targets.go index 43f98f12e..73d0a5d4d 100644 --- a/octopusdeploy/data_source_kubernetes_cluster_deployment_targets.go +++ b/octopusdeploy/data_source_kubernetes_cluster_deployment_targets.go @@ -38,7 +38,7 @@ func dataSourceKubernetesClusterDeploymentTargetsRead(ctx context.Context, d *sc } client := m.(*client.Client) - existingDeploymentTargets, err := client.Machines.Get(query) + existingDeploymentTargets, err := machines.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_library_variable_sets.go b/octopusdeploy/data_source_library_variable_sets.go index 7a1123e3f..cafdc3d2d 100644 --- a/octopusdeploy/data_source_library_variable_sets.go +++ b/octopusdeploy/data_source_library_variable_sets.go @@ -5,6 +5,7 @@ import ( "time" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/libraryvariablesets" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -27,8 +28,10 @@ func dataSourceLibraryVariableSetReadByName(ctx context.Context, d *schema.Resou Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) + client := m.(*client.Client) - existingLibraryVariableSets, err := client.LibraryVariableSets.Get(query) + existingLibraryVariableSets, err := libraryvariablesets.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_lifecycles.go b/octopusdeploy/data_source_lifecycles.go index db11dad33..3d17ace7c 100644 --- a/octopusdeploy/data_source_lifecycles.go +++ b/octopusdeploy/data_source_lifecycles.go @@ -25,9 +25,10 @@ func dataSourceLifecyclesRead(ctx context.Context, d *schema.ResourceData, m int Skip: d.Get("skip").(int), Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - existingLifecycles, err := client.Lifecycles.Get(query) + existingLifecycles, err := lifecycles.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_listening_tentacle_deployment_targets.go b/octopusdeploy/data_source_listening_tentacle_deployment_targets.go index 5d70f09bc..c1f21cf18 100644 --- a/octopusdeploy/data_source_listening_tentacle_deployment_targets.go +++ b/octopusdeploy/data_source_listening_tentacle_deployment_targets.go @@ -38,7 +38,7 @@ func dataSourceListeningTentacleDeploymentTargetsRead(ctx context.Context, d *sc } client := m.(*client.Client) - existingDeploymentTargets, err := client.Machines.Get(query) + existingDeploymentTargets, err := machines.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_machine_policies.go b/octopusdeploy/data_source_machine_policies.go index 1ee7881fc..9e03a45c4 100644 --- a/octopusdeploy/data_source_machine_policies.go +++ b/octopusdeploy/data_source_machine_policies.go @@ -5,7 +5,7 @@ import ( "time" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machinepolicies" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -19,15 +19,16 @@ func dataSourceMachinePolicies() *schema.Resource { } func dataSourceMachinePoliciesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - query := machines.MachinePoliciesQuery{ + query := machinepolicies.MachinePoliciesQuery{ IDs: expandArray(d.Get("ids").([]interface{})), PartialName: d.Get("partial_name").(string), Skip: d.Get("skip").(int), Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - existingMachinePolicies, err := client.MachinePolicies.Get(query) + existingMachinePolicies, err := machinepolicies.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_offline_package_drop_deployment_targets.go b/octopusdeploy/data_source_offline_package_drop_deployment_targets.go index 97517bae5..3e69b1ad1 100644 --- a/octopusdeploy/data_source_offline_package_drop_deployment_targets.go +++ b/octopusdeploy/data_source_offline_package_drop_deployment_targets.go @@ -38,7 +38,7 @@ func dataSourceOfflinePackageDropDeploymentTargetsRead(ctx context.Context, d *s } client := m.(*client.Client) - existingDeploymentTargets, err := client.Machines.Get(query) + existingDeploymentTargets, err := machines.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_polling_tentacle_deployment_targets.go b/octopusdeploy/data_source_polling_tentacle_deployment_targets.go index c6c43d10e..548fa8ec5 100644 --- a/octopusdeploy/data_source_polling_tentacle_deployment_targets.go +++ b/octopusdeploy/data_source_polling_tentacle_deployment_targets.go @@ -38,7 +38,7 @@ func dataSourcePollingTentacleDeploymentTargetsRead(ctx context.Context, d *sche } client := m.(*client.Client) - existingDeploymentTargets, err := client.Machines.Get(query) + existingDeploymentTargets, err := machines.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_project_groups.go b/octopusdeploy/data_source_project_groups.go index 11a985302..b3fb12ffa 100644 --- a/octopusdeploy/data_source_project_groups.go +++ b/octopusdeploy/data_source_project_groups.go @@ -26,8 +26,10 @@ func dataSourceProjectGroupsRead(ctx context.Context, d *schema.ResourceData, m Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) + client := m.(*client.Client) - existingProjectGroups, err := client.ProjectGroups.Get(query) + existingProjectGroups, err := projectgroups.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_projects.go b/octopusdeploy/data_source_projects.go index 00f7eba80..0410efae8 100644 --- a/octopusdeploy/data_source_projects.go +++ b/octopusdeploy/data_source_projects.go @@ -32,8 +32,10 @@ func dataSourceProjectsRead(ctx context.Context, d *schema.ResourceData, m inter Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) + client := m.(*client.Client) - existingProjects, err := client.Projects.Get(query) + existingProjects, err := projects.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_script_modules.go b/octopusdeploy/data_source_script_modules.go index 38f636b13..f782e1410 100644 --- a/octopusdeploy/data_source_script_modules.go +++ b/octopusdeploy/data_source_script_modules.go @@ -5,6 +5,7 @@ import ( "time" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/scriptmodules" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -27,8 +28,10 @@ func dataSourceScriptModulesRead(ctx context.Context, d *schema.ResourceData, m Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) + client := m.(*client.Client) - existingScriptModules, err := client.ScriptModules.Get(query) + existingScriptModules, err := scriptmodules.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_spaces.go b/octopusdeploy/data_source_spaces.go index 6ce61c1e5..466c869a0 100644 --- a/octopusdeploy/data_source_spaces.go +++ b/octopusdeploy/data_source_spaces.go @@ -31,7 +31,7 @@ func dataSourceSpacesRead(ctx context.Context, d *schema.ResourceData, m interfa Take: d.Get("take").(int), } - existingSpaces, err := client.Spaces.Get(query) + existingSpaces, err := spaces.Get(client, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_ssh_connection_deployment_targets.go b/octopusdeploy/data_source_ssh_connection_deployment_targets.go index 8be97de32..85934b8a0 100644 --- a/octopusdeploy/data_source_ssh_connection_deployment_targets.go +++ b/octopusdeploy/data_source_ssh_connection_deployment_targets.go @@ -38,7 +38,7 @@ func dataSourceSSHConnectionDeploymentTargetsRead(ctx context.Context, d *schema } client := m.(*client.Client) - existingDeploymentTargets, err := client.Machines.Get(query) + existingDeploymentTargets, err := machines.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_tag_sets.go b/octopusdeploy/data_source_tag_sets.go index 1f0a93922..63395248b 100644 --- a/octopusdeploy/data_source_tag_sets.go +++ b/octopusdeploy/data_source_tag_sets.go @@ -25,9 +25,10 @@ func dataSourceTagSetsRead(ctx context.Context, d *schema.ResourceData, m interf Skip: d.Get("skip").(int), Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) octopus := m.(*client.Client) - existingTagSets, err := octopus.TagSets.Get(query) + existingTagSets, err := tagsets.Get(octopus, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_user_roles.go b/octopusdeploy/data_source_user_roles.go index e0095cbe1..be1ec3f1a 100644 --- a/octopusdeploy/data_source_user_roles.go +++ b/octopusdeploy/data_source_user_roles.go @@ -26,8 +26,10 @@ func dataSourceUserRolesRead(ctx context.Context, d *schema.ResourceData, meta i Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) + client := meta.(*client.Client) - existingUserRoles, err := client.UserRoles.Get(query) + existingUserRoles, err := userroles.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_users.go b/octopusdeploy/data_source_users.go index 74d4db256..c541d86d7 100644 --- a/octopusdeploy/data_source_users.go +++ b/octopusdeploy/data_source_users.go @@ -26,8 +26,10 @@ func dataSourceUsersRead(ctx context.Context, d *schema.ResourceData, meta inter Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) + client := meta.(*client.Client) - existingUsers, err := client.Users.Get(query) + existingUsers, err := users.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_variables.go b/octopusdeploy/data_source_variables.go index 0f364e9bd..7dadb3afd 100644 --- a/octopusdeploy/data_source_variables.go +++ b/octopusdeploy/data_source_variables.go @@ -26,8 +26,13 @@ func dataSourceVariableReadByName(ctx context.Context, d *schema.ResourceData, m scope = expandVariableScope(v) } + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + client := m.(*client.Client) - variables, err := client.Variables.GetByName(ownerID.(string), name.(string), &scope) + variables, err := variables.GetByName(client, spaceID, ownerID.(string), name.(string), &scope) if err != nil { return diag.Errorf("error reading variable with owner ID %s with name %s: %s", ownerID, name, err.Error()) } diff --git a/octopusdeploy/data_source_worker_pools.go b/octopusdeploy/data_source_worker_pools.go index 0c42e000b..f685a2249 100644 --- a/octopusdeploy/data_source_worker_pools.go +++ b/octopusdeploy/data_source_worker_pools.go @@ -27,7 +27,7 @@ func dataSourceWorkerPoolsRead(ctx context.Context, d *schema.ResourceData, m in } client := m.(*client.Client) - workerPools, err := client.WorkerPools.Get(query) + workerPools, err := workerpools.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/provider.go b/octopusdeploy/provider.go index 34e93ac41..4299ce5ea 100644 --- a/octopusdeploy/provider.go +++ b/octopusdeploy/provider.go @@ -124,7 +124,6 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{} Address: d.Get("address").(string), APIKey: d.Get("api_key").(string), } - if spaceID, ok := d.GetOk("space_id"); ok { config.SpaceID = spaceID.(string) } diff --git a/octopusdeploy/resource_aws_elastic_container_registry.go b/octopusdeploy/resource_aws_elastic_container_registry.go index ff33fd320..93aa1dee6 100644 --- a/octopusdeploy/resource_aws_elastic_container_registry.go +++ b/octopusdeploy/resource_aws_elastic_container_registry.go @@ -33,7 +33,7 @@ func resourceAwsElasticContainerRegistryCreate(ctx context.Context, d *schema.Re tflog.Info(ctx, fmt.Sprintf("creating AWS Elastic Container Registry, %s", feed.GetName())) client := m.(*client.Client) - createdFeed, err := client.Feeds.Add(feed) + createdFeed, err := feeds.Add(client, feed) if err != nil { return diag.FromErr(err) } @@ -52,7 +52,7 @@ func resourceAwsElasticContainerRegistryDelete(ctx context.Context, d *schema.Re tflog.Info(ctx, fmt.Sprintf("deleting AWS Elastic Container Registry (%s)", d.Id())) client := m.(*client.Client) - err := client.Feeds.DeleteByID(d.Id()) + err := feeds.DeleteByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return diag.FromErr(err) } @@ -67,7 +67,7 @@ func resourceAwsElasticContainerRegistryRead(ctx context.Context, d *schema.Reso tflog.Info(ctx, fmt.Sprintf("reading AWS Elastic Container Registry (%s)", d.Id())) client := m.(*client.Client) - feed, err := client.Feeds.GetByID(d.Id()) + feed, err := feeds.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "AWS Elastic Container Registry") } @@ -90,7 +90,7 @@ func resourceAwsElasticContainerRegistryUpdate(ctx context.Context, d *schema.Re tflog.Info(ctx, fmt.Sprintf("updating AWS Elastic Container Registry (%s)", awsElasticContainerRegistry.GetID())) client := m.(*client.Client) - updatedFeed, err := client.Feeds.Update(awsElasticContainerRegistry) + updatedFeed, err := feeds.Update(client, awsElasticContainerRegistry) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_azure_cloud_service_deployment_target.go b/octopusdeploy/resource_azure_cloud_service_deployment_target.go index 35c341029..654074f1f 100644 --- a/octopusdeploy/resource_azure_cloud_service_deployment_target.go +++ b/octopusdeploy/resource_azure_cloud_service_deployment_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceAzureCloudServiceDeploymentTargetCreate(ctx context.Context, d *sch log.Printf("[INFO] creating Azure cloud service deployment target: %#v", deploymentTarget) client := m.(*client.Client) - createdDeploymentTarget, err := client.Machines.Add(deploymentTarget) + createdDeploymentTarget, err := machines.Add(client, deploymentTarget) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceAzureCloudServiceDeploymentTargetDelete(ctx context.Context, d *sch log.Printf("[INFO] deleting Azure cloud service deployment target (%s)", d.Id()) client := m.(*client.Client) - if err := client.Machines.DeleteByID(d.Id()); err != nil { + if err := machines.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceAzureCloudServiceDeploymentTargetRead(ctx context.Context, d *schem log.Printf("[INFO] reading Azure cloud service deployment target (%s)", d.Id()) client := m.(*client.Client) - deploymentTarget, err := client.Machines.GetByID(d.Id()) + deploymentTarget, err := machines.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Azure cloud service deployment target") } @@ -79,7 +80,7 @@ func resourceAzureCloudServiceDeploymentTargetUpdate(ctx context.Context, d *sch deploymentTarget := expandAzureCloudServiceDeploymentTarget(d) client := m.(*client.Client) - updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget) + updatedDeploymentTarget, err := machines.Update(client, deploymentTarget) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_azure_service_fabric_cluster_deployment_target.go b/octopusdeploy/resource_azure_service_fabric_cluster_deployment_target.go index 2e32acc98..1bec262e9 100644 --- a/octopusdeploy/resource_azure_service_fabric_cluster_deployment_target.go +++ b/octopusdeploy/resource_azure_service_fabric_cluster_deployment_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceAzureServiceFabricClusterDeploymentTargetCreate(ctx context.Context log.Printf("[INFO] creating Azure service fabric cluster deployment target: %#v", deploymentTarget) client := m.(*client.Client) - createdDeploymentTarget, err := client.Machines.Add(deploymentTarget) + createdDeploymentTarget, err := machines.Add(client, deploymentTarget) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceAzureServiceFabricClusterDeploymentTargetDelete(ctx context.Context log.Printf("[INFO] deleting Azure service fabric cluster deployment target (%s)", d.Id()) client := m.(*client.Client) - if err := client.Machines.DeleteByID(d.Id()); err != nil { + if err := machines.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceAzureServiceFabricClusterDeploymentTargetRead(ctx context.Context, log.Printf("[INFO] reading Azure service fabric cluster deployment target (%s)", d.Id()) client := m.(*client.Client) - deploymentTarget, err := client.Machines.GetByID(d.Id()) + deploymentTarget, err := machines.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Azure service fabric cluster deployment target") } @@ -79,7 +80,7 @@ func resourceAzureServiceFabricClusterDeploymentTargetUpdate(ctx context.Context deploymentTarget := expandAzureServiceFabricClusterDeploymentTarget(d) client := m.(*client.Client) - updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget) + updatedDeploymentTarget, err := machines.Update(client, deploymentTarget) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_azure_service_principal_account.go b/octopusdeploy/resource_azure_service_principal_account.go index b005a0aae..843f2309f 100644 --- a/octopusdeploy/resource_azure_service_principal_account.go +++ b/octopusdeploy/resource_azure_service_principal_account.go @@ -29,7 +29,7 @@ func resourceAzureServicePrincipalAccountCreate(ctx context.Context, d *schema.R log.Printf("[INFO] creating Azure service principal account: %#v", account) client := m.(*client.Client) - createdAccount, err := client.Accounts.Add(account) + createdAccount, err := accounts.Add(client, account) if err != nil { return diag.FromErr(err) } @@ -48,7 +48,7 @@ func resourceAzureServicePrincipalAccountDelete(ctx context.Context, d *schema.R log.Printf("[INFO] deleting Azure service principal account (%s)", d.Id()) client := m.(*client.Client) - if err := client.Accounts.DeleteByID(d.Id()); err != nil { + if err := accounts.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -62,7 +62,7 @@ func resourceAzureServicePrincipalAccountRead(ctx context.Context, d *schema.Res log.Printf("[INFO] reading Azure service principal account (%s)", d.Id()) client := m.(*client.Client) - accountResource, err := client.Accounts.GetByID(d.Id()) + accountResource, err := accounts.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Azure service principal account") } @@ -82,7 +82,7 @@ func resourceAzureServicePrincipalAccountUpdate(ctx context.Context, d *schema.R log.Printf("[INFO] updating Azure service principal account %#v", account) client := m.(*client.Client) - updatedAccount, err := client.Accounts.Update(account) + updatedAccount, err := accounts.Update(client, account) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_azure_subscription_account.go b/octopusdeploy/resource_azure_subscription_account.go index c7d48f75c..b56737aca 100644 --- a/octopusdeploy/resource_azure_subscription_account.go +++ b/octopusdeploy/resource_azure_subscription_account.go @@ -29,7 +29,7 @@ func resourceAzureSubscriptionAccountCreate(ctx context.Context, d *schema.Resou log.Printf("[INFO] creating Azure subscription account: %#v", account) client := m.(*client.Client) - createdAccount, err := client.Accounts.Add(account) + createdAccount, err := accounts.Add(client, account) if err != nil { return diag.FromErr(err) } @@ -48,7 +48,7 @@ func resourceAzureSubscriptionAccountDelete(ctx context.Context, d *schema.Resou log.Printf("[INFO] deleting Azure subscription account (%s)", d.Id()) client := m.(*client.Client) - if err := client.Accounts.DeleteByID(d.Id()); err != nil { + if err := accounts.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -62,7 +62,7 @@ func resourceAzureSubscriptionAccountRead(ctx context.Context, d *schema.Resourc log.Printf("[INFO] reading Azure subscription account (%s)", d.Id()) client := m.(*client.Client) - accountResource, err := client.Accounts.GetByID(d.Id()) + accountResource, err := accounts.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Azure subscription account") } @@ -82,7 +82,7 @@ func resourceAzureSubscriptionAccountUpdate(ctx context.Context, d *schema.Resou log.Printf("[INFO] updating Azure subscription account %#v", account) client := m.(*client.Client) - updatedAccount, err := client.Accounts.Update(account) + updatedAccount, err := accounts.Update(client, account) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_azure_web_app_deployment_target.go b/octopusdeploy/resource_azure_web_app_deployment_target.go index d670622b0..ee35d6393 100644 --- a/octopusdeploy/resource_azure_web_app_deployment_target.go +++ b/octopusdeploy/resource_azure_web_app_deployment_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceAzureWebAppDeploymentTargetCreate(ctx context.Context, d *schema.Re log.Printf("[INFO] creating Azure web app deployment target: %#v", deploymentTarget) client := m.(*client.Client) - createdDeploymentTarget, err := client.Machines.Add(deploymentTarget) + createdDeploymentTarget, err := machines.Add(client, deploymentTarget) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceAzureWebAppDeploymentTargetDelete(ctx context.Context, d *schema.Re log.Printf("[INFO] deleting Azure web app deployment target (%s)", d.Id()) client := m.(*client.Client) - if err := client.Machines.DeleteByID(d.Id()); err != nil { + if err := machines.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceAzureWebAppDeploymentTargetRead(ctx context.Context, d *schema.Reso log.Printf("[INFO] reading Azure web app deployment target (%s)", d.Id()) client := m.(*client.Client) - deploymentTarget, err := client.Machines.GetByID(d.Id()) + deploymentTarget, err := machines.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Azure web app deployment target") } @@ -79,7 +80,7 @@ func resourceAzureWebAppDeploymentTargetUpdate(ctx context.Context, d *schema.Re deploymentTarget := expandAzureWebAppDeploymentTarget(d) client := m.(*client.Client) - updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget) + updatedDeploymentTarget, err := machines.Update(client, deploymentTarget) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_certificate.go b/octopusdeploy/resource_certificate.go index 400262ab3..d6098964b 100644 --- a/octopusdeploy/resource_certificate.go +++ b/octopusdeploy/resource_certificate.go @@ -4,6 +4,7 @@ import ( "context" "log" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/certificates" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -28,7 +29,7 @@ func resourceCertificateCreate(ctx context.Context, d *schema.ResourceData, m in log.Printf("[INFO] creating certificate: %#v", certificate) client := m.(*client.Client) - createdCertificate, err := client.Certificates.Add(certificate) + createdCertificate, err := certificates.Add(client, certificate) if err != nil { return diag.FromErr(err) } @@ -46,8 +47,9 @@ func resourceCertificateCreate(ctx context.Context, d *schema.ResourceData, m in func resourceCertificateDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] deleting certificate (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - if err := client.Certificates.DeleteByID(d.Id()); err != nil { + if err := certificates.DeleteByID(client, spaceID, d.Id()); err != nil { return diag.FromErr(err) } @@ -60,8 +62,9 @@ func resourceCertificateDelete(ctx context.Context, d *schema.ResourceData, m in func resourceCertificateRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] reading certificate (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - certificate, err := client.Certificates.GetByID(d.Id()) + certificate, err := certificates.GetByID(client, spaceID, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "certificate") } @@ -79,7 +82,7 @@ func resourceCertificateUpdate(ctx context.Context, d *schema.ResourceData, m in certificate := expandCertificate(d) client := m.(*client.Client) - updatedCertificate, err := client.Certificates.Update(*certificate) + updatedCertificate, err := certificates.Update(client, certificate) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_channel.go b/octopusdeploy/resource_channel.go index 0401b043e..397f52001 100644 --- a/octopusdeploy/resource_channel.go +++ b/octopusdeploy/resource_channel.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/channels" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -32,7 +33,7 @@ func resourceChannelCreate(ctx context.Context, d *schema.ResourceData, m interf tflog.Info(ctx, fmt.Sprintf("creating channel: %#v", channel)) client := m.(*client.Client) - createdChannel, err := client.Channels.Add(channel) + createdChannel, err := channels.Add(client, channel) if err != nil { return diag.FromErr(err) } @@ -54,7 +55,7 @@ func resourceChannelDelete(ctx context.Context, d *schema.ResourceData, m interf tflog.Info(ctx, fmt.Sprintf("deleting channel (%s)", d.Id())) client := m.(*client.Client) - if err := client.Channels.DeleteByID(d.Id()); err != nil { + if err := channels.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -68,7 +69,7 @@ func resourceChannelRead(ctx context.Context, d *schema.ResourceData, m interfac tflog.Info(ctx, fmt.Sprintf("reading channel (%s)", d.Id())) client := m.(*client.Client) - channel, err := client.Channels.GetByID(d.Id()) + channel, err := channels.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "channel") } @@ -89,7 +90,7 @@ func resourceChannelUpdate(ctx context.Context, d *schema.ResourceData, m interf channel := expandChannel(d) client := m.(*client.Client) - updatedChannel, err := client.Channels.Update(channel) + updatedChannel, err := channels.Update(client, channel) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_cloud_region_deployment_target.go b/octopusdeploy/resource_cloud_region_deployment_target.go index 2bf0babb0..0905c45c3 100644 --- a/octopusdeploy/resource_cloud_region_deployment_target.go +++ b/octopusdeploy/resource_cloud_region_deployment_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceCloudRegionDeploymentTargetCreate(ctx context.Context, d *schema.Re log.Printf("[INFO] creating cloud region deployment target: %#v", deploymentTarget) client := m.(*client.Client) - createdDeploymentTarget, err := client.Machines.Add(deploymentTarget) + createdDeploymentTarget, err := machines.Add(client, deploymentTarget) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceCloudRegionDeploymentTargetDelete(ctx context.Context, d *schema.Re log.Printf("[INFO] deleting cloud region deployment target (%s)", d.Id()) client := m.(*client.Client) - if err := client.Machines.DeleteByID(d.Id()); err != nil { + if err := machines.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceCloudRegionDeploymentTargetRead(ctx context.Context, d *schema.Reso log.Printf("[INFO] reading cloud region deployment target (%s)", d.Id()) client := m.(*client.Client) - deploymentTarget, err := client.Machines.GetByID(d.Id()) + deploymentTarget, err := machines.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "cloud region deployment target") } @@ -79,7 +80,7 @@ func resourceCloudRegionDeploymentTargetUpdate(ctx context.Context, d *schema.Re deploymentTarget := expandCloudRegionDeploymentTarget(d) client := m.(*client.Client) - updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget) + updatedDeploymentTarget, err := machines.Update(client, deploymentTarget) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_docker_container_registry.go b/octopusdeploy/resource_docker_container_registry.go index 195f8314e..bf5d1edd8 100644 --- a/octopusdeploy/resource_docker_container_registry.go +++ b/octopusdeploy/resource_docker_container_registry.go @@ -33,7 +33,7 @@ func resourceDockerContainerRegistryCreate(ctx context.Context, d *schema.Resour tflog.Info(ctx, fmt.Sprintf("creating Docker container registry, %s", dockerContainerRegistry.GetName())) client := m.(*client.Client) - createdDockerContainerRegistry, err := client.Feeds.Add(dockerContainerRegistry) + createdDockerContainerRegistry, err := feeds.Add(client, dockerContainerRegistry) if err != nil { return diag.FromErr(err) } @@ -67,7 +67,7 @@ func resourceDockerContainerRegistryRead(ctx context.Context, d *schema.Resource tflog.Info(ctx, fmt.Sprintf("reading Docker container registry (%s)", d.Id())) client := m.(*client.Client) - feed, err := client.Feeds.GetByID(d.Id()) + feed, err := feeds.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Docker container registry") } @@ -90,7 +90,7 @@ func resourceDockerContainerRegistryUpdate(ctx context.Context, d *schema.Resour tflog.Info(ctx, fmt.Sprintf("updating Docker container registry (%s)", feed.GetID())) client := m.(*client.Client) - updatedFeed, err := client.Feeds.Update(feed) + updatedFeed, err := feeds.Update(client, feed) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_dynamic_worker_pool.go b/octopusdeploy/resource_dynamic_worker_pool.go index ff99aa48f..4d060e118 100644 --- a/octopusdeploy/resource_dynamic_worker_pool.go +++ b/octopusdeploy/resource_dynamic_worker_pool.go @@ -29,7 +29,7 @@ func resourceDynamicWorkerPoolCreate(ctx context.Context, d *schema.ResourceData log.Printf("[INFO] creating dynamic worker pool: %#v", workerPool) client := m.(*client.Client) - createdWorkerPool, err := client.WorkerPools.Add(workerPool) + createdWorkerPool, err := workerpools.Add(client, workerPool) if err != nil { return diag.FromErr(err) } @@ -47,9 +47,10 @@ func resourceDynamicWorkerPoolCreate(ctx context.Context, d *schema.ResourceData func resourceDynamicWorkerPoolDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] deleting dynamic worker pool (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - if err := client.WorkerPools.DeleteByID(d.Id()); err != nil { + if err := workerpools.DeleteByID(client, spaceID, d.Id()); err != nil { return diag.FromErr(err) } @@ -62,8 +63,9 @@ func resourceDynamicWorkerPoolDelete(ctx context.Context, d *schema.ResourceData func resourceDynamicWorkerPoolRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] reading dynamic worker pool (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - workerPoolResource, err := client.WorkerPools.GetByID(d.Id()) + workerPoolResource, err := workerpools.GetByID(client, spaceID, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "dynamic worker pool") } @@ -83,7 +85,7 @@ func resourceDynamicWorkerPoolUpdate(ctx context.Context, d *schema.ResourceData log.Printf("[INFO] updating dynamic worker pool (%s)", d.Id()) client := m.(*client.Client) - updatedWorkerPool, err := client.WorkerPools.Update(workerPool) + updatedWorkerPool, err := workerpools.Update(client, workerPool) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_environment.go b/octopusdeploy/resource_environment.go index c5e8f5a77..68a3f737a 100644 --- a/octopusdeploy/resource_environment.go +++ b/octopusdeploy/resource_environment.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, m in log.Printf("[INFO] creating environment: %#v", environment) client := m.(*client.Client) - createdEnvironment, err := client.Environments.Add(environment) + createdEnvironment, err := environments.Add(client, environment) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceEnvironmentDelete(ctx context.Context, d *schema.ResourceData, m in log.Printf("[INFO] deleting environment (%s)", d.Id()) client := m.(*client.Client) - if err := client.Environments.DeleteByID(d.Id()); err != nil { + if err := environments.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -60,7 +61,7 @@ func resourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, m inte log.Printf("[INFO] reading environment (%s)", d.Id()) client := m.(*client.Client) - environment, err := client.Environments.GetByID(d.Id()) + environment, err := environments.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "environment") } @@ -78,7 +79,7 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, m in environment := expandEnvironment(d) client := m.(*client.Client) - updatedEnvironment, err := client.Environments.Update(environment) + updatedEnvironment, err := environments.Update(client, environment) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_gcp_account.go b/octopusdeploy/resource_gcp_account.go index e13aa297d..3d4b3e6e2 100644 --- a/octopusdeploy/resource_gcp_account.go +++ b/octopusdeploy/resource_gcp_account.go @@ -29,7 +29,7 @@ func resourceGoogleCloudPlatformAccountCreate(ctx context.Context, d *schema.Res log.Printf("[INFO] creating GCP account: %#v", account) client := m.(*client.Client) - createdAccount, err := client.Accounts.Add(account) + createdAccount, err := accounts.Add(client, account) if err != nil { return diag.FromErr(err) } @@ -48,7 +48,7 @@ func resourceGoogleCloudPlatformAccountDelete(ctx context.Context, d *schema.Res log.Printf("[INFO] deleting GCP account (%s)", d.Id()) client := m.(*client.Client) - if err := client.Accounts.DeleteByID(d.Id()); err != nil { + if err := accounts.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -62,7 +62,7 @@ func resourceGoogleCloudPlatformAccountRead(ctx context.Context, d *schema.Resou log.Printf("[INFO] reading GCP account (%s)", d.Id()) client := m.(*client.Client) - accountResource, err := client.Accounts.GetByID(d.Id()) + accountResource, err := accounts.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "GCP account") } @@ -82,7 +82,7 @@ func resourceGoogleCloudPlatformAccountUpdate(ctx context.Context, d *schema.Res log.Printf("[INFO] updating GCP account: %#v", account) client := m.(*client.Client) - updatedAccount, err := client.Accounts.Update(account) + updatedAccount, err := accounts.Update(client, account) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_git_credential.go b/octopusdeploy/resource_git_credential.go index ed3fd38de..6fdb4cd79 100644 --- a/octopusdeploy/resource_git_credential.go +++ b/octopusdeploy/resource_git_credential.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -29,12 +30,12 @@ func resourceGitCredentialCreate(ctx context.Context, d *schema.ResourceData, m tflog.Info(ctx, fmt.Sprintf("creating Git credential, %s", resource.Name)) client := m.(*client.Client) - createdResource, err := client.GitCredentials.Add(resource) + createdResource, err := credentials.Add(client, resource) if err != nil { return diag.FromErr(err) } - createdResource, err = client.GitCredentials.GetByID(createdResource.GetID()) + createdResource, err = credentials.GetByID(client, d.Get("space_id").(string), createdResource.GetID()) if err != nil { return diag.FromErr(err) } @@ -53,7 +54,7 @@ func resourceGitCredentialDelete(ctx context.Context, d *schema.ResourceData, m tflog.Info(ctx, fmt.Sprintf("deleting Git credential (%s)", d.Id())) client := m.(*client.Client) - if err := client.GitCredentials.DeleteByID(d.Id()); err != nil { + if err := credentials.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -67,7 +68,7 @@ func resourceGitCredentialRead(ctx context.Context, d *schema.ResourceData, m in tflog.Info(ctx, fmt.Sprintf("reading Git credential (%s)", d.Id())) client := m.(*client.Client) - resource, err := client.GitCredentials.GetByID(d.Id()) + resource, err := credentials.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Git credential") } @@ -86,7 +87,7 @@ func resourceGitCredentialUpdate(ctx context.Context, d *schema.ResourceData, m tflog.Info(ctx, fmt.Sprintf("updating Git credential (%s)", resource.GetID())) client := m.(*client.Client) - updatedResource, err := client.GitCredentials.Update(resource) + updatedResource, err := credentials.Update(client, resource) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_github_repository_feed.go b/octopusdeploy/resource_github_repository_feed.go index 7be418671..81d899745 100644 --- a/octopusdeploy/resource_github_repository_feed.go +++ b/octopusdeploy/resource_github_repository_feed.go @@ -33,7 +33,7 @@ func resourceGitHubRepositoryFeedCreate(ctx context.Context, d *schema.ResourceD tflog.Info(ctx, fmt.Sprintf("creating GitHub repository feed, %s", feed.GetName())) client := m.(*client.Client) - createdGitHubRepositoryFeed, err := client.Feeds.Add(feed) + createdGitHubRepositoryFeed, err := feeds.Add(client, feed) if err != nil { return diag.FromErr(err) } @@ -52,7 +52,7 @@ func resourceGitHubRepositoryFeedDelete(ctx context.Context, d *schema.ResourceD tflog.Info(ctx, fmt.Sprintf("deleting GitHub repository feed (%s)", d.Id())) client := m.(*client.Client) - err := client.Feeds.DeleteByID(d.Id()) + err := feeds.DeleteByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return diag.FromErr(err) } @@ -67,7 +67,7 @@ func resourceGitHubRepositoryFeedRead(ctx context.Context, d *schema.ResourceDat tflog.Info(ctx, fmt.Sprintf("reading GitHub repository feed (%s)", d.Id())) client := m.(*client.Client) - feed, err := client.Feeds.GetByID(d.Id()) + feed, err := feeds.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "GitHub repository feed") } @@ -90,7 +90,7 @@ func resourceGitHubRepositoryFeedUpdate(ctx context.Context, d *schema.ResourceD tflog.Info(ctx, fmt.Sprintf("updating GitHub repository feed (%s)", feed.GetID())) client := m.(*client.Client) - updatedFeed, err := client.Feeds.Update(feed) + updatedFeed, err := feeds.Update(client, feed) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_helm_feed.go b/octopusdeploy/resource_helm_feed.go index 81d60029e..d05cefb68 100644 --- a/octopusdeploy/resource_helm_feed.go +++ b/octopusdeploy/resource_helm_feed.go @@ -33,7 +33,7 @@ func resourceHelmFeedCreate(ctx context.Context, d *schema.ResourceData, m inter tflog.Info(ctx, fmt.Sprintf("creating Helm feed, %s", feed.GetName())) client := m.(*client.Client) - createdFeed, err := client.Feeds.Add(feed) + createdFeed, err := feeds.Add(client, feed) if err != nil { return diag.FromErr(err) } @@ -52,7 +52,7 @@ func resourceHelmFeedDelete(ctx context.Context, d *schema.ResourceData, m inter tflog.Info(ctx, fmt.Sprintf("deleting Helm feed (%s)", d.Id())) client := m.(*client.Client) - err := client.Feeds.DeleteByID(d.Id()) + err := feeds.DeleteByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return diag.FromErr(err) } @@ -67,7 +67,7 @@ func resourceHelmFeedRead(ctx context.Context, d *schema.ResourceData, m interfa tflog.Info(ctx, fmt.Sprintf("reading Helm feed (%s)", d.Id())) client := m.(*client.Client) - feed, err := client.Feeds.GetByID(d.Id()) + feed, err := feeds.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Helm feed") } @@ -90,7 +90,7 @@ func resourceHelmFeedUpdate(ctx context.Context, d *schema.ResourceData, m inter tflog.Info(ctx, fmt.Sprintf("updating Helm feed (%s)", feed.GetID())) client := m.(*client.Client) - updatedFeed, err := client.Feeds.Update(feed) + updatedFeed, err := feeds.Update(client, feed) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_kubernetes_cluster_deployment_target.go b/octopusdeploy/resource_kubernetes_cluster_deployment_target.go index 811becab1..a2fb2e8d6 100644 --- a/octopusdeploy/resource_kubernetes_cluster_deployment_target.go +++ b/octopusdeploy/resource_kubernetes_cluster_deployment_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceKubernetesClusterDeploymentTargetCreate(ctx context.Context, d *sch log.Printf("[INFO] creating Kubernetes cluster deployment target: %#v", deploymentTarget) client := m.(*client.Client) - createdDeploymentTarget, err := client.Machines.Add(deploymentTarget) + createdDeploymentTarget, err := machines.Add(client, deploymentTarget) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceKubernetesClusterDeploymentTargetDelete(ctx context.Context, d *sch log.Printf("[INFO] deleting Kubernetes cluster deployment target (%s)", d.Id()) client := m.(*client.Client) - if err := client.Machines.DeleteByID(d.Id()); err != nil { + if err := machines.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceKubernetesClusterDeploymentTargetRead(ctx context.Context, d *schem log.Printf("[INFO] reading Kubernetes cluster deployment target (%s)", d.Id()) client := m.(*client.Client) - deploymentTarget, err := client.Machines.GetByID(d.Id()) + deploymentTarget, err := machines.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Kubernetes cluster deployment target") } @@ -79,7 +80,7 @@ func resourceKubernetesClusterDeploymentTargetUpdate(ctx context.Context, d *sch deploymentTarget := expandKubernetesClusterDeploymentTarget(d) client := m.(*client.Client) - updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget) + updatedDeploymentTarget, err := machines.Update(client, deploymentTarget) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_library_variable_set.go b/octopusdeploy/resource_library_variable_set.go index 7e8999b93..732b83e28 100644 --- a/octopusdeploy/resource_library_variable_set.go +++ b/octopusdeploy/resource_library_variable_set.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/libraryvariablesets" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,8 @@ func resourceLibraryVariableSetCreate(ctx context.Context, d *schema.ResourceDat log.Printf("[INFO] creating library variable set: %#v", libraryVariableSet) client := m.(*client.Client) - createdLibraryVariableSet, err := client.LibraryVariableSets.Add(libraryVariableSet) + + createdLibraryVariableSet, err := libraryvariablesets.Add(client, libraryVariableSet) if err != nil { return diag.FromErr(err) } @@ -46,8 +48,13 @@ func resourceLibraryVariableSetCreate(ctx context.Context, d *schema.ResourceDat func resourceLibraryVariableSetDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] deleting library variable set (%s)", d.Id()) + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + client := m.(*client.Client) - err := client.LibraryVariableSets.DeleteByID(d.Id()) + err := libraryvariablesets.DeleteByID(client, spaceID, d.Id()) if err != nil { return diag.FromErr(err) } @@ -60,8 +67,13 @@ func resourceLibraryVariableSetDelete(ctx context.Context, d *schema.ResourceDat func resourceLibraryVariableSetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] reading library variable set (%s)", d.Id()) + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + client := m.(*client.Client) - libraryVariableSet, err := client.LibraryVariableSets.GetByID(d.Id()) + libraryVariableSet, err := libraryvariablesets.GetByID(client, spaceID, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "library variable set") } @@ -80,7 +92,7 @@ func resourceLibraryVariableSetUpdate(ctx context.Context, d *schema.ResourceDat libraryVariableSet := expandLibraryVariableSet(d) client := m.(*client.Client) - updatedLibraryVariableSet, err := client.LibraryVariableSets.Update(libraryVariableSet) + updatedLibraryVariableSet, err := libraryvariablesets.Update(client, libraryVariableSet) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_lifecycle.go b/octopusdeploy/resource_lifecycle.go index 7f50bdd51..c71dbee5e 100644 --- a/octopusdeploy/resource_lifecycle.go +++ b/octopusdeploy/resource_lifecycle.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/lifecycles" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceLifecycleCreate(ctx context.Context, d *schema.ResourceData, m inte log.Printf("[INFO] creating lifecycle: %#v", lifecycle) client := m.(*client.Client) - createdLifecycle, err := client.Lifecycles.Add(lifecycle) + createdLifecycle, err := lifecycles.Add(client, lifecycle) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceLifecycleDelete(ctx context.Context, d *schema.ResourceData, m inte log.Printf("[INFO] deleting lifecycle (%s)", d.Id()) client := m.(*client.Client) - if err := client.Lifecycles.DeleteByID(d.Id()); err != nil { + if err := lifecycles.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -60,7 +61,7 @@ func resourceLifecycleRead(ctx context.Context, d *schema.ResourceData, m interf log.Printf("[INFO] reading lifecycle (%s)", d.Id()) client := m.(*client.Client) - lifecycle, err := client.Lifecycles.GetByID(d.Id()) + lifecycle, err := lifecycles.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "lifecycle") } @@ -79,7 +80,7 @@ func resourceLifecycleUpdate(ctx context.Context, d *schema.ResourceData, m inte lifecycle := expandLifecycle(d) client := m.(*client.Client) - updatedLifecycle, err := client.Lifecycles.Update(lifecycle) + updatedLifecycle, err := lifecycles.Update(client, lifecycle) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_listening_tentacle_deployment_target.go b/octopusdeploy/resource_listening_tentacle_deployment_target.go index 3d0635142..711ea2b5f 100644 --- a/octopusdeploy/resource_listening_tentacle_deployment_target.go +++ b/octopusdeploy/resource_listening_tentacle_deployment_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceListeningTentacleDeploymentTargetCreate(ctx context.Context, d *sch log.Printf("[INFO] creating listening tentacle deployment target: %#v", deploymentTarget) client := m.(*client.Client) - createdDeploymentTarget, err := client.Machines.Add(deploymentTarget) + createdDeploymentTarget, err := machines.Add(client, deploymentTarget) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceListeningTentacleDeploymentTargetDelete(ctx context.Context, d *sch log.Printf("[INFO] deleting listening tentacle deployment target (%s)", d.Id()) client := m.(*client.Client) - if err := client.Machines.DeleteByID(d.Id()); err != nil { + if err := machines.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceListeningTentacleDeploymentTargetRead(ctx context.Context, d *schem log.Printf("[INFO] reading listening tentacle deployment target (%s)", d.Id()) client := m.(*client.Client) - deploymentTarget, err := client.Machines.GetByID(d.Id()) + deploymentTarget, err := machines.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "listening tentacle deployment target") } @@ -79,7 +80,7 @@ func resourceListeningTentacleDeploymentTargetUpdate(ctx context.Context, d *sch deploymentTarget := expandListeningTentacleDeploymentTarget(d) client := m.(*client.Client) - updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget) + updatedDeploymentTarget, err := machines.Update(client, deploymentTarget) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_machine_policy.go b/octopusdeploy/resource_machine_policy.go index 0616baf5a..ab759fc7a 100644 --- a/octopusdeploy/resource_machine_policy.go +++ b/octopusdeploy/resource_machine_policy.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machinepolicies" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceMachinePolicyCreate(ctx context.Context, d *schema.ResourceData, m log.Printf("[INFO] creating machine policy: %#v", machinePolicy) client := m.(*client.Client) - createdMachinePolicy, err := client.MachinePolicies.Add(machinePolicy) + createdMachinePolicy, err := machinepolicies.Add(client, machinePolicy) if err != nil { return diag.FromErr(err) } @@ -46,8 +47,9 @@ func resourceMachinePolicyCreate(ctx context.Context, d *schema.ResourceData, m func resourceMachinePolicyDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] deleting machine policy (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - if err := client.MachinePolicies.DeleteByID(d.Id()); err != nil { + if err := machinepolicies.DeleteByID(client, spaceID, d.Id()); err != nil { return diag.FromErr(err) } @@ -60,8 +62,9 @@ func resourceMachinePolicyDelete(ctx context.Context, d *schema.ResourceData, m func resourceMachinePolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] reading machine policy (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - machinePolicy, err := client.MachinePolicies.GetByID(d.Id()) + machinePolicy, err := machinepolicies.GetByID(client, spaceID, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "machine policy") } @@ -79,7 +82,7 @@ func resourceMachinePolicyUpdate(ctx context.Context, d *schema.ResourceData, m machinePolicy := expandMachinePolicy(d) client := m.(*client.Client) - updatedMachinePolicy, err := client.MachinePolicies.Update(machinePolicy) + updatedMachinePolicy, err := machinepolicies.Update(client, machinePolicy) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_maven_feed.go b/octopusdeploy/resource_maven_feed.go index 8b1d81d24..6483c0c0d 100644 --- a/octopusdeploy/resource_maven_feed.go +++ b/octopusdeploy/resource_maven_feed.go @@ -33,7 +33,7 @@ func resourceMavenFeedCreate(ctx context.Context, d *schema.ResourceData, m inte tflog.Info(ctx, fmt.Sprintf("creating Maven feed: %s", mavenFeed.GetName())) client := m.(*client.Client) - createdFeed, err := client.Feeds.Add(mavenFeed) + createdFeed, err := feeds.Add(client, mavenFeed) if err != nil { return diag.FromErr(err) } @@ -52,7 +52,7 @@ func resourceMavenFeedDelete(ctx context.Context, d *schema.ResourceData, m inte tflog.Info(ctx, fmt.Sprintf("deleting Maven feed (%s)", d.Id())) client := m.(*client.Client) - err := client.Feeds.DeleteByID(d.Id()) + err := feeds.DeleteByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return diag.FromErr(err) } @@ -67,7 +67,7 @@ func resourceMavenFeedRead(ctx context.Context, d *schema.ResourceData, m interf tflog.Info(ctx, fmt.Sprintf("reading Maven feed (%s)", d.Id())) client := m.(*client.Client) - feed, err := client.Feeds.GetByID(d.Id()) + feed, err := feeds.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Maven feed") } @@ -90,7 +90,7 @@ func resourceMavenFeedUpdate(ctx context.Context, d *schema.ResourceData, m inte tflog.Info(ctx, fmt.Sprintf("updating Maven feed (%s)", feed.GetID())) client := m.(*client.Client) - updatedFeed, err := client.Feeds.Update(feed) + updatedFeed, err := feeds.Update(client, feed) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_nuget_feed.go b/octopusdeploy/resource_nuget_feed.go index 97b9fea95..1aa53e699 100644 --- a/octopusdeploy/resource_nuget_feed.go +++ b/octopusdeploy/resource_nuget_feed.go @@ -33,7 +33,7 @@ func resourceNuGetFeedCreate(ctx context.Context, d *schema.ResourceData, m inte tflog.Info(ctx, fmt.Sprintf("creating NuGet feed: %s", feed.GetName())) client := m.(*client.Client) - createdFeed, err := client.Feeds.Add(feed) + createdFeed, err := feeds.Add(client, feed) if err != nil { return diag.FromErr(err) } @@ -52,7 +52,7 @@ func resourceNuGetFeedDelete(ctx context.Context, d *schema.ResourceData, m inte tflog.Info(ctx, fmt.Sprintf("deleting NuGet feed (%s)", d.Id())) client := m.(*client.Client) - err := client.Feeds.DeleteByID(d.Id()) + err := feeds.DeleteByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return diag.FromErr(err) } @@ -67,7 +67,7 @@ func resourceNuGetFeedRead(ctx context.Context, d *schema.ResourceData, m interf tflog.Info(ctx, fmt.Sprintf("reading NuGet feed (%s)", d.Id())) client := m.(*client.Client) - feed, err := client.Feeds.GetByID(d.Id()) + feed, err := feeds.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "NuGet feed") } @@ -90,7 +90,7 @@ func resourceNuGetFeedUpdate(ctx context.Context, d *schema.ResourceData, m inte tflog.Info(ctx, fmt.Sprintf("updating NuGet feed (%s)", feed.GetID())) client := m.(*client.Client) - updatedFeed, err := client.Feeds.Update(feed) + updatedFeed, err := feeds.Update(client, feed) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_offline_package_drop_deployment_target.go b/octopusdeploy/resource_offline_package_drop_deployment_target.go index 788ed2bf0..2e516c232 100644 --- a/octopusdeploy/resource_offline_package_drop_deployment_target.go +++ b/octopusdeploy/resource_offline_package_drop_deployment_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceOfflinePackageDropDeploymentTargetCreate(ctx context.Context, d *sc log.Printf("[INFO] creating offline package drop deployment target: %#v", deploymentTarget) client := m.(*client.Client) - createdDeploymentTarget, err := client.Machines.Add(deploymentTarget) + createdDeploymentTarget, err := machines.Add(client, deploymentTarget) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceOfflinePackageDropDeploymentTargetDelete(ctx context.Context, d *sc log.Printf("[INFO] deleting offline package drop deployment target (%s)", d.Id()) client := m.(*client.Client) - if err := client.Machines.DeleteByID(d.Id()); err != nil { + if err := machines.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceOfflinePackageDropDeploymentTargetRead(ctx context.Context, d *sche log.Printf("[INFO] reading offline package drop deployment target (%s)", d.Id()) client := m.(*client.Client) - deploymentTarget, err := client.Machines.GetByID(d.Id()) + deploymentTarget, err := machines.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "offline package drop deployment target") } @@ -79,7 +80,7 @@ func resourceOfflinePackageDropDeploymentTargetUpdate(ctx context.Context, d *sc deploymentTarget := expandOfflinePackageDropDeploymentTarget(d) client := m.(*client.Client) - updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget) + updatedDeploymentTarget, err := machines.Update(client, deploymentTarget) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_polling_tentacle_deployment_target.go b/octopusdeploy/resource_polling_tentacle_deployment_target.go index cfc0f3a05..7b9a4c14a 100644 --- a/octopusdeploy/resource_polling_tentacle_deployment_target.go +++ b/octopusdeploy/resource_polling_tentacle_deployment_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourcePollingTentacleDeploymentTargetCreate(ctx context.Context, d *schem log.Printf("[INFO] creating polling tentacle deployment target: %#v", deploymentTarget) client := m.(*client.Client) - createdDeploymentTarget, err := client.Machines.Add(deploymentTarget) + createdDeploymentTarget, err := machines.Add(client, deploymentTarget) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourcePollingTentacleDeploymentTargetDelete(ctx context.Context, d *schem log.Printf("[INFO] deleting polling tentacle deployment target (%s)", d.Id()) client := m.(*client.Client) - if err := client.Machines.DeleteByID(d.Id()); err != nil { + if err := machines.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourcePollingTentacleDeploymentTargetRead(ctx context.Context, d *schema. log.Printf("[INFO] reading polling tentacle deployment target (%s)", d.Id()) client := m.(*client.Client) - deploymentTarget, err := client.Machines.GetByID(d.Id()) + deploymentTarget, err := machines.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "polling tentacle deployment target") } @@ -79,7 +80,7 @@ func resourcePollingTentacleDeploymentTargetUpdate(ctx context.Context, d *schem deploymentTarget := expandPollingTentacleDeploymentTarget(d) client := m.(*client.Client) - updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget) + updatedDeploymentTarget, err := machines.Update(client, deploymentTarget) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_project.go b/octopusdeploy/resource_project.go index b10f79436..a45eb4577 100644 --- a/octopusdeploy/resource_project.go +++ b/octopusdeploy/resource_project.go @@ -33,8 +33,13 @@ func resourceProjectCreate(ctx context.Context, d *schema.ResourceData, m interf tflog.Info(ctx, fmt.Sprintf("creating project (%s)", project.Name)) + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + client := m.(*client.Client) - createdProject, err := client.Projects.Add(project) + createdProject, err := projects.Add(client, project) if err != nil { return diag.FromErr(err) } @@ -42,15 +47,15 @@ func resourceProjectCreate(ctx context.Context, d *schema.ResourceData, m interf if persistenceSettings != nil && persistenceSettings.Type() == projects.PersistenceSettingsTypeVersionControlled { tflog.Info(ctx, "converting project to use VCS") - vcsProject, err := client.Projects.ConvertToVcs(createdProject, "converting project to use VCS", "", persistenceSettings.(projects.GitPersistenceSettings)) + vcsProject, err := projects.ConvertToVCS(client, createdProject, "converting project to use VCS", "", persistenceSettings.(projects.GitPersistenceSettings)) if err != nil { - client.Projects.DeleteByID(createdProject.GetID()) + projects.DeleteByID(client, spaceID, createdProject.GetID()) return diag.FromErr(err) } createdProject.PersistenceSettings = vcsProject.PersistenceSettings } - createdProject, err = client.Projects.GetByID(createdProject.GetID()) + createdProject, err = projects.GetByID(client, spaceID, createdProject.GetID()) if err != nil { return diag.FromErr(err) } @@ -68,8 +73,13 @@ func resourceProjectCreate(ctx context.Context, d *schema.ResourceData, m interf func resourceProjectDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, fmt.Sprintf("deleting project (%s)", d.Id())) + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + client := m.(*client.Client) - if err := client.Projects.DeleteByID(d.Id()); err != nil { + if err := projects.DeleteByID(client, spaceID, d.Id()); err != nil { return diag.FromErr(err) } @@ -81,8 +91,13 @@ func resourceProjectDelete(ctx context.Context, d *schema.ResourceData, m interf func resourceProjectRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, fmt.Sprintf("reading project (%s)", d.Id())) + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + client := m.(*client.Client) - project, err := client.Projects.GetByID(d.Id()) + project, err := projects.GetByID(client, spaceID, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "project") } @@ -103,7 +118,7 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, m interf var updatedProject *projects.Project var err error - projectLinks, err := client.Projects.GetByID(d.Id()) + projectLinks, err := projects.GetByID(client, project.SpaceID, d.Id()) if err != nil { return diag.FromErr(err) } @@ -117,7 +132,7 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, m interf tflog.Info(ctx, fmt.Sprintf("converting project to use VCS (%s)", d.Id())) project.Links["ConvertToVcs"] = convertToVcsLink - vcsProject, err := client.Projects.ConvertToVcs(project, "converting project to use VCS", "", versionControlSettings) + vcsProject, err := projects.ConvertToVCS(client, project, "converting project to use VCS", "", versionControlSettings) if err != nil { return diag.FromErr(err) } @@ -127,7 +142,7 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, m interf project.Links = projectLinks.Links - updatedProject, err = client.Projects.Update(project) + updatedProject, err = projects.Update(client, project) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_project_group.go b/octopusdeploy/resource_project_group.go index 6bc575ef0..b03cc8654 100644 --- a/octopusdeploy/resource_project_group.go +++ b/octopusdeploy/resource_project_group.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projectgroups" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceProjectGroupCreate(ctx context.Context, d *schema.ResourceData, m i log.Printf("[INFO] creating project group: %#v", projectGroup) client := m.(*client.Client) - createdProjectGroup, err := client.ProjectGroups.Add(projectGroup) + createdProjectGroup, err := projectgroups.Add(client, projectGroup) if err != nil { return diag.FromErr(err) } @@ -46,8 +47,13 @@ func resourceProjectGroupCreate(ctx context.Context, d *schema.ResourceData, m i func resourceProjectGroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] deleting project group (%s)", d.Id()) + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + client := m.(*client.Client) - if err := client.ProjectGroups.DeleteByID(d.Id()); err != nil { + if err := projectgroups.DeleteByID(client, spaceID, d.Id()); err != nil { return diag.FromErr(err) } @@ -59,8 +65,13 @@ func resourceProjectGroupDelete(ctx context.Context, d *schema.ResourceData, m i func resourceProjectGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] reading project group (%s)", d.Id()) + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + client := m.(*client.Client) - projectGroup, err := client.ProjectGroups.GetByID(d.Id()) + projectGroup, err := projectgroups.GetByID(client, spaceID, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "project group") } @@ -77,8 +88,9 @@ func resourceProjectGroupUpdate(ctx context.Context, d *schema.ResourceData, m i log.Printf("[INFO] updating project group (%s)", d.Id()) projectGroup := expandProjectGroup(d) + client := m.(*client.Client) - updatedProjectGroup, err := client.ProjectGroups.Update(*projectGroup) + updatedProjectGroup, err := projectgroups.Update(client, *projectGroup) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_runbook.go b/octopusdeploy/resource_runbook.go index 8316c07b0..7497a1a04 100644 --- a/octopusdeploy/resource_runbook.go +++ b/octopusdeploy/resource_runbook.go @@ -30,7 +30,7 @@ func resourceRunbookCreate(ctx context.Context, d *schema.ResourceData, m interf tflog.Info(ctx, fmt.Sprintf("creating runbook (%s)", runbook.Name)) client := m.(*client.Client) - createdRunbook, err := client.Runbooks.Add(runbook) + createdRunbook, err := runbooks.Add(client, runbook) if err != nil { return diag.FromErr(err) } @@ -49,7 +49,7 @@ func resourceRunbookDelete(ctx context.Context, d *schema.ResourceData, m interf tflog.Info(ctx, fmt.Sprintf("deleting runbook (%s)", d.Id())) client := m.(*client.Client) - if err := client.Runbooks.DeleteByID(d.Id()); err != nil { + if err := runbooks.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -62,7 +62,7 @@ func resourceRunbookRead(ctx context.Context, d *schema.ResourceData, m interfac tflog.Info(ctx, fmt.Sprintf("reading runbook (%s)", d.Id())) client := m.(*client.Client) - runbook, err := client.Runbooks.GetByID(d.Id()) + runbook, err := runbooks.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "runbook") } @@ -83,14 +83,14 @@ func resourceRunbookUpdate(ctx context.Context, d *schema.ResourceData, m interf var updatedRunbook *runbooks.Runbook var err error - runbookLinks, err := client.Runbooks.GetByID(d.Id()) + runbookLinks, err := runbooks.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return diag.FromErr(err) } runbook.Links = runbookLinks.Links - updatedRunbook, err = client.Runbooks.Update(runbook) + updatedRunbook, err = runbooks.Update(client, runbook) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_runbook_process.go b/octopusdeploy/resource_runbook_process.go index 7c2c3e217..96e135174 100644 --- a/octopusdeploy/resource_runbook_process.go +++ b/octopusdeploy/resource_runbook_process.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/runbookprocess" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/runbooks" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -61,19 +62,19 @@ func resourceRunbookProcessCreate(ctx context.Context, d *schema.ResourceData, m log.Printf("[INFO] creating runbook process: %#v", runbookProcess) - runbook, err := client.Runbooks.GetByID(runbookProcess.RunbookID) + runbook, err := runbooks.GetByID(client, d.Get("space_id").(string), runbookProcess.RunbookID) if err != nil { return diag.FromErr(err) } - var current *runbooks.RunbookProcess - current, err = client.RunbookProcesses.GetByID(runbook.RunbookProcessID) + var current *runbookprocess.RunbookProcess + current, err = runbookprocess.GetByID(client, d.Get("space_id").(string), runbook.RunbookProcessID) runbookProcess.ID = current.ID runbookProcess.Links = current.Links runbookProcess.Version = current.Version - createdRunbookProcess, err := client.RunbookProcesses.Update(runbookProcess) + createdRunbookProcess, err := runbookprocess.Update(client, runbookProcess) if err != nil { return diag.FromErr(err) @@ -96,19 +97,22 @@ func resourceRunbookProcessDelete(ctx context.Context, d *schema.ResourceData, m // "Deleting" a runbook process just means to clear it out client := m.(*client.Client) - current, err := client.RunbookProcesses.GetByID(d.Id()) + current, err := runbookprocess.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return diag.FromErr(err) } - runbookProcess := &runbooks.RunbookProcess{ + runbookProcess := &runbookprocess.RunbookProcess{ Version: current.Version, } runbookProcess.Links = current.Links runbookProcess.ID = d.Id() + if v, ok := d.GetOk("space_id"); ok { + runbookProcess.SpaceID = v.(string) + } - _, err = client.RunbookProcesses.Update(runbookProcess) + _, err = runbookprocess.Update(client, runbookProcess) if err != nil { return diag.FromErr(err) @@ -123,7 +127,7 @@ func resourceRunbookProcessRead(ctx context.Context, d *schema.ResourceData, m i log.Printf("[INFO] reading runbook process (%s)", d.Id()) client := m.(*client.Client) - runbookProcess, err := client.RunbookProcesses.GetByID(d.Id()) + runbookProcess, err := runbookprocess.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "runbook_process") @@ -142,7 +146,7 @@ func resourceRunbookProcessUpdate(ctx context.Context, d *schema.ResourceData, m client := m.(*client.Client) runbookProcess := expandRunbookProcess(ctx, d, client) - current, err := client.RunbookProcesses.GetByID(d.Id()) + current, err := runbookprocess.GetByID(client, runbookProcess.SpaceID, d.Id()) if err != nil { return diag.FromErr(err) @@ -151,7 +155,7 @@ func resourceRunbookProcessUpdate(ctx context.Context, d *schema.ResourceData, m runbookProcess.Links = current.Links runbookProcess.Version = current.Version - updatedRunbookProcess, err := client.RunbookProcesses.Update(runbookProcess) + updatedRunbookProcess, err := runbookprocess.Update(client, runbookProcess) if err != nil { return diag.FromErr(err) diff --git a/octopusdeploy/resource_script_module.go b/octopusdeploy/resource_script_module.go index 24987a0f7..faf0f5232 100644 --- a/octopusdeploy/resource_script_module.go +++ b/octopusdeploy/resource_script_module.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/scriptmodules" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceScriptModuleCreate(ctx context.Context, d *schema.ResourceData, m i log.Printf("[INFO] creating script module: %#v", scriptModule) client := m.(*client.Client) - createdScriptModule, err := client.ScriptModules.Add(scriptModule) + createdScriptModule, err := scriptmodules.Add(client, scriptModule) if err != nil { return diag.FromErr(err) } @@ -46,8 +47,13 @@ func resourceScriptModuleCreate(ctx context.Context, d *schema.ResourceData, m i func resourceScriptModuleDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] deleting script module (%s)", d.Id()) + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + client := m.(*client.Client) - err := client.ScriptModules.DeleteByID(d.Id()) + err := scriptmodules.DeleteByID(client, spaceID, d.Id()) if err != nil { return diag.FromErr(err) } @@ -60,8 +66,14 @@ func resourceScriptModuleDelete(ctx context.Context, d *schema.ResourceData, m i func resourceScriptModuleRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] reading script module (%s)", d.Id()) + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + client := m.(*client.Client) - scriptModule, err := client.ScriptModules.GetByID(d.Id()) + + scriptModule, err := scriptmodules.GetByID(client, spaceID, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "script module") } @@ -80,7 +92,7 @@ func resourceScriptModuleUpdate(ctx context.Context, d *schema.ResourceData, m i scriptModule := expandScriptModule(d) client := m.(*client.Client) - updatedScriptModule, err := client.ScriptModules.Update(scriptModule) + updatedScriptModule, err := scriptmodules.Update(client, scriptModule) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_space.go b/octopusdeploy/resource_space.go index c4ec6f14d..57df86fbd 100644 --- a/octopusdeploy/resource_space.go +++ b/octopusdeploy/resource_space.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -50,7 +51,7 @@ func resourceSpaceDelete(ctx context.Context, d *schema.ResourceData, m interfac space.TaskQueueStopped = true client := m.(*client.Client) - updatedSpace, err := client.Spaces.Update(space) + updatedSpace, err := spaces.Update(client, space) if err != nil { return diag.FromErr(err) } @@ -69,7 +70,7 @@ func resourceSpaceRead(ctx context.Context, d *schema.ResourceData, m interface{ log.Printf("[INFO] reading space (%s)", d.Id()) client := m.(*client.Client) - space, err := client.Spaces.GetByID(d.Id()) + space, err := spaces.GetByID(client, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "space") } @@ -87,7 +88,7 @@ func resourceSpaceUpdate(ctx context.Context, d *schema.ResourceData, m interfac space := expandSpace(d) client := m.(*client.Client) - updatedSpace, err := client.Spaces.Update(space) + updatedSpace, err := spaces.Update(client, space) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_space_test.go b/octopusdeploy/resource_space_test.go index 78fe34319..8865af000 100644 --- a/octopusdeploy/resource_space_test.go +++ b/octopusdeploy/resource_space_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -101,7 +102,7 @@ func testSpaceExists(prefix string) resource.TestCheckFunc { return func(s *terraform.State) error { client := testAccProvider.Meta().(*client.Client) spaceID := s.RootModule().Resources[prefix].Primary.ID - if _, err := client.Spaces.GetByID(spaceID); err != nil { + if _, err := spaces.GetByID(client, spaceID); err != nil { return err } @@ -113,7 +114,7 @@ func testAccSpaceCheckDestroy(s *terraform.State) error { client := testAccProvider.Meta().(*client.Client) for _, rs := range s.RootModule().Resources { spaceID := rs.Primary.ID - space, err := client.Spaces.GetByID(spaceID) + space, err := spaces.GetByID(client, spaceID) if err == nil { if space != nil { return fmt.Errorf("space (%s) still exists", rs.Primary.ID) diff --git a/octopusdeploy/resource_ssh_connection_deployment_target.go b/octopusdeploy/resource_ssh_connection_deployment_target.go index 7e56c2640..f15a0b022 100644 --- a/octopusdeploy/resource_ssh_connection_deployment_target.go +++ b/octopusdeploy/resource_ssh_connection_deployment_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceSSHConnectionDeploymentTargetCreate(ctx context.Context, d *schema. log.Printf("[INFO] creating SSH connection deployment target: %#v", deploymentTarget) client := m.(*client.Client) - createdDeploymentTarget, err := client.Machines.Add(deploymentTarget) + createdDeploymentTarget, err := machines.Add(client, deploymentTarget) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceSSHConnectionDeploymentTargetDelete(ctx context.Context, d *schema. log.Printf("[INFO] deleting SSH connection deployment target (%s)", d.Id()) client := m.(*client.Client) - if err := client.Machines.DeleteByID(d.Id()); err != nil { + if err := machines.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceSSHConnectionDeploymentTargetRead(ctx context.Context, d *schema.Re log.Printf("[INFO] reading SSH connection deployment target (%s)", d.Id()) client := m.(*client.Client) - deploymentTarget, err := client.Machines.GetByID(d.Id()) + deploymentTarget, err := machines.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "SSH connection deployment target") } @@ -79,7 +80,7 @@ func resourceSSHConnectionDeploymentTargetUpdate(ctx context.Context, d *schema. deploymentTarget := expandSSHConnectionDeploymentTarget(d) client := m.(*client.Client) - updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget) + updatedDeploymentTarget, err := machines.Update(client, deploymentTarget) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_sshkey_account.go b/octopusdeploy/resource_sshkey_account.go index d41a95c8e..0aab32202 100644 --- a/octopusdeploy/resource_sshkey_account.go +++ b/octopusdeploy/resource_sshkey_account.go @@ -29,7 +29,7 @@ func resourceSSHKeyAccountCreate(ctx context.Context, d *schema.ResourceData, m log.Printf("[INFO] creating SSH key account: %#v", account) client := m.(*client.Client) - createdAccount, err := client.Accounts.Add(account) + createdAccount, err := accounts.Add(client, account) if err != nil { return diag.FromErr(err) } @@ -48,7 +48,7 @@ func resourceSSHKeyAccountDelete(ctx context.Context, d *schema.ResourceData, m log.Printf("[INFO] deleting SSH key account (%s)", d.Id()) client := m.(*client.Client) - if err := client.Accounts.DeleteByID(d.Id()); err != nil { + if err := accounts.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -62,7 +62,7 @@ func resourceSSHKeyAccountRead(ctx context.Context, d *schema.ResourceData, m in log.Printf("[INFO] reading SSH key account (%s)", d.Id()) client := m.(*client.Client) - accountResource, err := client.Accounts.GetByID(d.Id()) + accountResource, err := accounts.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "SSH key account") } @@ -81,7 +81,7 @@ func resourceSSHKeyAccountUpdate(ctx context.Context, d *schema.ResourceData, m account := expandSSHKeyAccount(d) client := m.(*client.Client) - updatedAccount, err := client.Accounts.Update(account) + updatedAccount, err := accounts.Update(client, account) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_static_worker_pool.go b/octopusdeploy/resource_static_worker_pool.go index 826c9e4f5..881e9d6dc 100644 --- a/octopusdeploy/resource_static_worker_pool.go +++ b/octopusdeploy/resource_static_worker_pool.go @@ -29,7 +29,7 @@ func resourceStaticWorkerPoolCreate(ctx context.Context, d *schema.ResourceData, log.Printf("[INFO] creating static worker pool: %#v", workerPool) client := m.(*client.Client) - createdWorkerPool, err := client.WorkerPools.Add(workerPool) + createdWorkerPool, err := workerpools.Add(client, workerPool) if err != nil { return diag.FromErr(err) } @@ -47,9 +47,10 @@ func resourceStaticWorkerPoolCreate(ctx context.Context, d *schema.ResourceData, func resourceStaticWorkerPoolDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] deleting static worker pool (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - if err := client.WorkerPools.DeleteByID(d.Id()); err != nil { + if err := workerpools.DeleteByID(client, spaceID, d.Id()); err != nil { return diag.FromErr(err) } @@ -61,9 +62,10 @@ func resourceStaticWorkerPoolDelete(ctx context.Context, d *schema.ResourceData, func resourceStaticWorkerPoolRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] reading static worker pool (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - workerPoolResource, err := client.WorkerPools.GetByID(d.Id()) + workerPoolResource, err := workerpools.GetByID(client, spaceID, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "static worker pool") } @@ -83,7 +85,7 @@ func resourceStaticWorkerPoolUpdate(ctx context.Context, d *schema.ResourceData, log.Printf("[INFO] updating static worker pool (%s)", d.Id()) client := m.(*client.Client) - updatedWorkerPool, err := client.WorkerPools.Update(workerPool) + updatedWorkerPool, err := workerpools.Update(client, workerPool) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_tag.go b/octopusdeploy/resource_tag.go index 0c04feeff..a3a51451d 100644 --- a/octopusdeploy/resource_tag.go +++ b/octopusdeploy/resource_tag.go @@ -33,10 +33,17 @@ func resourceTagCreate(ctx context.Context, d *schema.ResourceData, m interface{ log.Printf("[INFO] creating tag") + return tagCreate(ctx, d, m) +} + +func tagCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Printf("[INFO] creating tag") + tagSetID := d.Get("tag_set_id").(string) + tagSetSpaceID := d.Get("tag_set_space_id").(string) octopus := m.(*client.Client) - tagSet, err := octopus.TagSets.GetByID(tagSetID) + tagSet, err := tagsets.GetByID(octopus, tagSetSpaceID, tagSetID) if err != nil { return processUnknownTagSetError(ctx, d, err) } @@ -50,14 +57,18 @@ func resourceTagCreate(ctx context.Context, d *schema.ResourceData, m interface{ } tag := expandTag(d) + if tag.ID != "" { + tag.ID = tagSet.GetID() + "/" + strings.Split(tag.ID, "/")[1] + } tagSet.Tags = append(tagSet.Tags, tag) - updatedTagSet, err := octopus.TagSets.Update(tagSet) + updatedTagSet, err := tagsets.Update(octopus, tagSet) if err != nil { return diag.FromErr(err) } return findByIdOrNameAndSetTag(ctx, d, tag, updatedTagSet) + } func resourceTagDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -65,11 +76,12 @@ func resourceTagDelete(ctx context.Context, d *schema.ResourceData, m interface{ defer mutex.Unlock() tagSetID := d.Get("tag_set_id").(string) + tagSetSpaceID := d.Get("tag_set_space_id").(string) log.Printf("[INFO] deleting tag (%s)", d.Id()) octopus := m.(*client.Client) - tagSet, err := octopus.TagSets.GetByID(tagSetID) + tagSet, err := tagsets.GetByID(octopus, tagSetSpaceID, tagSetID) if err != nil { return processUnknownTagSetError(ctx, d, err) } @@ -77,7 +89,7 @@ func resourceTagDelete(ctx context.Context, d *schema.ResourceData, m interface{ tag := expandTag(d) // verify tag is not associated with a tenant - isUsed, err := isTagUsedByTenants(ctx, octopus, tag) + isUsed, err := isTagUsedByTenants(ctx, octopus, tagSetSpaceID, tag) if err != nil { d.SetId("") return diag.FromErr(err) @@ -94,7 +106,7 @@ func resourceTagDelete(ctx context.Context, d *schema.ResourceData, m interface{ if tagSet.Tags[i].ID == d.Id() { tagSet.Tags = slices.Delete(tagSet.Tags, i, i+1) - if _, err := octopus.TagSets.Update(tagSet); err != nil { + if _, err := tagsets.Update(octopus, tagSet); err != nil { return diag.FromErr(err) } @@ -118,6 +130,7 @@ func resourceTagRead(ctx context.Context, d *schema.ResourceData, m interface{}) name := d.Get("name").(string) tagSetID := d.Get("tag_set_id").(string) + tagSetSpaceID := d.Get("tag_set_space_id").(string) // if name and tag set ID are empty then an import is underway if name == "" && tagSetID == "" { @@ -128,7 +141,7 @@ func resourceTagRead(ctx context.Context, d *schema.ResourceData, m interface{}) } octopus := m.(*client.Client) - tagSet, err := octopus.TagSets.GetByID(tagSetID) + tagSet, err := tagsets.GetByID(octopus, tagSetSpaceID, tagSetID) if err != nil { return processUnknownTagSetError(ctx, d, err) } @@ -143,6 +156,7 @@ func resourceTagUpdate(ctx context.Context, d *schema.ResourceData, m interface{ name := d.Get("name").(string) tagSetID := d.Get("tag_set_id").(string) + tagSetSpaceID := d.Get("tag_set_space_id").(string) log.Printf("[INFO] updating tag (%s)", d.Id()) @@ -151,13 +165,18 @@ func resourceTagUpdate(ctx context.Context, d *schema.ResourceData, m interface{ // if the tag is reassigned to another tag set if d.HasChange("tag_set_id") { sourceTagSetID, destinationTagSetID := d.GetChange("tag_set_id") + sourceTagSetSpaceID, destinationTagSetSpaceID := d.GetChange("tag_set_space_id") - sourceTagSet, err := octopus.TagSets.GetByID(sourceTagSetID.(string)) + sourceTagSet, err := tagsets.GetByID(octopus, sourceTagSetSpaceID.(string), sourceTagSetID.(string)) if err != nil { + // if spaceID has change, tag has been deleted, recreate required + if d.HasChange("tag_set_space_id") { + return tagCreate(ctx, d, m) + } return diag.FromErr(err) } - destinationTagSet, err := octopus.TagSets.GetByID(destinationTagSetID.(string)) + destinationTagSet, err := tagsets.GetByID(octopus, destinationTagSetSpaceID.(string), destinationTagSetID.(string)) if err != nil { return diag.FromErr(err) } @@ -173,7 +192,7 @@ func resourceTagUpdate(ctx context.Context, d *schema.ResourceData, m interface{ tag := expandTag(d) // check to see that the tag is not applied to a tenant - isUsed, err := isTagUsedByTenants(ctx, octopus, tag) + isUsed, err := isTagUsedByTenants(ctx, octopus, sourceTagSetSpaceID.(string), tag) if err != nil { d.SetId("") return diag.FromErr(err) @@ -191,7 +210,7 @@ func resourceTagUpdate(ctx context.Context, d *schema.ResourceData, m interface{ if sourceTagSet.Tags[i].ID == d.Id() { sourceTagSet.Tags = slices.Delete(sourceTagSet.Tags, i, i+1) - if _, err := octopus.TagSets.Update(sourceTagSet); err != nil { + if _, err := tagsets.Update(octopus, sourceTagSet); err != nil { return diag.FromErr(err) } } @@ -201,7 +220,7 @@ func resourceTagUpdate(ctx context.Context, d *schema.ResourceData, m interface{ tag.ID = destinationTagSet.GetID() + "/" + strings.Split(tag.ID, "/")[1] destinationTagSet.Tags = append(destinationTagSet.Tags, tag) - updatedTagSet, err := octopus.TagSets.Update(destinationTagSet) + updatedTagSet, err := tagsets.Update(octopus, destinationTagSet) if err != nil { return diag.FromErr(err) } @@ -209,7 +228,7 @@ func resourceTagUpdate(ctx context.Context, d *schema.ResourceData, m interface{ return findByIdOrNameAndSetTag(ctx, d, tag, updatedTagSet) } - tagSet, err := octopus.TagSets.GetByID(tagSetID) + tagSet, err := tagsets.GetByID(octopus, tagSetSpaceID, tagSetID) if err != nil { return processUnknownTagSetError(ctx, d, err) } @@ -219,7 +238,7 @@ func resourceTagUpdate(ctx context.Context, d *schema.ResourceData, m interface{ if tagSet.Tags[i].ID == d.Id() { tagSet.Tags[i] = expandTag(d) - updatedTagSet, err := octopus.TagSets.Update(tagSet) + updatedTagSet, err := tagsets.Update(octopus, tagSet) if err != nil { return diag.FromErr(err) } @@ -231,9 +250,9 @@ func resourceTagUpdate(ctx context.Context, d *schema.ResourceData, m interface{ return diag.Errorf("unable to update tag") } -func isTagUsedByTenants(ctx context.Context, octopus *client.Client, tag *tagsets.Tag) (bool, error) { - tenants, err := octopus.Tenants.Get(tenants.TenantsQuery{ - Tags: []string{tag.CanonicalTagName}, +func isTagUsedByTenants(ctx context.Context, octopus *client.Client, spaceID string, tag *tagsets.Tag) (bool, error) { + tenants, err := tenants.Get(octopus, spaceID, tenants.TenantsQuery{ + Tags: []string{tag.ID}, }) if err != nil { return false, err diff --git a/octopusdeploy/resource_tag_set.go b/octopusdeploy/resource_tag_set.go index ac2b5cea5..c80e19623 100644 --- a/octopusdeploy/resource_tag_set.go +++ b/octopusdeploy/resource_tag_set.go @@ -6,6 +6,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tagsets" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -30,7 +31,7 @@ func resourceTagSetCreate(ctx context.Context, d *schema.ResourceData, m interfa log.Printf("[INFO] creating tag set: %#v", tagSet) octopus := m.(*client.Client) - createdTagSet, err := octopus.TagSets.Add(tagSet) + createdTagSet, err := tagsets.Add(octopus, tagSet) if err != nil { return diag.FromErr(err) } @@ -49,7 +50,7 @@ func resourceTagSetDelete(ctx context.Context, d *schema.ResourceData, m interfa log.Printf("[INFO] deleting tag set (%s)", d.Id()) octopus := m.(*client.Client) - if err := octopus.TagSets.DeleteByID(d.Id()); err != nil { + if err := tagsets.DeleteByID(octopus, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -63,7 +64,7 @@ func resourceTagSetRead(ctx context.Context, d *schema.ResourceData, m interface tflog.Info(ctx, fmt.Sprintf("reading tag set (%s)", d.Id())) octopus := m.(*client.Client) - tagSet, err := octopus.TagSets.GetByID(d.Id()) + tagSet, err := tagsets.GetByID(octopus, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "tag set") } @@ -82,13 +83,13 @@ func resourceTagSetUpdate(ctx context.Context, d *schema.ResourceData, m interfa log.Printf("[INFO] updating tag set: %#v", tagSet) octopus := m.(*client.Client) - existingTagSet, err := octopus.TagSets.GetByID(d.Id()) + existingTagSet, err := tagsets.GetByID(octopus, d.Get("space_id").(string), d.Id()) if err != nil { return diag.FromErr(err) } tagSet.Tags = existingTagSet.Tags - updatedTagSet, err := octopus.TagSets.Update(tagSet) + updatedTagSet, err := tagsets.Update(octopus, tagSet) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_tenant.go b/octopusdeploy/resource_tenant.go index 87e206f6b..c4792434d 100644 --- a/octopusdeploy/resource_tenant.go +++ b/octopusdeploy/resource_tenant.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tenants" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceTenantCreate(ctx context.Context, d *schema.ResourceData, m interfa log.Printf("[INFO] creating tenant: %#v", tenant) client := m.(*client.Client) - createdTenant, err := client.Tenants.Add(tenant) + createdTenant, err := tenants.Add(client, tenant) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceTenantDelete(ctx context.Context, d *schema.ResourceData, m interfa log.Printf("[INFO] deleting tenant (%s)", d.Id()) client := m.(*client.Client) - if err := client.Tenants.DeleteByID(d.Id()); err != nil { + if err := tenants.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -60,7 +61,7 @@ func resourceTenantRead(ctx context.Context, d *schema.ResourceData, m interface log.Printf("[INFO] reading tenant (%s)", d.Id()) client := m.(*client.Client) - tenant, err := client.Tenants.GetByID(d.Id()) + tenant, err := tenants.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "tenant") } @@ -78,7 +79,7 @@ func resourceTenantUpdate(ctx context.Context, d *schema.ResourceData, m interfa tenant := expandTenant(d) client := m.(*client.Client) - updatedTenant, err := client.Tenants.Update(tenant) + updatedTenant, err := tenants.Update(client, tenant) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_tenant_common_variable.go b/octopusdeploy/resource_tenant_common_variable.go index 792f3793f..05c1027c7 100644 --- a/octopusdeploy/resource_tenant_common_variable.go +++ b/octopusdeploy/resource_tenant_common_variable.go @@ -8,6 +8,7 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tenants" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -33,6 +34,11 @@ func resourceTenantCommonVariable() *schema.Resource { Required: true, Type: schema.TypeString, }, + "space_id": { + Optional: true, + Computed: true, + Type: schema.TypeString, + }, "value": { Default: "", Optional: true, @@ -51,6 +57,7 @@ func resourceTenantCommonVariableCreate(ctx context.Context, d *schema.ResourceD libraryVariableSetID := d.Get("library_variable_set_id").(string) tenantID := d.Get("tenant_id").(string) templateID := d.Get("template_id").(string) + spaceID := d.Get("space_id").(string) value := d.Get("value").(string) id := tenantID + ":" + libraryVariableSetID + ":" + templateID @@ -58,7 +65,7 @@ func resourceTenantCommonVariableCreate(ctx context.Context, d *schema.ResourceD log.Printf("[INFO] creating tenant common variable (%s)", id) client := m.(*client.Client) - tenant, err := client.Tenants.GetByID(tenantID) + tenant, err := tenants.GetByID(client, spaceID, tenantID) if err != nil { return diag.FromErr(err) } @@ -94,6 +101,7 @@ func resourceTenantCommonVariableDelete(ctx context.Context, d *schema.ResourceD libraryVariableSetID := d.Get("library_variable_set_id").(string) tenantID := d.Get("tenant_id").(string) + spaceID := d.Get("space_id").(string) templateID := d.Get("template_id").(string) id := tenantID + ":" + libraryVariableSetID + ":" + templateID @@ -101,7 +109,7 @@ func resourceTenantCommonVariableDelete(ctx context.Context, d *schema.ResourceD log.Printf("[INFO] deleting tenant common variable (%s)", id) client := m.(*client.Client) - tenant, err := client.Tenants.GetByID(tenantID) + tenant, err := tenants.GetByID(client, spaceID, tenantID) if err != nil { if apiError, ok := err.(*core.APIError); ok { if apiError.StatusCode == 404 { @@ -167,6 +175,7 @@ func resourceTenantCommonVariableRead(ctx context.Context, d *schema.ResourceDat libraryVariableSetID := d.Get("library_variable_set_id").(string) tenantID := d.Get("tenant_id").(string) + spaceID := d.Get("space_id").(string) templateID := d.Get("template_id").(string) id := tenantID + ":" + libraryVariableSetID + ":" + templateID @@ -174,7 +183,7 @@ func resourceTenantCommonVariableRead(ctx context.Context, d *schema.ResourceDat log.Printf("[INFO] reading tenant common variable (%s)", id) client := m.(*client.Client) - tenant, err := client.Tenants.GetByID(tenantID) + tenant, err := tenants.GetByID(client, spaceID, tenantID) if err != nil { if apiError, ok := err.(*core.APIError); ok { if apiError.StatusCode == 404 { @@ -219,6 +228,7 @@ func resourceTenantCommonVariableUpdate(ctx context.Context, d *schema.ResourceD libraryVariableSetID := d.Get("library_variable_set_id").(string) tenantID := d.Get("tenant_id").(string) + spaceID := d.Get("space_id").(string) templateID := d.Get("template_id").(string) value := d.Get("value").(string) @@ -227,7 +237,7 @@ func resourceTenantCommonVariableUpdate(ctx context.Context, d *schema.ResourceD log.Printf("[INFO] updating tenant common variable (%s)", id) client := m.(*client.Client) - tenant, err := client.Tenants.GetByID(tenantID) + tenant, err := tenants.GetByID(client, spaceID, tenantID) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_tenant_project_variable.go b/octopusdeploy/resource_tenant_project_variable.go index ccbab50e6..7c41d402a 100644 --- a/octopusdeploy/resource_tenant_project_variable.go +++ b/octopusdeploy/resource_tenant_project_variable.go @@ -8,6 +8,7 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tenants" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -37,6 +38,11 @@ func resourceTenantProjectVariable() *schema.Resource { Required: true, Type: schema.TypeString, }, + "space_id": { + Optional: true, + Computed: true, + Type: schema.TypeString, + }, "value": { Default: "", Optional: true, @@ -55,6 +61,7 @@ func resourceTenantProjectVariableCreate(ctx context.Context, d *schema.Resource environmentID := d.Get("environment_id").(string) projectID := d.Get("project_id").(string) templateID := d.Get("template_id").(string) + spaceID := d.Get("space_id").(string) tenantID := d.Get("tenant_id").(string) value := d.Get("value").(string) @@ -63,7 +70,7 @@ func resourceTenantProjectVariableCreate(ctx context.Context, d *schema.Resource log.Printf("[INFO] creating tenant project variable (%s)", id) client := m.(*client.Client) - tenant, err := client.Tenants.GetByID(tenantID) + tenant, err := tenants.GetByID(client, spaceID, tenantID) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_token_account.go b/octopusdeploy/resource_token_account.go index f348cac5b..6c15f5b8c 100644 --- a/octopusdeploy/resource_token_account.go +++ b/octopusdeploy/resource_token_account.go @@ -28,7 +28,7 @@ func resourceTokenAccountCreate(ctx context.Context, d *schema.ResourceData, m i log.Printf("[INFO] creating token account: %#v", account) client := m.(*client.Client) - createdAccount, err := client.Accounts.Add(account) + createdAccount, err := accounts.Add(client, account) if err != nil { return diag.FromErr(err) } @@ -47,7 +47,7 @@ func resourceTokenAccountDelete(ctx context.Context, d *schema.ResourceData, m i log.Printf("[INFO] deleting token account (%s)", d.Id()) client := m.(*client.Client) - if err := client.Accounts.DeleteByID(d.Id()); err != nil { + if err := accounts.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +61,7 @@ func resourceTokenAccountRead(ctx context.Context, d *schema.ResourceData, m int log.Printf("[INFO] reading token account (%s)", d.Id()) client := m.(*client.Client) - accountResource, err := client.Accounts.GetByID(d.Id()) + accountResource, err := accounts.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "token account") } @@ -80,7 +80,7 @@ func resourceTokenAccountUpdate(ctx context.Context, d *schema.ResourceData, m i log.Printf("[INFO] updating token account: %#v", account) client := m.(*client.Client) - updatedAccount, err := client.Accounts.Update(account) + updatedAccount, err := accounts.Update(client, account) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_user.go b/octopusdeploy/resource_user.go index fb73069c1..0a7a5f599 100644 --- a/octopusdeploy/resource_user.go +++ b/octopusdeploy/resource_user.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/users" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceUserCreate(ctx context.Context, d *schema.ResourceData, m interface log.Printf("[DEBUG] creating user") client := m.(*client.Client) - createdUser, err := client.Users.Add(user) + createdUser, err := users.Add(client, user) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceUserDelete(ctx context.Context, d *schema.ResourceData, m interface log.Printf("[INFO] deleting user (%s)", d.Id()) client := m.(*client.Client) - if err := client.Users.DeleteByID(d.Id()); err != nil { + if err := users.DeleteByID(client, d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceUserRead(ctx context.Context, d *schema.ResourceData, m interface{} log.Printf("[INFO] reading user (%s)", d.Id()) client := m.(*client.Client) - user, err := client.Users.GetByID(d.Id()) + user, err := users.GetByID(client, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "user") } @@ -79,7 +80,7 @@ func resourceUserUpdate(ctx context.Context, d *schema.ResourceData, m interface user := expandUser(d) client := m.(*client.Client) - updatedUser, err := client.Users.Update(user) + updatedUser, err := users.Update(client, user) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_user_role.go b/octopusdeploy/resource_user_role.go index 447a77e6a..d1cc14780 100644 --- a/octopusdeploy/resource_user_role.go +++ b/octopusdeploy/resource_user_role.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/userroles" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceUserRoleCreate(ctx context.Context, d *schema.ResourceData, m inter log.Printf("[INFO] creating user role: %#v", userRole) client := m.(*client.Client) - createdUserRole, err := client.UserRoles.Add(userRole) + createdUserRole, err := userroles.Add(client, userRole) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceUserRoleDelete(ctx context.Context, d *schema.ResourceData, m inter log.Printf("[INFO] deleting user role (%s)", d.Id()) client := m.(*client.Client) - if err := client.UserRoles.DeleteByID(d.Id()); err != nil { + if err := userroles.DeleteByID(client, d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceUserRoleRead(ctx context.Context, d *schema.ResourceData, m interfa log.Printf("[INFO] reading user role (%s)", d.Id()) client := m.(*client.Client) - userRole, err := client.UserRoles.GetByID(d.Id()) + userRole, err := userroles.GetByID(client, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "user role") } @@ -79,7 +80,7 @@ func resourceUserRoleUpdate(ctx context.Context, d *schema.ResourceData, m inter userRole := expandUserRole(d) client := m.(*client.Client) - updatedUserRole, err := client.UserRoles.Update(userRole) + updatedUserRole, err := userroles.Update(client, userRole) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_username_password_account.go b/octopusdeploy/resource_username_password_account.go index e4fde1ba2..4d6ba8b79 100644 --- a/octopusdeploy/resource_username_password_account.go +++ b/octopusdeploy/resource_username_password_account.go @@ -29,7 +29,7 @@ func resourceUsernamePasswordAccountCreate(ctx context.Context, d *schema.Resour log.Printf("[INFO] creating username-password account: %#v", account) client := m.(*client.Client) - createdAccount, err := client.Accounts.Add(account) + createdAccount, err := accounts.Add(client, account) if err != nil { return diag.FromErr(err) } @@ -48,7 +48,7 @@ func resourceUsernamePasswordAccountDelete(ctx context.Context, d *schema.Resour log.Printf("[INFO] deleting username-password account (%s)", d.Id()) client := m.(*client.Client) - if err := client.Accounts.DeleteByID(d.Id()); err != nil { + if err := accounts.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -62,7 +62,7 @@ func resourceUsernamePasswordAccountRead(ctx context.Context, d *schema.Resource log.Printf("[INFO] reading username-password account (%s)", d.Id()) client := m.(*client.Client) - accountResource, err := client.Accounts.GetByID(d.Id()) + accountResource, err := accounts.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "username-password account") } @@ -81,7 +81,7 @@ func resourceUsernamePasswordAccountUpdate(ctx context.Context, d *schema.Resour log.Printf("[INFO] updating username-password account: %#v", account) client := m.(*client.Client) - updatedAccount, err := client.Accounts.Update(account) + updatedAccount, err := accounts.Update(client, account) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_variable.go b/octopusdeploy/resource_variable.go index 60b2823e3..dcb8db8c5 100644 --- a/octopusdeploy/resource_variable.go +++ b/octopusdeploy/resource_variable.go @@ -8,6 +8,7 @@ import ( "sync" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -49,6 +50,11 @@ func resourceVariableCreate(ctx context.Context, d *schema.ResourceData, m inter return diag.FromErr(err) } + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + projectID, projectOk := d.GetOk("project_id") ownerID, ownerOk := d.GetOk("owner_id") @@ -69,14 +75,14 @@ func resourceVariableCreate(ctx context.Context, d *schema.ResourceData, m inter log.Printf("[INFO] creating variable: %#v", variable) client := m.(*client.Client) - variableSet, err := client.Variables.AddSingle(variableOwnerID, variable) + variableSet, err := variables.AddSingle(client, spaceID, variableOwnerID, variable) if err != nil { return diag.FromErr(err) } for _, v := range variableSet.Variables { if v.Name == variable.Name && v.Type == variable.Type && (v.IsSensitive || v.Value == variable.Value) && v.Description == variable.Description && v.IsSensitive == variable.IsSensitive { - scopeMatches, _, err := client.Variables.MatchesScope(v.Scope, &variable.Scope) + scopeMatches, _, err := variables.MatchesScope(v.Scope, &variable.Scope) if err != nil { return diag.FromErr(err) } @@ -97,6 +103,11 @@ func resourceVariableRead(ctx context.Context, d *schema.ResourceData, m interfa id := d.Id() + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + projectID, projectOk := d.GetOk("project_id") ownerID, ownerOk := d.GetOk("owner_id") @@ -113,7 +124,7 @@ func resourceVariableRead(ctx context.Context, d *schema.ResourceData, m interfa } client := m.(*client.Client) - variable, err := client.Variables.GetByID(variableOwnerID, id) + variable, err := variables.GetByID(client, spaceID, variableOwnerID, id) if err != nil { return errors.ProcessApiError(ctx, d, err, "variable") } @@ -138,6 +149,11 @@ func resourceVariableUpdate(ctx context.Context, d *schema.ResourceData, m inter variable := expandVariable(d) + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + projectID, projectOk := d.GetOk("project_id") ownerID, ownerOk := d.GetOk("owner_id") @@ -154,14 +170,14 @@ func resourceVariableUpdate(ctx context.Context, d *schema.ResourceData, m inter } client := m.(*client.Client) - variableSet, err := client.Variables.UpdateSingle(variableOwnerID, variable) + variableSet, err := variables.UpdateSingle(client, spaceID, variableOwnerID, variable) if err != nil { return diag.FromErr(err) } for _, v := range variableSet.Variables { if v.Name == variable.Name && v.Type == variable.Type && (v.IsSensitive || v.Value == variable.Value) && v.Description == variable.Description && v.IsSensitive == variable.IsSensitive { - scopeMatches, _, _ := client.Variables.MatchesScope(v.Scope, &variable.Scope) + scopeMatches, _, _ := variables.MatchesScope(v.Scope, &variable.Scope) if scopeMatches { if err := setVariable(ctx, d, v); err != nil { return diag.FromErr(err) @@ -182,6 +198,11 @@ func resourceVariableDelete(ctx context.Context, d *schema.ResourceData, m inter log.Printf("[INFO] deleting variable (%s)", d.Id()) + var spaceID string + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + projectID, projectOk := d.GetOk("project_id") ownerID, ownerOk := d.GetOk("owner_id") @@ -198,7 +219,7 @@ func resourceVariableDelete(ctx context.Context, d *schema.ResourceData, m inter } client := m.(*client.Client) - _, err := client.Variables.DeleteSingle(variableOwnerID, d.Id()) + _, err := variables.DeleteSingle(client, spaceID, variableOwnerID, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "variable") } diff --git a/octopusdeploy/schema_account_resource.go b/octopusdeploy/schema_account_resource.go index 44e5432ec..5dbee9361 100644 --- a/octopusdeploy/schema_account_resource.go +++ b/octopusdeploy/schema_account_resource.go @@ -52,6 +52,7 @@ func getAccountResourceDataSchema() map[string]*schema.Schema { Type: schema.TypeList, }, "id": getDataSchemaID(), + "space_id": getQuerySpaceID(), "ids": getQueryIDs(), "partial_name": getQueryPartialName(), "skip": getQuerySkip(), diff --git a/octopusdeploy/schema_aws_elastic_container_registry.go b/octopusdeploy/schema_aws_elastic_container_registry.go index 439787bc3..e986d1ac5 100644 --- a/octopusdeploy/schema_aws_elastic_container_registry.go +++ b/octopusdeploy/schema_aws_elastic_container_registry.go @@ -75,6 +75,7 @@ func getAwsElasticContainerRegistrySchema() map[string]*schema.Schema { Description: "The space ID associated with this feed.", Optional: true, Type: schema.TypeString, + ForceNew: true, }, } } diff --git a/octopusdeploy/schema_azure_service_fabric_cluster.go b/octopusdeploy/schema_azure_service_fabric_cluster.go index a9f121390..3ff73f5e0 100644 --- a/octopusdeploy/schema_azure_service_fabric_cluster.go +++ b/octopusdeploy/schema_azure_service_fabric_cluster.go @@ -9,7 +9,11 @@ func expandAzureServiceFabricCluster(flattenedMap map[string]interface{}) *machi endpoint := machines.NewAzureServiceFabricEndpoint() endpoint.AadClientCredentialSecret = flattenedMap["aad_client_credential_secret"].(string) endpoint.AadCredentialType = flattenedMap["aad_credential_type"].(string) - endpoint.AadUserCredentialPassword = core.NewSensitiveValue(flattenedMap["aad_user_credential_password"].(string)) + + if userCredential, ok := flattenedMap["aad_user_credential_password"]; ok { + endpoint.AadUserCredentialPassword = core.NewSensitiveValue(userCredential.(string)) + } + endpoint.AadUserCredentialUsername = flattenedMap["aad_user_credential_username"].(string) endpoint.CertificateStoreLocation = flattenedMap["certificate_store_location"].(string) endpoint.CertificateStoreName = flattenedMap["certificate_store_name"].(string) diff --git a/octopusdeploy/schema_certificate.go b/octopusdeploy/schema_certificate.go index 1863f5925..153890be9 100644 --- a/octopusdeploy/schema_certificate.go +++ b/octopusdeploy/schema_certificate.go @@ -114,6 +114,10 @@ func expandCertificate(d *schema.ResourceData) *certificates.CertificateResource certificate.Version = v.(int) } + if v, ok := d.GetOk("space_id"); ok { + certificate.SpaceID = v.(string) + } + return certificate } @@ -178,6 +182,7 @@ func getCertificateDataSchema() map[string]*schema.Schema { "skip": getQuerySkip(), "take": getQueryTake(), "tenant": getQueryTenant(), + "space_id": getSpaceIDSchema(), } } @@ -296,6 +301,11 @@ func getCertificateSchema() map[string]*schema.Schema { Optional: true, Type: schema.TypeInt, }, + "space_id": { + Optional: true, + Computed: true, + Type: schema.TypeString, + }, } } diff --git a/octopusdeploy/schema_channel.go b/octopusdeploy/schema_channel.go index 473a87bfe..88aa0bda9 100644 --- a/octopusdeploy/schema_channel.go +++ b/octopusdeploy/schema_channel.go @@ -80,6 +80,7 @@ func getChannelDataSchema() map[string]*schema.Schema { "partial_name": getQueryPartialName(), "skip": getQuerySkip(), "take": getQueryTake(), + "space_id": getSpaceIDSchema(), } } diff --git a/octopusdeploy/schema_deployment_target.go b/octopusdeploy/schema_deployment_target.go index 2b5f8ae3d..456265859 100644 --- a/octopusdeploy/schema_deployment_target.go +++ b/octopusdeploy/schema_deployment_target.go @@ -40,6 +40,10 @@ func expandDeploymentTarget(d *schema.ResourceData) *machines.DeploymentTarget { deploymentTarget.URI = v.(string) } + if v, ok := d.GetOk("space_id"); ok { + deploymentTarget.SpaceID = v.(string) + } + return deploymentTarget } @@ -102,6 +106,7 @@ func getDeploymentTargetDataSchema() map[string]*schema.Schema { "tenants": getQueryTenants(), "tenant_tags": getQueryTenantTags(), "thumbprint": getQueryThumbprint(), + "space_id": getSpaceIDSchema(), } } @@ -198,6 +203,7 @@ func setDeploymentTarget(ctx context.Context, d *schema.ResourceData, deployment d.Set("tenanted_deployment_participation", deploymentTarget.TenantedDeploymentMode) d.Set("thumbprint", deploymentTarget.Thumbprint) d.Set("uri", deploymentTarget.URI) + d.Set("space_id", deploymentTarget.SpaceID) endpointResource, err := machines.ToEndpointResource(deploymentTarget.Endpoint) if err != nil { diff --git a/octopusdeploy/schema_environment.go b/octopusdeploy/schema_environment.go index 8458888e5..babb495ab 100644 --- a/octopusdeploy/schema_environment.go +++ b/octopusdeploy/schema_environment.go @@ -112,6 +112,7 @@ func getEnvironmentDataSchema() map[string]*schema.Schema { "partial_name": getQueryPartialName(), "skip": getQuerySkip(), "take": getQueryTake(), + "space_id": getSpaceIDSchema(), } } diff --git a/octopusdeploy/schema_feed.go b/octopusdeploy/schema_feed.go index 0d312fc7a..6c5c77337 100644 --- a/octopusdeploy/schema_feed.go +++ b/octopusdeploy/schema_feed.go @@ -48,6 +48,7 @@ func getFeedDataSchema() map[string]*schema.Schema { "partial_name": getQueryPartialName(), "skip": getQuerySkip(), "take": getQueryTake(), + "space_id": getSpaceIDSchema(), } } diff --git a/octopusdeploy/schema_git_credential.go b/octopusdeploy/schema_git_credential.go index 469044305..da17119b8 100644 --- a/octopusdeploy/schema_git_credential.go +++ b/octopusdeploy/schema_git_credential.go @@ -55,9 +55,10 @@ func getGitCredentialDataSchema() map[string]*schema.Schema { Optional: true, Type: schema.TypeList, }, - "name": getQueryName(), - "skip": getQuerySkip(), - "take": getQueryTake(), + "name": getQueryName(), + "skip": getQuerySkip(), + "take": getQueryTake(), + "space_id": getSpaceIDSchema(), } } diff --git a/octopusdeploy/schema_helm_feed.go b/octopusdeploy/schema_helm_feed.go index 08870ccb9..1dc3d3478 100644 --- a/octopusdeploy/schema_helm_feed.go +++ b/octopusdeploy/schema_helm_feed.go @@ -36,6 +36,10 @@ func expandHelmFeed(d *schema.ResourceData) (*feeds.HelmFeed, error) { helmFeed.Username = v.(string) } + if v, ok := d.GetOk("space_id"); ok { + helmFeed.SpaceID = v.(string) + } + return helmFeed, nil } @@ -64,17 +68,17 @@ func getHelmFeedSchema() map[string]*schema.Schema { } } -func setHelmFeed(ctx context.Context, d *schema.ResourceData, mavenFeed *feeds.HelmFeed) error { - d.Set("feed_uri", mavenFeed.FeedURI) - d.Set("name", mavenFeed.Name) - d.Set("space_id", mavenFeed.SpaceID) - d.Set("username", mavenFeed.Username) +func setHelmFeed(ctx context.Context, d *schema.ResourceData, helmFeed *feeds.HelmFeed) error { + d.Set("feed_uri", helmFeed.FeedURI) + d.Set("name", helmFeed.Name) + d.Set("space_id", helmFeed.SpaceID) + d.Set("username", helmFeed.Username) - if err := d.Set("package_acquisition_location_options", mavenFeed.PackageAcquisitionLocationOptions); err != nil { + if err := d.Set("package_acquisition_location_options", helmFeed.PackageAcquisitionLocationOptions); err != nil { return fmt.Errorf("error setting package_acquisition_location_options: %s", err) } - d.SetId(mavenFeed.GetID()) + d.SetId(helmFeed.GetID()) return nil } diff --git a/octopusdeploy/schema_library_variable_set.go b/octopusdeploy/schema_library_variable_set.go index a6cc108c9..2d2760036 100644 --- a/octopusdeploy/schema_library_variable_set.go +++ b/octopusdeploy/schema_library_variable_set.go @@ -18,6 +18,10 @@ func expandLibraryVariableSet(d *schema.ResourceData) *variables.LibraryVariable libraryVariableSet.Description = v.(string) } + if v, ok := d.GetOk("space_id"); ok { + libraryVariableSet.SpaceID = v.(string) + } + if attr, ok := d.GetOk("template"); ok { tfTemplates := attr.([]interface{}) @@ -52,6 +56,7 @@ func getLibraryVariableSetDataSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "content_type": getQueryContentType(), "id": getDataSchemaID(), + "space_id": getQuerySpaceID(), "ids": getQueryIDs(), "library_variable_sets": { Computed: true, diff --git a/octopusdeploy/schema_lifecycle.go b/octopusdeploy/schema_lifecycle.go index feb63ee3c..0b00aefc4 100644 --- a/octopusdeploy/schema_lifecycle.go +++ b/octopusdeploy/schema_lifecycle.go @@ -74,6 +74,7 @@ func getLifecycleDataSchema() map[string]*schema.Schema { "partial_name": getQueryPartialName(), "skip": getQuerySkip(), "take": getQueryTake(), + "space_id": getSpaceIDSchema(), } } diff --git a/octopusdeploy/schema_machine_cleanup_policy.go b/octopusdeploy/schema_machine_cleanup_policy.go index 0ddec3de9..63919acc1 100644 --- a/octopusdeploy/schema_machine_cleanup_policy.go +++ b/octopusdeploy/schema_machine_cleanup_policy.go @@ -3,12 +3,12 @@ package octopusdeploy import ( "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machinepolicies" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -func expandMachineCleanupPolicy(values interface{}) *machines.MachineCleanupPolicy { +func expandMachineCleanupPolicy(values interface{}) *machinepolicies.MachineCleanupPolicy { if values == nil { return nil } @@ -19,7 +19,7 @@ func expandMachineCleanupPolicy(values interface{}) *machines.MachineCleanupPoli flattenedMap := flattenedValues.List()[0].(map[string]interface{}) - machineCleanupPolicy := machines.NewMachineCleanupPolicy() + machineCleanupPolicy := machinepolicies.NewMachineCleanupPolicy() if v, ok := flattenedMap["delete_machines_behavior"]; ok { machineCleanupPolicy.DeleteMachinesBehavior = v.(string) @@ -32,7 +32,7 @@ func expandMachineCleanupPolicy(values interface{}) *machines.MachineCleanupPoli return machineCleanupPolicy } -func flattenMachineCleanupPolicy(machineCleanupPolicy *machines.MachineCleanupPolicy) []interface{} { +func flattenMachineCleanupPolicy(machineCleanupPolicy *machinepolicies.MachineCleanupPolicy) []interface{} { if machineCleanupPolicy == nil { return nil } diff --git a/octopusdeploy/schema_machine_connectivity_policy.go b/octopusdeploy/schema_machine_connectivity_policy.go index 0a1869493..fdda20c98 100644 --- a/octopusdeploy/schema_machine_connectivity_policy.go +++ b/octopusdeploy/schema_machine_connectivity_policy.go @@ -1,12 +1,12 @@ package octopusdeploy import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machinepolicies" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -func expandMachineConnectivityPolicy(values interface{}) *machines.MachineConnectivityPolicy { +func expandMachineConnectivityPolicy(values interface{}) *machinepolicies.MachineConnectivityPolicy { if values == nil { return nil } @@ -17,7 +17,7 @@ func expandMachineConnectivityPolicy(values interface{}) *machines.MachineConnec flattenedMap := flattenedValues.List()[0].(map[string]interface{}) - machineConnectivityPolicy := machines.NewMachineConnectivityPolicy() + machineConnectivityPolicy := machinepolicies.NewMachineConnectivityPolicy() if v, ok := flattenedMap["machine_connectivity_behavior"]; ok { machineConnectivityPolicy.MachineConnectivityBehavior = v.(string) @@ -26,7 +26,7 @@ func expandMachineConnectivityPolicy(values interface{}) *machines.MachineConnec return machineConnectivityPolicy } -func flattenMachineConnectivityPolicy(machineConnectivityPolicy *machines.MachineConnectivityPolicy) []interface{} { +func flattenMachineConnectivityPolicy(machineConnectivityPolicy *machinepolicies.MachineConnectivityPolicy) []interface{} { if machineConnectivityPolicy == nil { return nil } diff --git a/octopusdeploy/schema_machine_health_check_policy.go b/octopusdeploy/schema_machine_health_check_policy.go index 52752650f..59a00a0a2 100644 --- a/octopusdeploy/schema_machine_health_check_policy.go +++ b/octopusdeploy/schema_machine_health_check_policy.go @@ -3,12 +3,12 @@ package octopusdeploy import ( "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machinepolicies" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -func expandMachineHealthCheckPolicy(values interface{}) *machines.MachineHealthCheckPolicy { +func expandMachineHealthCheckPolicy(values interface{}) *machinepolicies.MachineHealthCheckPolicy { if values == nil { return nil } @@ -19,7 +19,7 @@ func expandMachineHealthCheckPolicy(values interface{}) *machines.MachineHealthC flattenedMap := flattenedValues.List()[0].(map[string]interface{}) - machineHealthCheckPolicy := machines.NewMachineHealthCheckPolicy() + machineHealthCheckPolicy := machinepolicies.NewMachineHealthCheckPolicy() if v, ok := flattenedMap["bash_health_check_policy"]; ok { if len(v.([]interface{})) > 0 { @@ -54,7 +54,7 @@ func expandMachineHealthCheckPolicy(values interface{}) *machines.MachineHealthC return machineHealthCheckPolicy } -func flattenMachineHealthCheckPolicy(machineHealthCheckPolicy *machines.MachineHealthCheckPolicy) []interface{} { +func flattenMachineHealthCheckPolicy(machineHealthCheckPolicy *machinepolicies.MachineHealthCheckPolicy) []interface{} { if machineHealthCheckPolicy == nil { return nil } diff --git a/octopusdeploy/schema_machine_policy.go b/octopusdeploy/schema_machine_policy.go index 0aa34d422..001569350 100644 --- a/octopusdeploy/schema_machine_policy.go +++ b/octopusdeploy/schema_machine_policy.go @@ -5,14 +5,14 @@ import ( "fmt" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machinepolicies" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -func expandMachinePolicy(d *schema.ResourceData) *machines.MachinePolicy { +func expandMachinePolicy(d *schema.ResourceData) *machinepolicies.MachinePolicy { name := d.Get("name").(string) - machinePolicy := machines.NewMachinePolicy(name) + machinePolicy := machinepolicies.NewMachinePolicy(name) machinePolicy.ID = d.Id() if v, ok := d.GetOk("connection_connect_timeout"); ok { @@ -83,7 +83,7 @@ func expandMachinePolicy(d *schema.ResourceData) *machines.MachinePolicy { } -func flattenMachinePolicy(machinePolicy *machines.MachinePolicy) map[string]interface{} { +func flattenMachinePolicy(machinePolicy *machinepolicies.MachinePolicy) map[string]interface{} { if machinePolicy == nil { return nil } @@ -123,6 +123,7 @@ func getMachinePolicyDataSchema() map[string]*schema.Schema { "partial_name": getQueryPartialName(), "skip": getQuerySkip(), "take": getQueryTake(), + "space_id": getSpaceIDSchema(), } } @@ -202,7 +203,7 @@ func getMachinePolicySchema() map[string]*schema.Schema { } } -func setMachinePolicy(ctx context.Context, d *schema.ResourceData, machinePolicy *machines.MachinePolicy) error { +func setMachinePolicy(ctx context.Context, d *schema.ResourceData, machinePolicy *machinepolicies.MachinePolicy) error { d.Set("connection_connect_timeout", machinePolicy.ConnectionConnectTimeout) d.Set("connection_retry_count_limit", machinePolicy.ConnectionRetryCountLimit) d.Set("connection_retry_sleep_interval", machinePolicy.ConnectionRetrySleepInterval) diff --git a/octopusdeploy/schema_machine_script_policy.go b/octopusdeploy/schema_machine_script_policy.go index d23f1adff..c1e2797cc 100644 --- a/octopusdeploy/schema_machine_script_policy.go +++ b/octopusdeploy/schema_machine_script_policy.go @@ -1,12 +1,12 @@ package octopusdeploy import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machinepolicies" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -func expandMachineScriptPolicy(values interface{}) *machines.MachineScriptPolicy { +func expandMachineScriptPolicy(values interface{}) *machinepolicies.MachineScriptPolicy { if values == nil { return nil } @@ -17,7 +17,7 @@ func expandMachineScriptPolicy(values interface{}) *machines.MachineScriptPolicy flattenedMap := flattenedValues[0].(map[string]interface{}) - machineScriptPolicy := machines.NewMachineScriptPolicy() + machineScriptPolicy := machinepolicies.NewMachineScriptPolicy() if v, ok := flattenedMap["run_type"]; ok { machineScriptPolicy.RunType = v.(string) @@ -31,7 +31,7 @@ func expandMachineScriptPolicy(values interface{}) *machines.MachineScriptPolicy return machineScriptPolicy } -func flattenMachineScriptPolicy(machineScriptPolicy *machines.MachineScriptPolicy) []interface{} { +func flattenMachineScriptPolicy(machineScriptPolicy *machinepolicies.MachineScriptPolicy) []interface{} { if machineScriptPolicy == nil { return nil } diff --git a/octopusdeploy/schema_machine_update_policy.go b/octopusdeploy/schema_machine_update_policy.go index 7b726079e..ffc7d3d85 100644 --- a/octopusdeploy/schema_machine_update_policy.go +++ b/octopusdeploy/schema_machine_update_policy.go @@ -1,12 +1,12 @@ package octopusdeploy import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machinepolicies" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -func expandMachineUpdatePolicy(values interface{}) *machines.MachineUpdatePolicy { +func expandMachineUpdatePolicy(values interface{}) *machinepolicies.MachineUpdatePolicy { if values == nil { return nil } @@ -17,7 +17,7 @@ func expandMachineUpdatePolicy(values interface{}) *machines.MachineUpdatePolicy flattenedMap := flattenedValues.List()[0].(map[string]interface{}) - machineUpdatePolicy := machines.NewMachineUpdatePolicy() + machineUpdatePolicy := machinepolicies.NewMachineUpdatePolicy() if v, ok := flattenedMap["calamari_update_behavior"]; ok { machineUpdatePolicy.CalamariUpdateBehavior = v.(string) @@ -34,7 +34,7 @@ func expandMachineUpdatePolicy(values interface{}) *machines.MachineUpdatePolicy return machineUpdatePolicy } -func flattenMachineUpdatePolicy(machineUpdatePolicy *machines.MachineUpdatePolicy) []interface{} { +func flattenMachineUpdatePolicy(machineUpdatePolicy *machinepolicies.MachineUpdatePolicy) []interface{} { if machineUpdatePolicy == nil { return nil } diff --git a/octopusdeploy/schema_offline_package_drop.go b/octopusdeploy/schema_offline_package_drop.go index 275c95e02..bd038070f 100644 --- a/octopusdeploy/schema_offline_package_drop.go +++ b/octopusdeploy/schema_offline_package_drop.go @@ -10,7 +10,11 @@ func expandOfflinePackageDrop(flattenedMap map[string]interface{}) *machines.Off endpoint.ApplicationsDirectory = flattenedMap["applications_directory"].(string) endpoint.Destination = expandOfflinePackageDropDestination(flattenedMap["destination"]) endpoint.ID = flattenedMap["id"].(string) - endpoint.SensitiveVariablesEncryptionPassword = core.NewSensitiveValue(flattenedMap["sensitive_variables_encryption_password"].(string)) + + if encryptedPassword, ok := flattenedMap["sensitive_variables_encryption_password"]; ok { + endpoint.SensitiveVariablesEncryptionPassword = core.NewSensitiveValue(encryptedPassword.(string)) + } + endpoint.WorkingDirectory = flattenedMap["working_directory"].(string) return endpoint diff --git a/octopusdeploy/schema_polling_tentacle.go b/octopusdeploy/schema_polling_tentacle.go index b353b66ca..552cc98c9 100644 --- a/octopusdeploy/schema_polling_tentacle.go +++ b/octopusdeploy/schema_polling_tentacle.go @@ -7,13 +7,18 @@ import ( ) func expandPollingTentacle(flattenedMap map[string]interface{}) *machines.PollingTentacleEndpoint { - octopusURL, _ := url.Parse(flattenedMap["octopus_url"].(string)) - thumbprint := flattenedMap["thumbprint"].(string) + if octopusUrlString, ok := flattenedMap["octopus_url"]; ok { + octopusURL, _ := url.Parse(octopusUrlString.(string)) - endpoint := machines.NewPollingTentacleEndpoint(octopusURL, thumbprint) - endpoint.CertificateSignatureAlgorithm = flattenedMap["certificate_signature_algorithm"].(string) - endpoint.ID = flattenedMap["id"].(string) - endpoint.TentacleVersionDetails = expandTentacleVersionDetails(flattenedMap["tentacle_version_details"]) + thumbprint := flattenedMap["thumbprint"].(string) + endpoint := machines.NewPollingTentacleEndpoint(octopusURL, thumbprint) - return endpoint + endpoint.CertificateSignatureAlgorithm = flattenedMap["certificate_signature_algorithm"].(string) + endpoint.ID = flattenedMap["id"].(string) + endpoint.TentacleVersionDetails = expandTentacleVersionDetails(flattenedMap["tentacle_version_details"]) + + return endpoint + } + + return nil } diff --git a/octopusdeploy/schema_project.go b/octopusdeploy/schema_project.go index 407897c32..bc7d2fb1c 100644 --- a/octopusdeploy/schema_project.go +++ b/octopusdeploy/schema_project.go @@ -202,6 +202,7 @@ func getProjectDataSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "cloned_from_project_id": getQueryClonedFromProjectID(), "id": getDataSchemaID(), + "space_id": getQuerySpaceID(), "ids": getQueryIDs(), "is_clone": getQueryIsClone(), "name": getQueryName(), diff --git a/octopusdeploy/schema_project_group.go b/octopusdeploy/schema_project_group.go index a1aff07ef..52fbfe857 100644 --- a/octopusdeploy/schema_project_group.go +++ b/octopusdeploy/schema_project_group.go @@ -48,6 +48,7 @@ func getProjectGroupDataSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "id": getDataSchemaID(), + "space_id": getQuerySpaceID(), "ids": getQueryIDs(), "partial_name": getQueryPartialName(), "project_groups": { diff --git a/octopusdeploy/schema_queries.go b/octopusdeploy/schema_queries.go index 8fe0a21ad..66ac87de4 100644 --- a/octopusdeploy/schema_queries.go +++ b/octopusdeploy/schema_queries.go @@ -147,6 +147,14 @@ func getQueryHealthStatuses() *schema.Schema { } } +func getQuerySpaceID() *schema.Schema { + return &schema.Schema{ + Description: "A Space ID to filter by. Will revert what is specified on the provider if not set.", + Optional: true, + Type: schema.TypeString, + } +} + func getDataSchemaID() *schema.Schema { return &schema.Schema{ Computed: true, diff --git a/octopusdeploy/schema_runbook.go b/octopusdeploy/schema_runbook.go index 38d83b457..47ffebba4 100644 --- a/octopusdeploy/schema_runbook.go +++ b/octopusdeploy/schema_runbook.go @@ -94,13 +94,7 @@ func getRunbookSchema() map[string]*schema.Schema { Computed: true, Type: schema.TypeString, }, - "space_id": { - Computed: true, - Description: "The space ID associated with this runbook.", - Optional: true, - Type: schema.TypeString, - ValidateDiagFunc: validation.ToDiagFunc(validation.StringIsNotWhiteSpace), - }, + "space_id": getSpaceIDSchema(), "multi_tenancy_mode": getTenantedDeploymentSchema(), "connectivity_policy": { Computed: true, diff --git a/octopusdeploy/schema_runbook_process.go b/octopusdeploy/schema_runbook_process.go index 1dd0ee43a..a0488e879 100644 --- a/octopusdeploy/schema_runbook_process.go +++ b/octopusdeploy/schema_runbook_process.go @@ -4,14 +4,14 @@ import ( "context" "fmt" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/runbooks" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/runbookprocess" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -func expandRunbookProcess(ctx context.Context, d *schema.ResourceData, client *client.Client) *runbooks.RunbookProcess { - runbookProcess := runbooks.NewRunbookProcess() +func expandRunbookProcess(ctx context.Context, d *schema.ResourceData, client *client.Client) *runbookprocess.RunbookProcess { + runbookProcess := runbookprocess.NewRunbookProcess() runbookProcess.ID = d.Id() if v, ok := d.GetOk("project_id"); ok { @@ -46,7 +46,7 @@ func expandRunbookProcess(ctx context.Context, d *schema.ResourceData, client *c return runbookProcess } -func setRunbookProcess(ctx context.Context, d *schema.ResourceData, RunbookProcess *runbooks.RunbookProcess) error { +func setRunbookProcess(ctx context.Context, d *schema.ResourceData, RunbookProcess *runbookprocess.RunbookProcess) error { d.Set("last_snapshot_id", RunbookProcess.LastSnapshotID) d.Set("project_id", RunbookProcess.ProjectID) d.Set("runbook_id", RunbookProcess.RunbookID) diff --git a/octopusdeploy/schema_script_modules.go b/octopusdeploy/schema_script_modules.go index a1f8e72e2..c4a24d1f8 100644 --- a/octopusdeploy/schema_script_modules.go +++ b/octopusdeploy/schema_script_modules.go @@ -79,8 +79,9 @@ func getScriptModuleDataSchema() map[string]*schema.Schema { setDataSchema(&dataSchema) return map[string]*schema.Schema{ - "id": getDataSchemaID(), - "ids": getQueryIDs(), + "id": getDataSchemaID(), + "space_id": getQuerySpaceID(), + "ids": getQueryIDs(), "script_modules": { Computed: true, Description: "A list of script modules that match the filter(s).", diff --git a/octopusdeploy/schema_tag.go b/octopusdeploy/schema_tag.go index 3136b529f..e9657ae61 100644 --- a/octopusdeploy/schema_tag.go +++ b/octopusdeploy/schema_tag.go @@ -29,6 +29,12 @@ func getTagSchema() map[string]*schema.Schema { Required: true, Type: schema.TypeString, }, + "tag_set_space_id": { + Description: "The Space ID of the associated tag set. Required if the tag set is not in the same space as what is configured on the provider", + Type: schema.TypeString, + Optional: true, + Computed: true, + }, } } @@ -61,6 +67,7 @@ func setTag(ctx context.Context, d *schema.ResourceData, tag *tagsets.Tag, tagSe d.Set("name", tag.Name) d.Set("sort_order", tag.SortOrder) d.Set("tag_set_id", tagSet.GetID()) + d.Set("tag_set_space_id", tagSet.SpaceID) d.SetId(tag.ID) return nil diff --git a/octopusdeploy/schema_tag_set.go b/octopusdeploy/schema_tag_set.go index 303c69728..db5c31a23 100644 --- a/octopusdeploy/schema_tag_set.go +++ b/octopusdeploy/schema_tag_set.go @@ -57,7 +57,8 @@ func getTagSetDataSchema() map[string]*schema.Schema { Optional: true, Type: schema.TypeList, }, - "take": getQueryTake(), + "take": getQueryTake(), + "space_id": getSpaceIDSchema(), } } diff --git a/octopusdeploy/schema_user.go b/octopusdeploy/schema_user.go index 24f848a20..5ef089c67 100644 --- a/octopusdeploy/schema_user.go +++ b/octopusdeploy/schema_user.go @@ -64,11 +64,12 @@ func getUserDataSchema() map[string]*schema.Schema { setDataSchema(&dataSchema) return map[string]*schema.Schema{ - "filter": getQueryFilter(), - "id": getDataSchemaID(), - "ids": getQueryIDs(), - "skip": getQuerySkip(), - "take": getQueryTake(), + "filter": getQueryFilter(), + "id": getDataSchemaID(), + "ids": getQueryIDs(), + "skip": getQuerySkip(), + "take": getQueryTake(), + "space_id": getQuerySpaceID(), "users": { Computed: true, Description: "A list of users that match the filter(s).", diff --git a/octopusdeploy/schema_user_role.go b/octopusdeploy/schema_user_role.go index cb865af90..9258402e5 100644 --- a/octopusdeploy/schema_user_role.go +++ b/octopusdeploy/schema_user_role.go @@ -79,6 +79,7 @@ func getUserRoleDataSchema() map[string]*schema.Schema { "partial_name": getQueryPartialName(), "skip": getQuerySkip(), "take": getQueryTake(), + "space_id": getQuerySpaceID(), "user_roles": { Computed: true, Description: "A list of user roles that match the filter(s).", diff --git a/octopusdeploy/schema_utilities.go b/octopusdeploy/schema_utilities.go index e37469dea..69b47ce30 100644 --- a/octopusdeploy/schema_utilities.go +++ b/octopusdeploy/schema_utilities.go @@ -289,6 +289,7 @@ func getSpaceIDSchema() *schema.Schema { Description: "The space ID associated with this resource.", Optional: true, Type: schema.TypeString, + ForceNew: true, } } diff --git a/octopusdeploy/schema_variable.go b/octopusdeploy/schema_variable.go index 218d5b6fd..2bc9cdf43 100644 --- a/octopusdeploy/schema_variable.go +++ b/octopusdeploy/schema_variable.go @@ -34,6 +34,10 @@ func expandVariable(d *schema.ResourceData) *variables.Variable { variable.Scope = expandVariableScope(v) } + if v, ok := d.GetOk("space_id"); ok { + variable.SpaceID = v.(string) + } + if variable.IsSensitive { variable.Type = "Sensitive" variable.Value = d.Get("sensitive_value").(string) @@ -55,8 +59,9 @@ func getVariableDataSchema() map[string]*schema.Schema { setDataSchema(&dataSchema) return map[string]*schema.Schema{ - "id": getDataSchemaID(), - "ids": getQueryIDs(), + "id": getDataSchemaID(), + "space_id": getQuerySpaceID(), + "ids": getQueryIDs(), "variables": { Computed: true, Description: "A list of variables that match the filter(s).", @@ -172,7 +177,8 @@ func getVariableSchema() map[string]*schema.Schema { Sensitive: true, Type: schema.TypeString, }, - "type": getVariableTypeSchema(), + "type": getVariableTypeSchema(), + "space_id": getSpaceIDSchema(), "value": { ConflictsWith: []string{"sensitive_value"}, Optional: true, diff --git a/octopusdeploy/schema_worker_pool.go b/octopusdeploy/schema_worker_pool.go index 178c72909..9207124c2 100644 --- a/octopusdeploy/schema_worker_pool.go +++ b/octopusdeploy/schema_worker_pool.go @@ -34,6 +34,7 @@ func getWorkerPoolDataSchema() map[string]*schema.Schema { "partial_name": getQueryPartialName(), "skip": getQuerySkip(), "take": getQueryTake(), + "space_id": getSpaceIDSchema(), "worker_pools": { Computed: true, Description: "A list of worker pools that match the filter(s).",