diff --git a/go.mod b/go.mod index a965ef3..1d0caa5 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,12 @@ -module github.com/ctfer-io/tofu-provider-ctfd +module github.com/ctfer-io/terraform-provider-ctfd -go 1.21 +go 1.21.3 require ( - github.com/opentofu/terraform-plugin-framework v1.3.4 - github.com/opentofu/terraform-plugin-go v0.18.0 - github.com/opentofu/terraform-plugin-log v0.9.0 - github.com/opentofu/terraform-plugin-testing v1.5.1 - github.com/ctfer-io/go-ctfd v0.1.9 + github.com/ctfer-io/go-ctfd v0.3.3 + github.com/hashicorp/terraform-plugin-framework v1.4.2 + github.com/hashicorp/terraform-plugin-go v0.19.0 + github.com/hashicorp/terraform-plugin-log v0.9.0 ) require ( @@ -17,24 +16,11 @@ require ( github.com/cloudflare/circl v1.3.3 // indirect github.com/fatih/color v1.13.0 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/go-cmp v0.5.9 // indirect - github.com/gorilla/schema v1.2.0 // indirect - github.com/hashicorp/errwrap v1.0.0 // indirect - github.com/hashicorp/go-checkpoint v0.5.0 // indirect - github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect + github.com/gorilla/schema v1.2.1 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.4.10 // indirect + github.com/hashicorp/go-plugin v1.5.1 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/hc-install v0.5.2 // indirect - github.com/hashicorp/hcl/v2 v2.17.0 // indirect - github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.18.1 // indirect - github.com/hashicorp/terraform-json v0.17.1 // indirect - github.com/hashicorp/terraform-plugin-sdk/v2 v2.28.0 // indirect - github.com/hashicorp/terraform-registry-address v0.2.1 // indirect + github.com/hashicorp/terraform-registry-address v0.2.2 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect github.com/mattn/go-colorable v0.1.12 // indirect @@ -49,15 +35,10 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.13.3 // indirect - golang.org/x/crypto v0.12.0 // indirect - golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect - golang.org/x/mod v0.11.0 // indirect - golang.org/x/net v0.11.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.56.1 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect + google.golang.org/grpc v1.57.0 // indirect google.golang.org/protobuf v1.31.0 // indirect ) diff --git a/go.sum b/go.sum index 2c9ad19..aeaca22 100644 --- a/go.sum +++ b/go.sum @@ -1,18 +1,7 @@ -github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= -github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= -github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= -github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= -github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= -github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= -github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= -github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= +github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= +github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= +github.com/ctfer-io/go-ctfd v0.3.3 h1:XrI2sUBrNond2sLvHD4d4F9S4qBil/DUbM74CsQ+z90= +github.com/ctfer-io/go-ctfd v0.3.3/go.mod h1:GnWhEdXMI2PEpGZXsADzBvnU1e9MbuWQiBnSSNOY3cs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -35,71 +24,30 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= -github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= -github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= -github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= -github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/gorilla/schema v1.2.1 h1:tjDxcmdb+siIqkTNoV+qRH2mjYdr2hHe5MKXbp61ziM= +github.com/gorilla/schema v1.2.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.4.10 h1:xUbmA4jC6Dq163/fWcp8P3JuHilrHHMLNRxzGQJ9hNk= -github.com/hashicorp/go-plugin v1.4.10/go.mod h1:6/1TEzT0eQznvI/gV2CM29DLSkAK/e58mUWKVsPaph0= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-plugin v1.5.1 h1:oGm7cWBaYIp3lJpx1RUEfLWophprE2EV/KUeqBYo+6k= +github.com/hashicorp/go-plugin v1.5.1/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.5.2 h1:SfwMFnEXVVirpwkDuSF5kymUOhrUxrTq3udEseZdOD0= -github.com/hashicorp/hc-install v0.5.2/go.mod h1:9QISwe6newMWIfEiXpzuu1k9HAGtQYgnSH8H9T8wmoI= -github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= -github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= -github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX5H8XZxHlH4= -github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980= -github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA= -github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o= -github.com/hashicorp/terraform-plugin-framework v1.3.4 h1:dOTLsALgmQu+PawAvhfGQ04H0MeIz3EZmBw7OFvj7qs= -github.com/hashicorp/terraform-plugin-framework v1.3.4/go.mod h1:2gGDpWiTI0irr9NSTLFAKlTi6KwGti3AoU19rFqU30o= -github.com/hashicorp/terraform-plugin-go v0.18.0 h1:IwTkOS9cOW1ehLd/rG0y+u/TGLK9y6fGoBjXVUquzpE= -github.com/hashicorp/terraform-plugin-go v0.18.0/go.mod h1:l7VK+2u5Kf2y+A+742GX0ouLut3gttudmvMgN0PA74Y= +github.com/hashicorp/terraform-plugin-framework v1.4.2 h1:P7a7VP1GZbjc4rv921Xy5OckzhoiO3ig6SGxwelD2sI= +github.com/hashicorp/terraform-plugin-framework v1.4.2/go.mod h1:GWl3InPFZi2wVQmdVnINPKys09s9mLmTZr95/ngLnbY= +github.com/hashicorp/terraform-plugin-go v0.19.0 h1:BuZx/6Cp+lkmiG0cOBk6Zps0Cb2tmqQpDM3iAtnhDQU= +github.com/hashicorp/terraform-plugin-go v0.19.0/go.mod h1:EhRSkEPNoylLQntYsk5KrDHTZJh9HQoumZXbOGOXmec= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.28.0 h1:gY4SG34ANc6ZSeWEKC9hDTChY0ZiN+Myon17fSA0Xgc= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.28.0/go.mod h1:deXEw/iJXtJxNV9d1c/OVJrvL7Zh0a++v7rzokW6wVY= -github.com/hashicorp/terraform-plugin-testing v1.5.1 h1:T4aQh9JAhmWo4+t1A7x+rnxAJHCDIYW9kXyo4sVO92c= -github.com/hashicorp/terraform-plugin-testing v1.5.1/go.mod h1:dg8clO6K59rZ8w9EshBmDp1CxTIPu3yA4iaDpX1h5u0= -github.com/hashicorp/terraform-registry-address v0.2.1 h1:QuTf6oJ1+WSflJw6WYOHhLgwUiQ0FrROpHPYFtwTYWM= -github.com/hashicorp/terraform-registry-address v0.2.1/go.mod h1:BSE9fIFzp0qWsJUUyGquo4ldV9k2n+psif6NYkBRS3Y= +github.com/hashicorp/terraform-registry-address v0.2.2 h1:lPQBg403El8PPicg/qONZJDC6YlgCVbWDtNmmZKtBno= +github.com/hashicorp/terraform-registry-address v0.2.2/go.mod h1:LtwNbCihUoUZ3RYriyS2wF/lGPB6gF9ICLRtuDk7hSo= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= -github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= -github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= -github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= -github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= @@ -118,10 +66,6 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/pandatix/go-ctfd v0.1.9 h1:4ZiydbZgV2kXNTRnqyJfChFuxUt7W8RRsfw9T0LicmI= -github.com/pandatix/go-ctfd v0.1.9/go.mod h1:RzuIfvJGweW7/a8uo+STh9e6m2Hbi8o1DskmeHljiK4= -github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= -github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -141,25 +85,8 @@ github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9 github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= -github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -github.com/zclconf/go-cty v1.13.3 h1:m+b9q3YDbg6Bec5rr+KGy1MzEVzY/jC2X+YX4yqKtHI= -github.com/zclconf/go-cty v1.13.3/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U= -golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= -golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= -golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -168,23 +95,15 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= -google.golang.org/grpc v1.56.1 h1:z0dNfjIl0VpaZ9iSVjA6daGatAYwPGstTjt5vkRMFkQ= -google.golang.org/grpc v1.56.1/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= diff --git a/internal/provider/challenge/file_subresource.go b/internal/provider/challenge/file_subresource.go index 55a1c1f..0e802f2 100644 --- a/internal/provider/challenge/file_subresource.go +++ b/internal/provider/challenge/file_subresource.go @@ -7,12 +7,12 @@ import ( "strconv" "github.com/ctfer-io/go-ctfd/api" - "github.com/opentofu/terraform-plugin-framework/diag" - "github.com/opentofu/terraform-plugin-framework/resource/schema" - "github.com/opentofu/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/opentofu/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/opentofu/terraform-plugin-framework/types" - "github.com/opentofu/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" ) type FileSubresourceModel struct { @@ -64,7 +64,7 @@ func FileSubresourceAttributes() map[string]schema.Attribute { func (file *FileSubresourceModel) Read(ctx context.Context, diags diag.Diagnostics, client *api.Client) { content, err := client.GetFileContent(&api.File{ Location: file.Location.ValueString(), - }, api.WithContext(ctx)) + }) if err != nil { diags.AddError( "CTFd Error", @@ -76,7 +76,7 @@ func (file *FileSubresourceModel) Read(ctx context.Context, diags diag.Diagnosti file.PropagateContent(ctx, diags) } -func (data *FileSubresourceModel) Create(ctx context.Context, diags diag.Diagnostics, client *api.Client, challengeID string) { +func (data *FileSubresourceModel) Create(ctx context.Context, diags diag.Diagnostics, client *api.Client, challengeID int) { // Fetch raw or base64 content prior to creating it with raw data.PropagateContent(ctx, diags) if diags.HasError() { diff --git a/internal/provider/challenge/flag_subresource.go b/internal/provider/challenge/flag_subresource.go index 580d0e7..8413593 100644 --- a/internal/provider/challenge/flag_subresource.go +++ b/internal/provider/challenge/flag_subresource.go @@ -6,13 +6,13 @@ import ( "strconv" "github.com/ctfer-io/go-ctfd/api" - "github.com/opentofu/terraform-plugin-framework/diag" - "github.com/opentofu/terraform-plugin-framework/resource/schema" - "github.com/opentofu/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/opentofu/terraform-plugin-framework/resource/schema/stringdefault" - "github.com/opentofu/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/opentofu/terraform-plugin-framework/types" - "github.com/opentofu/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" ) type FlagSubresourceModel struct { @@ -50,7 +50,7 @@ func FlagSubresourceAttributes() map[string]schema.Attribute { } } -func (data *FlagSubresourceModel) Create(ctx context.Context, diags diag.Diagnostics, client *api.Client, challengeID string) { +func (data *FlagSubresourceModel) Create(ctx context.Context, diags diag.Diagnostics, client *api.Client, challengeID int) { res, err := client.PostFlags(&api.PostFlagsParams{ Challenge: challengeID, Content: data.Content.ValueString(), diff --git a/internal/provider/challenge/hint_subresource.go b/internal/provider/challenge/hint_subresource.go index f453768..55a4339 100644 --- a/internal/provider/challenge/hint_subresource.go +++ b/internal/provider/challenge/hint_subresource.go @@ -6,13 +6,13 @@ import ( "strconv" "github.com/ctfer-io/go-ctfd/api" - "github.com/opentofu/terraform-plugin-framework/diag" - "github.com/opentofu/terraform-plugin-framework/resource/schema" - "github.com/opentofu/terraform-plugin-framework/resource/schema/int64default" - "github.com/opentofu/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/opentofu/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/opentofu/terraform-plugin-framework/types" - "github.com/opentofu/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" ) // TODO requirements can be set manually, but can't be automatised. Hint may be a complete resource @@ -48,7 +48,7 @@ func HintSubresourceAttributes() map[string]schema.Attribute { } } -func (data *HintSubresourceModel) Create(ctx context.Context, diags diag.Diagnostics, client *api.Client, challengeID string) { +func (data *HintSubresourceModel) Create(ctx context.Context, diags diag.Diagnostics, client *api.Client, challengeID int) { preq := make([]int, 0, len(data.Requirements)) for _, req := range data.Requirements { hintID, _ := strconv.Atoi(req.ValueString()) diff --git a/internal/provider/challenge/requirements_subresource.go b/internal/provider/challenge/requirements_subresource.go index da514ba..10046d1 100644 --- a/internal/provider/challenge/requirements_subresource.go +++ b/internal/provider/challenge/requirements_subresource.go @@ -2,7 +2,7 @@ package challenge import ( "github.com/ctfer-io/terraform-provider-ctfd/internal/provider/utils" - "github.com/opentofu/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types" ) var ( diff --git a/internal/provider/challenge_data_source.go b/internal/provider/challenge_data_source.go index 306f142..ce35c11 100644 --- a/internal/provider/challenge_data_source.go +++ b/internal/provider/challenge_data_source.go @@ -8,9 +8,9 @@ import ( "github.com/ctfer-io/go-ctfd/api" "github.com/ctfer-io/terraform-provider-ctfd/internal/provider/challenge" "github.com/ctfer-io/terraform-provider-ctfd/internal/provider/utils" - "github.com/opentofu/terraform-plugin-framework/datasource" - "github.com/opentofu/terraform-plugin-framework/datasource/schema" - "github.com/opentofu/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" ) var ( @@ -139,7 +139,7 @@ func (ch *challengeDataSource) Read(ctx context.Context, req datasource.ReadRequ for _, chall := range challs { // Fetch the challenge with all its information as the CTFd API is broken as fuck - chall, err := ch.client.GetChallenge(strconv.Itoa(chall.ID), api.WithContext(ctx)) + chall, err := ch.client.GetChallenge(chall.ID, api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( fmt.Sprintf("Unable to Read CTFd Challenge %d", chall.ID), @@ -149,7 +149,7 @@ func (ch *challengeDataSource) Read(ctx context.Context, req datasource.ReadRequ } // => Files - files, err := ch.client.GetChallengeFiles(strconv.Itoa(chall.ID)) + files, err := ch.client.GetChallengeFiles(chall.ID) if err != nil { resp.Diagnostics.AddError( fmt.Sprintf("Unable to Read CTFd files of Challenge %d", chall.ID), @@ -169,7 +169,7 @@ func (ch *challengeDataSource) Read(ctx context.Context, req datasource.ReadRequ } // => Flags - flags, err := ch.client.GetChallengeFlags(strconv.Itoa(chall.ID), api.WithContext(ctx)) + flags, err := ch.client.GetChallengeFlags(chall.ID, api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( fmt.Sprintf("Unable to Read CTFd flags of Challenge %d", chall.ID), @@ -189,7 +189,7 @@ func (ch *challengeDataSource) Read(ctx context.Context, req datasource.ReadRequ } // => Tags - tags, err := ch.client.GetChallengeTags(strconv.Itoa(chall.ID), api.WithContext(ctx)) + tags, err := ch.client.GetChallengeTags(chall.ID, api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( fmt.Sprintf("Unable to Read CTFd tags of Challenge %d", chall.ID), @@ -203,7 +203,7 @@ func (ch *challengeDataSource) Read(ctx context.Context, req datasource.ReadRequ } // => Topics - topics, err := ch.client.GetChallengeTopics(strconv.Itoa(chall.ID), api.WithContext(ctx)) + topics, err := ch.client.GetChallengeTopics(chall.ID, api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( fmt.Sprintf("Unable to Read CTFd topics of Challenge %d", chall.ID), @@ -217,7 +217,7 @@ func (ch *challengeDataSource) Read(ctx context.Context, req datasource.ReadRequ } // => Hints - hints, err := ch.client.GetChallengeHints(strconv.Itoa(chall.ID), api.WithContext(ctx)) + hints, err := ch.client.GetChallengeHints(chall.ID, api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( fmt.Sprintf("Unable to Reac CTFd hints of Challenge %d", chall.ID), @@ -244,7 +244,7 @@ func (ch *challengeDataSource) Read(ctx context.Context, req datasource.ReadRequ Name: types.StringValue(chall.Name), Category: types.StringValue(chall.Category), Description: types.StringValue(chall.Description), - Value: utils.ToTFInt64(chall.Value), + Value: types.Int64Value(int64(chall.Value)), Initial: utils.ToTFInt64(chall.Initial), Decay: utils.ToTFInt64(chall.Decay), Minimum: utils.ToTFInt64(chall.Minimum), diff --git a/internal/provider/challenge_resource.go b/internal/provider/challenge_resource.go index c2b8edc..72ad6cb 100644 --- a/internal/provider/challenge_resource.go +++ b/internal/provider/challenge_resource.go @@ -5,21 +5,21 @@ import ( "fmt" "strconv" - api "github.com/ctfer-io/go-ctfd/api" + "github.com/ctfer-io/go-ctfd/api" "github.com/ctfer-io/terraform-provider-ctfd/internal/provider/challenge" "github.com/ctfer-io/terraform-provider-ctfd/internal/provider/utils" "github.com/ctfer-io/terraform-provider-ctfd/internal/provider/validators" - "github.com/opentofu/terraform-plugin-framework/path" - "github.com/opentofu/terraform-plugin-framework/resource" - "github.com/opentofu/terraform-plugin-framework/resource/schema" - "github.com/opentofu/terraform-plugin-framework/resource/schema/int64default" - "github.com/opentofu/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/opentofu/terraform-plugin-framework/resource/schema/stringdefault" - "github.com/opentofu/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/opentofu/terraform-plugin-framework/schema/validator" - "github.com/opentofu/terraform-plugin-framework/types" - "github.com/opentofu/terraform-plugin-framework/types/basetypes" - "github.com/opentofu/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" ) var ( @@ -214,7 +214,7 @@ func (r *challengeResource) Create(ctx context.Context, req resource.CreateReque Description: data.Description.ValueString(), ConnectionInfo: data.ConnectionInfo.ValueStringPointer(), MaxAttempts: utils.ToInt(data.MaxAttempts), - Value: utils.ToInt(data.Value), + Value: int(data.Value.ValueInt64()), Initial: utils.ToInt(data.Initial), Decay: utils.ToInt(data.Decay), Minimum: utils.ToInt(data.Minimum), @@ -238,7 +238,7 @@ func (r *challengeResource) Create(ctx context.Context, req resource.CreateReque // Create files challFiles := make([]challenge.FileSubresourceModel, 0, len(data.Files)) for _, file := range data.Files { - file.Create(ctx, resp.Diagnostics, r.client, data.ID.ValueString()) + file.Create(ctx, resp.Diagnostics, r.client, utils.Atoi(data.ID.ValueString())) challFiles = append(challFiles, file) } if data.Files != nil { @@ -248,7 +248,7 @@ func (r *challengeResource) Create(ctx context.Context, req resource.CreateReque // Create flags challFlags := make([]challenge.FlagSubresourceModel, 0, len(data.Flags)) for _, flag := range data.Flags { - flag.Create(ctx, resp.Diagnostics, r.client, data.ID.ValueString()) + flag.Create(ctx, resp.Diagnostics, r.client, utils.Atoi(data.ID.ValueString())) challFlags = append(challFlags, flag) } if data.Flags != nil { @@ -259,7 +259,7 @@ func (r *challengeResource) Create(ctx context.Context, req resource.CreateReque challTags := make([]types.String, 0, len(data.Tags)) for _, tag := range data.Tags { _, err := r.client.PostTags(&api.PostTagsParams{ - Challenge: data.ID.ValueString(), + Challenge: utils.Atoi(data.ID.ValueString()), Value: tag.ValueString(), }, api.WithContext(ctx)) if err != nil { @@ -279,7 +279,7 @@ func (r *challengeResource) Create(ctx context.Context, req resource.CreateReque challTopics := make([]types.String, 0, len(data.Topics)) for _, topic := range data.Topics { _, err := r.client.PostTopics(&api.PostTopicsParams{ - Challenge: data.ID.ValueString(), + Challenge: utils.Atoi(data.ID.ValueString()), Type: "challenge", Value: topic.ValueString(), }, api.WithContext(ctx)) @@ -299,7 +299,7 @@ func (r *challengeResource) Create(ctx context.Context, req resource.CreateReque // Create hints challHints := make([]challenge.HintSubresourceModel, 0, len(data.Hints)) for _, hint := range data.Hints { - hint.Create(ctx, resp.Diagnostics, r.client, data.ID.ValueString()) + hint.Create(ctx, resp.Diagnostics, r.client, utils.Atoi(data.ID.ValueString())) challHints = append(challHints, hint) } if data.Hints != nil { @@ -320,7 +320,7 @@ func (r *challengeResource) Read(ctx context.Context, req resource.ReadRequest, } // Retrieve challenge - res, err := r.client.GetChallenge(data.ID.ValueString(), api.WithContext(ctx)) + res, err := r.client.GetChallenge(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read challenge %s, got error: %s", data.ID.ValueString(), err)) return @@ -328,9 +328,9 @@ func (r *challengeResource) Read(ctx context.Context, req resource.ReadRequest, data.Name = types.StringValue(res.Name) data.Category = types.StringValue(res.Category) data.Description = types.StringValue(res.Description) - data.ConnectionInfo = types.StringValue(res.ConnectionInfo) - data.MaxAttempts = types.Int64Value(int64(res.MaxAttempts)) - data.Value = utils.ToTFInt64(res.Value) + data.ConnectionInfo = utils.ToTFString(res.ConnectionInfo) + data.MaxAttempts = utils.ToTFInt64(res.MaxAttempts) + data.Value = types.Int64Value(int64(res.Value)) data.Initial = utils.ToTFInt64(res.Initial) data.Decay = utils.ToTFInt64(res.Decay) data.Minimum = utils.ToTFInt64(res.Minimum) @@ -338,7 +338,7 @@ func (r *challengeResource) Read(ctx context.Context, req resource.ReadRequest, data.Type = types.StringValue(res.Type) // Read its requirements - resReqs, err := r.client.GetChallengeRequirements(data.ID.ValueString(), api.WithContext(ctx)) + resReqs, err := r.client.GetChallengeRequirements(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( "Client Error", @@ -359,7 +359,7 @@ func (r *challengeResource) Read(ctx context.Context, req resource.ReadRequest, data.Requirements = reqs // Read its files - resFiles, err := r.client.GetChallengeFiles(data.ID.ValueString(), api.WithContext(ctx)) + resFiles, err := r.client.GetChallengeFiles(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( "Client Error", @@ -381,7 +381,7 @@ func (r *challengeResource) Read(ctx context.Context, req resource.ReadRequest, } // Read its flags - resFlags, err := r.client.GetChallengeFlags(data.ID.ValueString(), api.WithContext(ctx)) + resFlags, err := r.client.GetChallengeFlags(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( "Client Error", @@ -404,7 +404,7 @@ func (r *challengeResource) Read(ctx context.Context, req resource.ReadRequest, } // Read its tags - resTags, err := r.client.GetChallengeTags(data.ID.ValueString(), api.WithContext(ctx)) + resTags, err := r.client.GetChallengeTags(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( "Client Error", @@ -421,7 +421,7 @@ func (r *challengeResource) Read(ctx context.Context, req resource.ReadRequest, } // Read its topics - resTopics, err := r.client.GetChallengeTopics(data.ID.ValueString(), api.WithContext(ctx)) + resTopics, err := r.client.GetChallengeTopics(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( "Client Error", @@ -438,7 +438,7 @@ func (r *challengeResource) Read(ctx context.Context, req resource.ReadRequest, } // Read its hints - resHints, err := r.client.GetChallengeHints(data.ID.ValueString(), api.WithContext(ctx)) + resHints, err := r.client.GetChallengeHints(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( "Client Error", @@ -494,18 +494,18 @@ func (r *challengeResource) Update(ctx context.Context, req resource.UpdateReque Prerequisites: preqs, } } - _, err := r.client.PatchChallenge(data.ID.ValueString(), &api.PatchChallengeParams{ - Name: data.Name.ValueStringPointer(), - Category: data.Category.ValueStringPointer(), - Description: data.Description.ValueStringPointer(), + _, err := r.client.PatchChallenge(utils.Atoi(data.ID.ValueString()), &api.PatchChallengeParams{ + Name: data.Name.ValueString(), + Category: data.Category.ValueString(), + Description: data.Description.ValueString(), ConnectionInfo: data.ConnectionInfo.ValueStringPointer(), MaxAttempts: utils.ToInt(data.MaxAttempts), - Value: utils.ToInt(data.Value), - Initial: utils.ToInt(data.Initial), - Decay: utils.ToInt(data.Decay), - Minimum: utils.ToInt(data.Minimum), - State: data.State.ValueStringPointer(), - Requirements: reqs, + // Value: int(data.Value.ToInt64Value()), // TODO add support of .value in PATCH /challenges + Initial: utils.ToInt(data.Initial), + Decay: utils.ToInt(data.Decay), + Minimum: utils.ToInt(data.Minimum), + State: data.State.ValueString(), + Requirements: reqs, }, api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( @@ -516,7 +516,7 @@ func (r *challengeResource) Update(ctx context.Context, req resource.UpdateReque } // Update its files - currentFiles, err := r.client.GetChallengeFiles(data.ID.ValueString(), api.WithContext(ctx)) + currentFiles, err := r.client.GetChallengeFiles(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( "Client Error", @@ -543,7 +543,7 @@ func (r *challengeResource) Update(ctx context.Context, req resource.UpdateReque update := !corFile.Content.Equal(file.Content) if update { file.Delete(ctx, resp.Diagnostics, r.client) - file.Create(ctx, resp.Diagnostics, r.client, data.ID.ValueString()) + file.Create(ctx, resp.Diagnostics, r.client, utils.Atoi(data.ID.ValueString())) } files = append(files, file) @@ -551,7 +551,7 @@ func (r *challengeResource) Update(ctx context.Context, req resource.UpdateReque } } if !exists { - file.Create(ctx, resp.Diagnostics, r.client, data.ID.ValueString()) + file.Create(ctx, resp.Diagnostics, r.client, utils.Atoi(data.ID.ValueString())) files = append(files, file) } } @@ -576,7 +576,7 @@ func (r *challengeResource) Update(ctx context.Context, req resource.UpdateReque } // Update its flags - currentFlags, err := r.client.GetChallengeFlags(data.ID.ValueString(), api.WithContext(ctx)) + currentFlags, err := r.client.GetChallengeFlags(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( "Client Error", @@ -596,7 +596,7 @@ func (r *challengeResource) Update(ctx context.Context, req resource.UpdateReque } } if !exists { - tfFlag.Create(ctx, resp.Diagnostics, r.client, data.ID.ValueString()) + tfFlag.Create(ctx, resp.Diagnostics, r.client, utils.Atoi(data.ID.ValueString())) flags = append(flags, tfFlag) } } @@ -620,7 +620,7 @@ func (r *challengeResource) Update(ctx context.Context, req resource.UpdateReque } // Update its tags (drop them all, create new ones) - challTags, err := r.client.GetChallengeTags(data.ID.ValueString(), api.WithContext(ctx)) + challTags, err := r.client.GetChallengeTags(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( "Client Error", @@ -640,7 +640,7 @@ func (r *challengeResource) Update(ctx context.Context, req resource.UpdateReque tags := make([]types.String, 0, len(data.Tags)) for _, tag := range data.Tags { _, err := r.client.PostTags(&api.PostTagsParams{ - Challenge: data.ID.ValueString(), + Challenge: utils.Atoi(data.ID.ValueString()), Value: tag.ValueString(), }, api.WithContext(ctx)) if err != nil { @@ -657,7 +657,7 @@ func (r *challengeResource) Update(ctx context.Context, req resource.UpdateReque } // Update its topics (drop them all, create new ones) - challTopics, err := r.client.GetChallengeTopics(data.ID.ValueString(), api.WithContext(ctx)) + challTopics, err := r.client.GetChallengeTopics(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( "Client Error", @@ -677,7 +677,7 @@ func (r *challengeResource) Update(ctx context.Context, req resource.UpdateReque topics := make([]types.String, 0, len(data.Topics)) for _, topic := range data.Topics { _, err := r.client.PostTopics(&api.PostTopicsParams{ - Challenge: data.ID.ValueString(), + Challenge: utils.Atoi(data.ID.ValueString()), Type: "challenge", Value: topic.ValueString(), }, api.WithContext(ctx)) @@ -695,7 +695,7 @@ func (r *challengeResource) Update(ctx context.Context, req resource.UpdateReque } // Update its hints - currentHints, err := r.client.GetChallengeHints(data.ID.ValueString(), api.WithContext(ctx)) + currentHints, err := r.client.GetChallengeHints(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)) if err != nil { resp.Diagnostics.AddError( "Client Error", @@ -715,7 +715,7 @@ func (r *challengeResource) Update(ctx context.Context, req resource.UpdateReque } } if !exists { - tfHint.Create(ctx, resp.Diagnostics, r.client, data.ID.ValueString()) + tfHint.Create(ctx, resp.Diagnostics, r.client, utils.Atoi(data.ID.ValueString())) hints = append(hints, tfHint) } } @@ -751,7 +751,7 @@ func (r *challengeResource) Delete(ctx context.Context, req resource.DeleteReque return } - if err := r.client.DeleteChallenge(data.ID.ValueString(), api.WithContext(ctx)); err != nil { + if err := r.client.DeleteChallenge(utils.Atoi(data.ID.ValueString()), api.WithContext(ctx)); err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to delete challenge, got error: %s", err)) return } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index b595b64..e4f22d8 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -5,13 +5,13 @@ import ( "os" "github.com/ctfer-io/go-ctfd/api" - "github.com/opentofu/terraform-plugin-framework/datasource" - "github.com/opentofu/terraform-plugin-framework/path" - "github.com/opentofu/terraform-plugin-framework/provider" - "github.com/opentofu/terraform-plugin-framework/provider/schema" - "github.com/opentofu/terraform-plugin-framework/resource" - "github.com/opentofu/terraform-plugin-framework/types" - "github.com/opentofu/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/provider" + "github.com/hashicorp/terraform-plugin-framework/provider/schema" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" ) var _ provider.Provider = &CTFdProvider{} diff --git a/internal/provider/utils/utils.go b/internal/provider/utils/utils.go index a02076f..f11399d 100644 --- a/internal/provider/utils/utils.go +++ b/internal/provider/utils/utils.go @@ -1,9 +1,10 @@ package utils import ( + "strconv" "strings" - "github.com/opentofu/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types" ) // return a null types.Int64 if pointer is nil, else its value @@ -14,6 +15,13 @@ func ToTFInt64(i *int) types.Int64 { return types.Int64Value(int64(*i)) } +func ToTFString(str *string) types.String { + if str == nil { + return types.StringNull() + } + return types.StringValue(*str) +} + // return a nil point if types.Int64 is null, else its value func ToInt(itf types.Int64) *int { if itf.IsNull() { @@ -31,3 +39,10 @@ func Filename(location string) string { func Ptr[T any](t T) *T { return &t } + +// Atoi MUST only be called on trusted input as it won't +// return an error nor panic after calling `strconv.Atoi`. +func Atoi(s string) int { + v, _ := strconv.Atoi(s) + return v +} diff --git a/main.go b/main.go index 5d0f453..cafdd29 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,7 @@ import ( "log" "github.com/ctfer-io/terraform-provider-ctfd/internal/provider" - "github.com/opentofu/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-framework/providerserver" ) var (